mirror of
https://github.com/adafruit/Adafruit-GFX-Library.git
synced 2024-10-03 18:18:46 -04:00
Merge pull request #130 from vortigont/dev
Added String overload to getTextBounds() #90
This commit is contained in:
commit
f379d7070c
@ -1392,7 +1392,7 @@ void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
|
||||
@param h The boundary height, set by function
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
|
||||
void Adafruit_GFX::getTextBounds(const char *str, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
|
||||
uint8_t c; // Current character
|
||||
|
||||
@ -1415,6 +1415,26 @@ void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Helper to determine size of a string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
|
||||
@param str The ascii string to measure (as an arduino String() class)
|
||||
@param x The current cursor X
|
||||
@param y The current cursor Y
|
||||
@param x1 The boundary X coordinate, set by function
|
||||
@param y1 The boundary Y coordinate, set by function
|
||||
@param w The boundary width, set by function
|
||||
@param h The boundary height, set by function
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::getTextBounds(const String &str, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
|
||||
if (str.length() != 0) {
|
||||
getTextBounds(const_cast<char*>(str.c_str()), x, y, x1, y1, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@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.
|
||||
|
@ -102,11 +102,14 @@ class Adafruit_GFX : public Print {
|
||||
setTextWrap(boolean w),
|
||||
cp437(boolean x=true),
|
||||
setFont(const GFXfont *f = NULL),
|
||||
getTextBounds(char *string, int16_t x, int16_t y,
|
||||
getTextBounds(const char *string, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
|
||||
getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
|
||||
getTextBounds(const String &str, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);
|
||||
|
||||
|
||||
#if ARDUINO >= 100
|
||||
virtual size_t write(uint8_t);
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user