Enabled linear interpolation for font texture magnification when running on display resolutions at or above approximately 1920x1080.

This commit is contained in:
Leon Styhre 2022-09-02 21:30:16 +02:00
parent 9b1fb95865
commit ce50c1121b
2 changed files with 8 additions and 2 deletions

View file

@ -66,6 +66,10 @@ void Font::initLibrary()
sLibrary = nullptr; sLibrary = nullptr;
LOG(LogError) << "Couldn't initialize FreeType"; 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<std::string> Font::getFallbackFontPaths() std::vector<std::string> Font::getFallbackFontPaths()
@ -590,8 +594,9 @@ bool Font::FontTexture::findEmpty(const glm::ivec2& size, glm::ivec2& cursor_out
void Font::FontTexture::initTexture() void Font::FontTexture::initTexture()
{ {
assert(textureId == 0); assert(textureId == 0);
textureId = Renderer::getInstance()->createTexture( textureId =
Renderer::TextureType::RED, true, false, false, textureSize.x, textureSize.y, nullptr); Renderer::getInstance()->createTexture(Renderer::TextureType::RED, true, mHighResolution,
false, textureSize.x, textureSize.y, nullptr);
} }
void Font::FontTexture::deinitTexture() void Font::FontTexture::deinitTexture()

View file

@ -175,6 +175,7 @@ private:
int mSize; int mSize;
int mMaxGlyphHeight; int mMaxGlyphHeight;
const std::string mPath; const std::string mPath;
static inline bool mHighResolution {false};
float getNewlineStartOffset(const std::string& text, float getNewlineStartOffset(const std::string& text,
const unsigned int& charStart, const unsigned int& charStart,