Code:
// Add in Adafruit versions of text bounds calculations.
void ILI9341_t3n::getTextBounds(const uint8_t *buffer, uint16_t len, int16_t x,
int16_t y, int16_t *x1, int16_t *y1,
uint16_t *w, uint16_t *h) {
*x1 = x;
*y1 = y;
*w = *h = 0;
int16_t minx = _width, miny = _height, maxx = -1, maxy = -1;
while (len--) {
uint8_t c = *buffer++;
charBounds(c, &x, &y, &minx, &miny, &maxx, &maxy);
//Serial.printf("%c in(%d %d) out(%d %d) - min(%d %d) max(%d %d)\n", c, *x1, *y1, x, y, minx, miny, maxx, maxy);
}
if (maxx >= minx) {
*x1 = minx;
*w = maxx - minx + 1;
}
if (maxy >= miny) {
*y1 = miny;
*h = maxy - miny + 1;
}
//Serial.printf("GTB %d %d %d %d\n", *x1, *y1, *w, *h);
}
void ILI9341_t3n::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
*x1 = x;
*y1 = y;
*w = *h = 0;
int16_t minx = _width, miny = _height, maxx = -1, maxy = -1;
while ((c = *str++)) {
charBounds(c, &x, &y, &minx, &miny, &maxx, &maxy);
//Serial.printf("%c in(%d %d) out(%d %d) - min(%d %d) max(%d %d)\n", c, *x1, *y1, x, y, minx, miny, maxx, maxy);
}
if (maxx >= minx) {
*x1 = minx;
*w = maxx - minx + 1;
}
if (maxy >= miny) {
*y1 = miny;
*h = maxy - miny + 1;
}
//Serial.printf("GTB %d %d %u %u\n", *x1, *y1, *w, *h);
}
void ILI9341_t3n::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);
}
}
Guess I am confused on how to make them work! What bugs me is the way I did it (at the top) did work from May 2022, until yesterday, until IDE2 was installed. Then everything broke. @KurtE can you throw me a bone? Thanks.