From 8100858101dd9a871216d7beb5b29c677ec78696 Mon Sep 17 00:00:00 2001 From: Arthur Tazhitdinov Date: Sun, 1 Feb 2026 15:23:22 +0500 Subject: [PATCH] fix: return text as is if it fits --- lib/GfxRenderer/GfxRenderer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/GfxRenderer/GfxRenderer.cpp b/lib/GfxRenderer/GfxRenderer.cpp index 2eab1a44..b5aa7710 100644 --- a/lib/GfxRenderer/GfxRenderer.cpp +++ b/lib/GfxRenderer/GfxRenderer.cpp @@ -419,9 +419,13 @@ std::string GfxRenderer::truncatedText(const int fontId, const char* text, const std::string item = text; const char* ellipsis = "..."; - int ellipsisWidth = getTextWidth(fontId, ellipsis, style); + int textWidth = getTextWidth(fontId, item.c_str(), style); + if (textWidth <= maxWidth) { + // Text fits, return as is + return item; + } - while (!item.empty() && getTextWidth(fontId, (item + ellipsis).c_str(), style) > maxWidth) { + while (!item.empty() && getTextWidth(fontId, (item + ellipsis).c_str(), style) >= maxWidth) { utf8RemoveLastChar(item); }