Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Stefanhg opened this issue Jul 27, 2021 · 0 comments
Open

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

Stefanhg opened this issue Jul 27, 2021 · 0 comments

Comments

@Stefanhg
Copy link

Stefanhg commented Jul 27, 2021

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant