From 0ca6d06fbaa29d549bcd8a5868bc6f7cda8f2b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Wed, 15 Mar 2023 13:43:14 +0100 Subject: [PATCH] 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. --- src/engine/client/text.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index effd418eb..d75f9d1c1 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -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)