Change font size #1744
-
Hi, I have been testing the U8g2 library, i only want to know if theres by any chance, a way to change de font or text size. In the original Adafruit.GFX library i have is there something similar in the U8g2 library? regardless, thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
The Adafruit setTextSize() will just extend each pixel, which will be fast, but will not look good: U8g2 does not support such scaling of the pixels. Note that most embedded controllers are not fast enough and do not have enough memory to do a proper scaling of fonts. |
Beta Was this translation helpful? Give feedback.
-
Correct, with a .ttf font for example you can generate the .bdf file out of it with a different size (see the FAQ).
U8g2 is a monochrome graphics library. It only deals with enabled or disabled pixel values. Whether an enabled pixel appears white, blue, pink or black is defined by your display. Same is true for a disabled pixel value. Whatever color is visible if the pixel value is zero depends on your display. Usually, if you need red background color, you need to get a display with red LED backlight (see here for example: https://www.lcd-module.com/produkte/dog.html). |
Beta Was this translation helpful? Give feedback.
-
I am confused. U8g2 does not support ili 9431. |
Beta Was this translation helpful? Give feedback.
-
ah ok, in this case you must use a font with a "_hr" or "_mr" postfix (h or m instead of the t). And of course you need to apply a proper background color: u8g2_for_adafruit_gfx.setBackgroundColor(uint16_t color) Here are some fonts which will work better in your case:
As an alternative solution: You could clear the previous data with a rectangle and then write the new text. |
Beta Was this translation helpful? Give feedback.
ah ok, in this case you must use a font with a "_hr" or "_mr" postfix (h or m instead of the t).
And of course you need to apply a proper background color: u8g2_for_adafruit_gfx.setBackgroundColor(uint16_t color)
Here are some fonts which will work better in your case: