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

Fonts #138

Open
VyacheslavKH opened this issue Oct 11, 2017 · 1 comment
Open

Fonts #138

VyacheslavKH opened this issue Oct 11, 2017 · 1 comment

Comments

@VyacheslavKH
Copy link

Good afternoon. When loading new fonts it is not possible to change the color of the substrate on which they are output. If the text is displayed in the same place on the screen, then the old characters are not overwritten.
  tft.setTextColor (Blue, Black); The color of the text changes, but there is no substrate. Please tell me how you can solve this problem.

@pljakobs
Copy link
Contributor

This is expected behaviour as proportional fonts don't have defined bounding boxes and characters may actually overlap, so clearing the character box might iteself lead to unintended behaviour.
You can use getTextBounds to get the actual bounding box for the given string (or the old string or the maximum string) and use fillRect to clear the text area.
Alternatively, you can create an extra canvas in the correct size, render your text on that canvas and then copy the canvas to your display device.
I have used the latter in my Gauges library (https://github.com/pljakobs/Arduino_Gauges) if you're looking for an example. The advantage is, that the whole text field will be displayed in one go.

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