Adding icons from fontawesome

I’ve tried following the instructions as best i can but think i’ve missed a crucial step… I am not getting errors but i’m also not getting my icon :slight_smile:

I have…

  • lv_label_set_text(label, MY_SEARCH_SYMBOL);*    (tested and works with lvgl standard symbols)

All i get is a blank button where i want to see an icon, am i missing something obvious here? Do i need some more code in my .iso to tell it about this new icon?

Have you set a style for the label which uses your font?

Using this site I’ve found that MY_SEARCH_SYMBOL “\xEF\x8F\xBD” (UTF-8) is F3FD (Unicode). However, F3FD is not part of your font file.

Ahha, setting the style, thanks for the pointers, so my solution was…

Create a style:

static lv_style_t CustomIconsFont; lv_style_copy(&CustomIconsFont, &lv_style_btn_rel ); /*Initialize from a built-in style*/ CustomIconsFont.text.font = &CustomIcons;

and apply that style to my label object

lv_obj_set_style( label, &CustomIconsFont);

For others working this out i found this documentation useful.

1 Like

It seems the LVGL I am using has been modified and lv_style_t doesn’t have the data member “text”.
Could you please reply how to set the style to use the font?


For 7.x versions:

static lv_style_t style;
lv_style_set_text_font(&style, LV_STATE_DEFAULT, &lv_font_montserrat_12);
lv_obj_add_style(label, LV_LABEL_PART_MAIN, &style);

Thanks a lot. Got my symbol on the LCD.

lv_style_set_text_font(&style, LV_STATE_DEFAULT, &my_symbol);