Merge pull request #71 from markwal/lastlinewidth

getTextBounds should consider the last line width
This commit is contained in:
Paint Your Dragon 2016-08-23 15:16:40 -07:00 committed by GitHub
commit 2fced4b700

View File

@ -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;
@ -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;