Kaynağa Gözat

Merge pull request #71 from markwal/lastlinewidth

getTextBounds should consider the last line width
Paint Your Dragon 9 yıl önce
ebeveyn
işleme
2fced4b700
1 değiştirilmiş dosya ile 2 ekleme ve 0 silme
  1. 2 0
      Adafruit_GFX.cpp

+ 2 - 0
Adafruit_GFX.cpp

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