How to set differents size fonts in elements

Description

I want to use differents size fonts in my GUI, I have enable the LV_FONT_MONTSERRAT_10, and LV_FONT_MONTSERRAT_26 and my fonts defined are:

#define LV_THEME_DEFAULT_FONT_SMALL         &lv_font_montserrat_10
#define LV_THEME_DEFAULT_FONT_NORMAL        &lv_font_montserrat_26
#define LV_THEME_DEFAULT_FONT_SUBTITLE      &lv_font_montserrat_26
#define LV_THEME_DEFAULT_FONT_TITLE         &lv_font_montserrat_26

How can I use the FONT_SMALL for elements of dropdownlist or one label?

Thanks in advance

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

ESP32 nodeMCU with Arduino IDE

What LVGL version are you using?

v7.7.2-dev

Code to reproduce

My dropdownlist

  ddlist = lv_dropdown_create(bg_top, NULL);
    lv_dropdown_set_show_selected(ddlist, false);
    lv_dropdown_set_text(ddlist, LV_SYMBOL_WIFI);
    //lv_dropdown_set_max_width(ddlist ,20);
    lv_obj_set_size(ddlist, 30, 30);
    lv_dropdown_set_symbol(ddlist, false);
    lv_dropdown_set_dir(ddlist, LV_DROPDOWN_DIR_LEFT);
    lv_dropdown_set_options(ddlist, "...Searching...");
    lv_obj_align(ddlist, NULL, LV_ALIGN_IN_TOP_LEFT, 205, 10);
    lv_obj_set_event_cb(ddlist, dropDown_handler);

And my label:

label_status = lv_label_create(bg_bottom, NULL);
    lv_label_set_long_mode(label_status, LV_LABEL_LONG_SROLL_CIRC);
    lv_obj_set_width(label_status, LV_HOR_RES - 20);
    lv_label_set_text(label_status, "test");
    lv_obj_align(label_status, NULL, LV_ALIGN_CENTER, 0, 0);

I try this, but I don’t know how to call


static lv_style_t st;
lv_style_set_text_font( &st, label_status, &lv_font_montserrat_10);

I’m not sure, but in my opinion

lv_style_set_text_font (label_status, &lv_font_montserrat_10)

It doesn’t work I tried. Thanks!

The exception is:

main:81:64: error: cannot convert 'lv_obj_t* {aka _lv_obj_t*}' to 'lv_style_t*' for argument '1' to 'void lv_style_set_text_font(lv_style_t*, lv_state_t, const lv_font_t*)'
     lv_style_set_text_font(label_status, &lv_font_montserrat_10);

How it’s the lv_state_t?How can I set to the label? Thanks

This should work:

lv_obj_set_style_local_text_font(label_status, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_THEME_DEFAULT_FONT_SMALL);

It works, Also I got it with this solution

static lv_style_t smallFont;

lv_style_init(&smallFont);
lv_style_set_text_font( &smallFont, LV_STATE_DEFAULT, &lv_font_montserrat_10);

lv_obj_add_style(label_status, LV_OBJ_PART_MAIN, &smallFont);

But now my problem it’s that I want to set in the elements of a dropdownlist, if I set to the dropdownlist, only have this small font in the title of the dropdown but no the elements in the list, how can I get it?

ddlist = lv_dropdown_create(bg_top, NULL);
    lv_dropdown_set_show_selected(ddlist, false);
    lv_dropdown_set_text(ddlist, LV_SYMBOL_WIFI);
    lv_obj_set_style_local_text_font(ddlist , LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_THEME_DEFAULT_FONT_SMALL);
    lv_obj_set_size(ddlist, 30, 30);
    lv_dropdown_set_symbol(ddlist, false);
    lv_dropdown_set_dir(ddlist, LV_DROPDOWN_DIR_LEFT);
    lv_dropdown_set_options(ddlist, "...Searching...");
    lv_obj_align(ddlist, NULL, LV_ALIGN_IN_TOP_LEFT, 205, 10);
    lv_obj_set_event_cb(ddlist, dropDown_handler);

I fixed it whit
lv_obj_add_style(ddlist, LV_DROPDOWN_PART_LIST, &smallFont);

Thanks for all