Skip to content

Commit

Permalink
Merge pull request #25163 from CastagnaIT/fix_text_regressions
Browse files Browse the repository at this point in the history
[GUIFontTTF] Fix regressions on centered GUI text
  • Loading branch information
fuzzard committed May 9, 2024
2 parents 8526557 + 174a4c5 commit e56e40c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions xbmc/guilib/GUIFontTTF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,13 @@ void CGUIFontTTF::DrawTextInternal(CGraphicContext& context,
if (!c)
continue;

float nextWidth;
float nextWidth = textWidth;
if ((ch & 0xffff) == static_cast<character_t>('\t'))
nextWidth = GetTabSpaceLength();
nextWidth += GetTabSpaceLength();
else
nextWidth = textWidth + c->m_advance;
nextWidth += c->m_advance;

if (nextWidth > maxPixelWidth)
if (maxPixelWidth > 0 && nextWidth > maxPixelWidth)
{
// Start rendering from the glyph that does not exceed the maximum width
startPosGlyph = std::distance(itRGlyph, glyphs.crend());
Expand All @@ -540,13 +540,13 @@ void CGUIFontTTF::DrawTextInternal(CGraphicContext& context,
if (!c)
continue;

float nextWidth;
float nextWidth = textWidth;
if ((ch & 0xffff) == static_cast<character_t>('\t'))
nextWidth = GetTabSpaceLength();
nextWidth += GetTabSpaceLength();
else
nextWidth = textWidth + c->m_advance;
nextWidth += c->m_advance;

if (nextWidth > maxPixelWidth)
if (maxPixelWidth > 0 && nextWidth > maxPixelWidth)
break;

textWidth = nextWidth;
Expand Down

0 comments on commit e56e40c

Please sign in to comment.