How to change symbol styles of tabview's tab object individually?


I have 2 tabs in tabview and are filled with symbols. Upon navigating to another tab, I want to change the symbol style.

What MCU/Processor/Board and compiler are you using?

lvgl pc sim

What LVGL version are you using?


What do you want to achieve?

I want to use the same symbol from fontawesome with two different styles (Regular/ Filled) in each tab of tabview.

What have you tried so far?

I added two fonts (Regular + Filled) with the same symbol unicode into the font converter and it combined two fonts into 1 file. I’m not quite sure how to switch between the two fonts in lvgl.

I did try to import the two styles as two separate fonts but I was not able to set the font locally to the tab1/ tab2 object.

Code to reproduce

The code block(s) should be formatted like:

LV_FONT_DECLARE(solid_circle_20); //Consist of both reg/filled fonts
#define SOLID_CIRCLE_20 "\uf111"

static lv_style_t style_tab;

lv_style_set_text_font(&style_tab, LV_STATE_DEFAULT, &solid_circle_20);

lv_obj_t *tabview = lv_tabview_create(lv_scr_act(), NULL);
lv_tabview_set_btns_pos(tabview, LV_TABVIEW_TAB_POS_BOTTOM);

lv_obj_t *tab1 = lv_tabview_add_tab(tabview, SOLID_CIRCLE_20);
lv_obj_t *tab2 = lv_tabview_add_tab(tabview, SOLID_CIRCLE_20);

I’d need to test this, but at first glance, attaching style_tab to tab1 and tab2 like this should work:

lv_obj_add_style(tab1, LV_PAGE_PART_BG, &style_tab);
lv_obj_add_style(tab2, LV_PAGE_PART_BG, &style_tab);

Is that what you tried?