Add custom Font awesome symbol to lv_label using style not displaying

Description

I have used LVGL font converter to add a font with one symbol code “\xEF\xF7\x8C” /63372 f78c/
Copied the file to the Font folder, added ‘myfontawesome’
myfontawesome.c (6.1 KB)
to a style. The example below compiles, the button is drawn but with out the custom symbol being shown.

Using Waveahare ESP32 s3 touch 4.3
LVGL 8.4 (with lvgl_port_v8 from waveshare)

Code to reproduce

void lv_example_btn_1(void)
{
LV_FONT_DECLARE(myfontawesome);
#define MY_USB_SYMBOL “\xEF\xF7\x8C”
static lv_style_t style_btn;
lv_style_init(&style_btn);
lv_style_set_text_font(&style_btn,&myfontawesome);

lv_obj_t * label;
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);

label = lv_label_create(btn1);
lv_obj_add_style(label, &style_btn, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(label, MY_USB_SYMBOL);
lv_obj_center(label);

}

I also tried adding

#if !defined MY_SYMBOL
#define MY_SYMBOL_ “\xEF\xF7\x8C” /63372 0xF78C/
#endif

to lv_symbol_def.h

What am I missing.

Thank you for any help.

Did you add it to symbol instead of range like I incorrectly did?

Good point, i cannot rember but i thought i added as range so i will have another go. Do you see anything wrong in the code example.

You should have the following outside of the button example, it should be in the h file if you’re using c or the main ino if Arduino

LV_FONT_DECLARE(myfontawesome);
#define MY_USB_SYMBOL “\xEF\xF7\x8C”

Also when I’ve done mine in the past i directly set the font on the label instead of using a style as I was only using them here and there…

    lbl_MainLight_Icon = lv_label_create(ui_Home_Screen);
    lv_obj_set_style_text_color(lbl_MainLight_Icon, lv_color_hex(LV_COLOUR_LIGHT_OFF), LV_PART_MAIN);
    lv_label_set_text(lbl_MainLight_Icon, LV_SYMBOL_POWER);
    lv_obj_set_style_text_font(lbl_MainLight_Icon, &lv_font_montserrat_40, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_align_to(lbl_MainLight_Icon, btn_light, LV_ALIGN_TOP_LEFT, -5, -5);

Hi

OK checked I did use range. Note using arduino same result no icon displayed

LV_FONT_DECLARE(myfontawesome);
#define MY_USB_SYMBOL “\xEF\xF7\x8C”

void setup()
{
/* lvgl_port_v8 code left out*/

lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, 0);

lv_obj_t * label = lv_label_create(btn1);
lv_label_set_text(label, MY_USB_SYMBOL"arrow");
lv_obj_set_style_text_font(label, &myfontawesome, LV_PART_MAIN| LV_STATE_DEFAULT);
lv_obj_align_to(label, btn1, LV_ALIGN_CENTER, 0, 0);

}

Apart from putting myfontawesome in /src/fonts folder is there any where else I need to make declarations.
Although I download FontAwesome5-Solid+Brands+Regular.woff and used this in the font converter, I assume that if my range was not valid then the process would error.

i think f78c symbol should be represented in utf-8 as \xEF\x9E\x8C sequence