mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
fix: return text as is if it fits
This commit is contained in:
parent
68ba5a7f5e
commit
8100858101
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user