Skip to content

Commit

Permalink
Font ascent and descent were wrong in SFML backend when font scale wa…
Browse files Browse the repository at this point in the history
…s set
  • Loading branch information
texus committed Dec 19, 2024
1 parent f631a4f commit 9320e00
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Backend/Font/SFML-Graphics/BackendFontSFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ namespace tgui
if (!m_font->hasGlyph(U'\u00CA'))
return static_cast<float>(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<float>(scaledTextSize) / m_fontScale;
#endif
Expand All @@ -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<unsigned int>(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;
}

Expand Down

0 comments on commit 9320e00

Please sign in to comment.