From ce50c1121b6103cfeca47a116a75bb319dc323b1 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 2 Sep 2022 21:30:16 +0200 Subject: [PATCH] Enabled linear interpolation for font texture magnification when running on display resolutions at or above approximately 1920x1080. --- es-core/src/resources/Font.cpp | 9 +++++++-- es-core/src/resources/Font.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index 2bb58add3..64a29fa50 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -66,6 +66,10 @@ void Font::initLibrary() sLibrary = nullptr; LOG(LogError) << "Couldn't initialize FreeType"; } + + // Whether to enable linear interpolation for font texture magnification (a size of 90 + // means approximately 1920x1080). + mHighResolution = FONT_SIZE_LARGE > 90; } std::vector Font::getFallbackFontPaths() @@ -590,8 +594,9 @@ bool Font::FontTexture::findEmpty(const glm::ivec2& size, glm::ivec2& cursor_out void Font::FontTexture::initTexture() { assert(textureId == 0); - textureId = Renderer::getInstance()->createTexture( - Renderer::TextureType::RED, true, false, false, textureSize.x, textureSize.y, nullptr); + textureId = + Renderer::getInstance()->createTexture(Renderer::TextureType::RED, true, mHighResolution, + false, textureSize.x, textureSize.y, nullptr); } void Font::FontTexture::deinitTexture() diff --git a/es-core/src/resources/Font.h b/es-core/src/resources/Font.h index d7b54dc7f..dae9633a8 100644 --- a/es-core/src/resources/Font.h +++ b/es-core/src/resources/Font.h @@ -175,6 +175,7 @@ private: int mSize; int mMaxGlyphHeight; const std::string mPath; + static inline bool mHighResolution {false}; float getNewlineStartOffset(const std::string& text, const unsigned int& charStart,