From 795e69237c92ff3fdcb976c4be3e01eab4eabb4c Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Tue, 14 Mar 2023 21:21:16 -0700 Subject: [PATCH] Fixed lines ending with whitespace. --- src/dawn/display/font/BitmapFont.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dawn/display/font/BitmapFont.cpp b/src/dawn/display/font/BitmapFont.cpp index 8070a6bb..087b7397 100644 --- a/src/dawn/display/font/BitmapFont.cpp +++ b/src/dawn/display/font/BitmapFont.cpp @@ -79,10 +79,13 @@ void BitmapFont::buffer( if(maxWidth != -1 && (xy0.x+tileSize.x) > maxWidth) { // We've exceeded the edge on THIS character. We first need to go back to // the start of the word and push it to the new line - size_t charsToBeRewound = ((i - 1) - wordStart); - info->width = mathMax(info->width, xy0.x - (tileSize.x * charsToBeRewound)); + info->width = mathMax( + info->width, + (xy0.x - (tileSize.x * charsToBeRewound)) - + (wordStart > 0 && text[wordStart - 1] == FONT_SPACE ? tileSize.x : 0) + ); xy0.x = 0; xy0.y += tileSize.y; @@ -99,8 +102,6 @@ void BitmapFont::buffer( xy0.x += tileSize.x; j++; } - - // Next line begins with this word } tile = this->tileset->getTile(c);