@@ -1392,7 +1392,7 @@ void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
13921392 @param h The boundary height, set by function
13931393*/
13941394/* *************************************************************************/
1395- void Adafruit_GFX::getTextBounds (char *str, int16_t x, int16_t y,
1395+ void Adafruit_GFX::getTextBounds (const char *str, int16_t x, int16_t y,
13961396 int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
13971397 uint8_t c; // Current character
13981398
@@ -1415,6 +1415,26 @@ void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
14151415 }
14161416}
14171417
1418+ /* *************************************************************************/
1419+ /* !
1420+ @brief Helper to determine size of a string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
1421+ @param str The ascii string to measure (as an arduino String() class)
1422+ @param x The current cursor X
1423+ @param y The current cursor Y
1424+ @param x1 The boundary X coordinate, set by function
1425+ @param y1 The boundary Y coordinate, set by function
1426+ @param w The boundary width, set by function
1427+ @param h The boundary height, set by function
1428+ */
1429+ /* *************************************************************************/
1430+ void Adafruit_GFX::getTextBounds (const String &str, int16_t x, int16_t y,
1431+ int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
1432+ if (str.length () != 0 ) {
1433+ getTextBounds (const_cast <char *>(str.c_str ()), x, y, x1, y1, w, h);
1434+ }
1435+ }
1436+
1437+
14181438/* *************************************************************************/
14191439/* !
14201440 @brief Helper to determine size of a PROGMEM string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
0 commit comments