From d4a2c460deb11e707409d2926d3ddedc93b9de2b Mon Sep 17 00:00:00 2001 From: Ron Tseytlin Date: Mon, 16 Dec 2024 22:47:35 +0200 Subject: [PATCH] Ignore last space in justified text --- src/modules/graphics/Font.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/Font.cpp b/src/modules/graphics/Font.cpp index bbf0d3fbb..6b882b69c 100644 --- a/src/modules/graphics/Font.cpp +++ b/src/modules/graphics/Font.cpp @@ -507,8 +507,12 @@ std::vector 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;