I am converting a ttf font file to hex array code, then using it on a display connected to ESP32. All works fine.
Since I am using only numbers (0..9, . , ,) , how can I convert the numeric characters only instead all characters from the particular font file?
My last solution will be edit the font file and remove all characters except the numbers, But is there any easier way to achieve this?
I am not following what you are saying. I will take a swag and say you should do a range check on the variable before printing and decide what to do with it if you do not want to print it. You can just ignore it if you like.
Test them before loading and do not load the invalid ones. You will have to read the characters to test or display them so that function does not go away. The other thing is modify the source so it does the filtering.
Depends a lot on what display library you are using. The U8g2 library, as well as the libraries based on Adafruit_GFX, have ways of limiting the range of characters in the font.
The ESP32 does not have PROGMEM as such, that is only applicable to some AVR processors. The ESP32 has flash memory that serves the same purpose, but since it is in the same address space as the ram the PROGMEM methods are unnecessary.
You can extract only the numeric characters from the TTF font file by using a font editing tool like FontForge. Instead of editing the file manually, you can select only the numeric characters (0-9, comma, and period) and export them. This way, you avoid converting the entire font to a hex array and can streamline the process for your ESP32 display. It's definitely easier than manually removing all other characters. I’ve done something similar when designing gym accessories like a Lifting Belt, and it really simplifies the process.
@J-M-L Yes. It is difficult to understand the hex structure for removing unnecessary fonts.
So I am going to export the numeric characters only and make a new font for this purpose. it will only contain 12 characters.
Yes. I had this on my mind. But thought easier to remove some characters in the hex file. But now, I will export the characters needed only to make a new font and use it. will contain 12 char.
Are you using the tools included with the TFT_eSPI library? The Create_font.pde file has options for only converting specific characters. There is already a commented out example for the characters needed for a clock (0123456789+-.:apm only), that can easily be changed to what you need.
The tools I am using is from a you tube video mentioned in their video. Did not know there are any tools included with the library . But I will take a look.