I am trying to reduce the memory usage for storing fonts. Most of my fonts are small pixel fonts, so it should be relatively easy to double the size in all dimensions at runtime, not arbitrary scaling.
Does anyone have ideas on the best way to attempt this?
What MCU/Processor/Board and compiler are you using?
What do you want to achieve?
Runtime doubling of font sizes.
What have you tried so far?
Not much, seeing if there are recommendations on where to start.
My hope is that there would be a way to simply multiply all of the dimensions by a scale factor during render, which for a pixelated font should be fine. I am not looking for vector based calculation to give smooth scaling.
Otherwise you could create a new font render engine with an option for pixel size. 1 being default. Then you could render the fonts based on that value. For bonus points you could add antialiasing. Honestly that sounds like a fun project
The more I think about this, the more I like it. If you could balance speed and size, dynamic sizing with antialiasing would be fantastic. You could define a 12 or 14 point font and dynamically size it for substantial savings in memory
Lvgl now has functions to transform (scale and/or rotate) images. I’ve tried to apply them on glyphs but it gave quite bad quality for letters. I think it’d be reasonable to add a dedicated algorithm which scale 8 bit fonts in 0.5 … 2 range. Above 2 things gets trickier because some pixels will be skipped.
Could you contribute with algorithm like this? If so I’d integrate it to lvgl.
It’s prototype could look like:
About font scaling, is there any latest progress?
I am using the lvgl MicroPython version, primarily for Chinese fonts. I need to dynamically display different texts and sizes, which requires loading a large font library with various sizes. However, this results in significant program space usage. Is there a way to dynamically scale within a single font to support different font sizes?
Of course, I understand that scaling to different sizes may lead to less clear fonts, and we are willing to keep it within a reasonable range.
Could you please let me know if there are plans to support this feature, or if we need to modify functions such as lv_font_get_bitmap_fmt_txt and lv_font_get_glyph_dsc_fmt_txt ourselves?