From 9320e0070efd705fc6704fabcbd5e9c7bfe0cf24 Mon Sep 17 00:00:00 2001 From: Bruno Van de Velde Date: Thu, 19 Dec 2024 15:19:26 +0100 Subject: [PATCH] Font ascent and descent were wrong in SFML backend when font scale was set --- src/Backend/Font/SFML-Graphics/BackendFontSFML.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Backend/Font/SFML-Graphics/BackendFontSFML.cpp b/src/Backend/Font/SFML-Graphics/BackendFontSFML.cpp index 87cde913e..d1d34d9fb 100644 --- a/src/Backend/Font/SFML-Graphics/BackendFontSFML.cpp +++ b/src/Backend/Font/SFML-Graphics/BackendFontSFML.cpp @@ -178,9 +178,9 @@ namespace tgui if (!m_font->hasGlyph(U'\u00CA')) return static_cast(scaledTextSize) / m_fontScale; - const FontGlyph& glyph = getGlyph(U'\u00CA', scaledTextSize, false, 0); + const FontGlyph& glyph = getGlyph(U'\u00CA', characterSize, false, 0); #else - const FontGlyph& glyph = getGlyph(U'\u00CA', scaledTextSize, false, 0); + const FontGlyph& glyph = getGlyph(U'\u00CA', characterSize, false, 0); if ((glyph.advance == 0) && (glyph.bounds == FloatRect{}) && (glyph.textureRect == UIntRect{})) return static_cast(scaledTextSize) / m_fontScale; #endif @@ -194,8 +194,7 @@ namespace tgui { // SFML doesn't provide a method to access the descent of the font. // We extract the descent by examining the 'g' glyph, assuming it exists. - const unsigned int scaledTextSize = static_cast(characterSize * m_fontScale); - const FontGlyph& glyph = getGlyph(U'g', scaledTextSize, false); + const FontGlyph& glyph = getGlyph(U'g', characterSize, false); return glyph.bounds.height + glyph.bounds.top; }