Просмотр исходного кода

Merge pull request #71 from markwal/lastlinewidth

getTextBounds should consider the last line width
Paint Your Dragon лет назад: 9
Родитель
Сommit
2fced4b700
1 измененных файлов с 2 добавлено и 0 удалено
  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;