From 0a746427321d0a9e89cfb2148de1fd4749a5ff0e Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 6 Oct 2025 16:07:06 -0500 Subject: [PATCH] feat(ui): handle max lines and line height in CSimpleFontString::GetDisplayText --- src/ui/CSimpleFontString.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ui/CSimpleFontString.cpp b/src/ui/CSimpleFontString.cpp index cfc5889..b99396a 100644 --- a/src/ui/CSimpleFontString.cpp +++ b/src/ui/CSimpleFontString.cpp @@ -142,14 +142,18 @@ const char* CSimpleFontString::GetDisplayText(float width, float height) { return nullptr; } - if (!this->m_font || width <= 0.0f || /* TODO */ height <= 0.0f) { + if (!this->m_font || width <= 0.0f || (this->m_maxLines == 0 && height <= 0.0)) { return this->m_text; } auto fontHeight = this->GetFontHeight(true); - auto v5 = (CSimpleTop::RoundToPixelHeight(this->m_spacing) + fontHeight) * this->m_layoutScale; + auto lineHeight = (CSimpleTop::RoundToPixelHeight(this->m_spacing) + fontHeight) * this->m_layoutScale; - // TODO + if (this->m_maxLines != 0) { + height = lineHeight * this->m_maxLines; + } else if (lineHeight >= height) { + height = lineHeight; + } auto text = this->m_text; auto textLen = SStrLen(text);