Fixed a text abbreviation issue.

This commit is contained in:
Leon Styhre 2022-09-28 17:21:02 +02:00
parent 49c9710afc
commit f048d06b95

View file

@ -340,7 +340,8 @@ std::string Font::wrapText(std::string text, float maxLength, float maxHeight, f
if (restrictHeight && currLineLength != 0.0f && maxHeight < lineHeight && if (restrictHeight && currLineLength != 0.0f && maxHeight < lineHeight &&
wordSize > maxLength - textSize.x) { wordSize > maxLength - textSize.x) {
// Multi-word lines. // Multi-word lines.
if (maxLength - currLineLength + dotsSize < wordSize) { if (maxLength - currLineLength + dotsSize < wordSize &&
sizeText(line).x + dotsSize > maxLength) {
while (sizeText(line).x + dotsSize > maxLength) while (sizeText(line).x + dotsSize > maxLength)
line.pop_back(); line.pop_back();
} }
@ -353,6 +354,9 @@ std::string Font::wrapText(std::string text, float maxLength, float maxHeight, f
line = line + word; line = line + word;
} }
if (line.back() == ' ')
line.pop_back();
line.append("..."); line.append("...");
break; break;
} }
@ -411,6 +415,8 @@ std::string Font::wrapText(std::string text, float maxLength, float maxHeight, f
out.pop_back(); out.pop_back();
} }
} }
if (out.back() == ' ')
out.pop_back();
out.append("..."); out.append("...");
} }