Skip to content

Commit

Permalink
Ignore last space in justified text
Browse files Browse the repository at this point in the history
  • Loading branch information
steveRoll-git committed Dec 16, 2024
1 parent 7e34e0a commit d4a2c46
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/graphics/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d4a2c46

Please sign in to comment.