Ignore last space in justified text

This commit is contained in:
Ron Tseytlin
2024-12-16 22:47:35 +02:00
parent 7e34e0ad21
commit d4a2c460de
+5 -1
View File
@@ -507,8 +507,12 @@ std::vector<Font::DrawCommand> Font::generateVerticesFormatted(const love::font:
auto start = text.cps.begin() + range.getOffset();
auto end = start + range.getSize();
float numspaces = std::count(start, end, ' ');
if (text.cps[range.last] == ' ')
--numspaces;
if (width < wrap && numspaces >= 1)
extraspacing = (wrap - width) / (numspaces - 1);
extraspacing = (wrap - width) / numspaces;
else
extraspacing = 0.0f;
break;