Addind new symbols


How can I add new symbols please ?
I tried things based on this documentation but I’m not a C expert and beginning with micropython and lvgl.
What’s the full process for adding a fontawsome symbol in micropython please ?


You have a few options:

  • One way is to use a custom font and load it dynamically on runtime.
    Here is an Online Demo
    The disadvantage is that this approach requires more RAM and cost cycles to load the font on runtime.
  • If you want the font on flash and ready for use without loading it, you must compile the font statically. You don’t need to be a C expert for that, but you do need some basic understanding in C and in the Micropython build system.
  • Another approach is to use imgfont, where you can replace specific characters with images

Thank’s amigron.

I’m working from this stm32f469 port of LVGL. It’s not the last LVGL version but there is the only one port for this board that I have found. (I haven’t the skill to port latest LVGL at this time :-/)
I would prefer to use the second approach with the C file.
I do that:

  • Build C files with the online converter is OK.
  • I add the files into usermods/udisplay_f469/fonts folder.
  • I add LV_FONT_DECLARE(custom_symbols_16) into usermods/udisplay_f469/lv_conf.h
  • I add SRC_USERMOD += $(DISPLAY_MOD_DIR)/fonts/custom_symbols_16.c\ into usermods/udisplay_f469/` file

Trying to use style.text.font = lv.custom_symbols_16 into my code but obtain this error: 'module' object has no attribute 'custom_symbols_16'
Something escapes me but I can’t see what.

I also thought of adding symbols in the existing source code of the roboto font.
At first glance it seemed possible but it’s obviously not as simple as copying / pasting pieces of code from the file generated by the converter into the roboto source, especially in the “glyph description” section

Do you have any advice for me please ?

It’s very old.
Looking at their files, they froze Micropython bindings on Jan 2021, nearly two years ago, and didn’t update since.
You can consider taking their display driver and using it with newer lv_micropython (but only if their license agreement allows this)

You should add something like:

#define LV_FONT_CUSTOM_DECLARE   LV_FONT_DECLARE(lv_custom_symbols_16) 

(note the lv_ prefix!)
Then the font should be available as lv.custom_symbols_16

Thank you for your advice. I will do some tests in this direction.

I thought about trying to port it in v8 but I still have to learn I think.
The project is under MIT license so no worries for porting. I keep this idea into my head