Fix incorrect text width calculation of multi-line text

For text spanning multiple lines `TextWidth` only returned the length of the last line instead of the length of the longest line.
This commit is contained in:
Robert Müller 2023-03-15 13:43:14 +01:00
parent ad69d62015
commit 0ca6d06fba

View file

@ -845,7 +845,7 @@ public:
*pAlignedHeight = Cursor.m_AlignedFontSize;
if(pMaxCharacterHeightInLine != nullptr)
*pMaxCharacterHeightInLine = Cursor.m_MaxCharacterHeight;
return Cursor.m_X;
return Cursor.m_LongestLineWidth;
}
int TextLineCount(float Size, const char *pText, float LineWidth) override
@ -1416,8 +1416,7 @@ public:
LastCharWidth = CharWidth;
}
if(DrawX > pCursor->m_LongestLineWidth)
pCursor->m_LongestLineWidth = DrawX;
pCursor->m_LongestLineWidth = maximum(pCursor->m_LongestLineWidth, DrawX);
}
if(NewLine)