Adafruit-GFX-Library icon indicating copy to clipboard operation
Adafruit-GFX-Library copied to clipboard

getTextBounds issue(s): If text is close to edge

Open Stefanhg opened this issue 4 years ago • 0 comments

  • Arduino board: Arduino Leonardo
  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.13

First up I've concluded that the getTextBounds function includes an additional character. Refer to the sketch I've included.

getTextBounds_Issue_example_002.zip

If I execute getTextBounds where my text is "Hello" the width is 60 but i expect 50. The unknown character I am guessing is the termination character /0 of the char array.

Secound issue is if you are too close to the edge of the display BUT there is enough space to draw.. If my X position is 270, and the width of the display is 320 then the width returned by getTextBounds is 318 I haven't looked much into the code for the library other than i came to the charBounds section and gave up My guess of what causes the issue: Note that 10px is because im using size 2 for my text. 270 + (10px * amount of characters) + 10px(unknown character) = 330px and the display is 320px max.

Stefanhg avatar Jul 27 '21 20:07 Stefanhg