Skip to content

Commit 2fced4b

Browse files
Merge pull request #71 from markwal/lastlinewidth
getTextBounds should consider the last line width
2 parents 334e815 + 39c2bb8 commit 2fced4b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Adafruit_GFX.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
772772
}
773773
// End of string
774774
if(lineWidth) y += textsize * 8; // Add height of last (or only) line
775+
if(lineWidth > maxWidth) maxWidth = lineWidth; // Is the last or only line the widest?
775776
*w = maxWidth - 1; // Don't include last interchar x gap
776777
*h = y - *y1;
777778

@@ -861,6 +862,7 @@ void Adafruit_GFX::getTextBounds(const __FlashStringHelper *str,
861862
}
862863
// End of string
863864
if(lineWidth) y += textsize * 8; // Add height of last (or only) line
865+
if(lineWidth > maxWidth) maxWidth = lineWidth; // Is the last or only line the widest?
864866
*w = maxWidth - 1; // Don't include last interchar x gap
865867
*h = y - *y1;
866868

0 commit comments

Comments
 (0)