Skip to content

Commit

Permalink
Merge pull request #71 from markwal/lastlinewidth
Browse files Browse the repository at this point in the history
getTextBounds should consider the last line width
  • Loading branch information
PaintYourDragon authored Aug 23, 2016
2 parents 334e815 + 39c2bb8 commit 2fced4b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Adafruit_GFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
}
// End of string
if(lineWidth) y += textsize * 8; // Add height of last (or only) line
if(lineWidth > maxWidth) maxWidth = lineWidth; // Is the last or only line the widest?
*w = maxWidth - 1; // Don't include last interchar x gap
*h = y - *y1;

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

Expand Down

0 comments on commit 2fced4b

Please sign in to comment.