aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzard <fuzzard@users.noreply.github.com>2024-05-09 10:11:43 +1000
committerGitHub <noreply@github.com>2024-05-09 10:11:43 +1000
commite56e40c7b6fc21b284803614ad8261482a17bc93 (patch)
treeea8eea09f1d6c962a0c3b9294a5b22862c7486ac
parent8526557197e3346556c73010e025d712a531b5bf (diff)
parent174a4c5810a62c34471893220692f1cb55d465a0 (diff)
downloadxbmc-e56e40c7b6fc21b284803614ad8261482a17bc93.tar.xz
Merge pull request #25163 from CastagnaIT/fix_text_regressions
[GUIFontTTF] Fix regressions on centered GUI text
-rw-r--r--xbmc/guilib/GUIFontTTF.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/xbmc/guilib/GUIFontTTF.cpp b/xbmc/guilib/GUIFontTTF.cpp
index ff11db14f8..f9f0eec2a3 100644
--- a/xbmc/guilib/GUIFontTTF.cpp
+++ b/xbmc/guilib/GUIFontTTF.cpp
@@ -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());
@@ -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;