Style with new font size is not working on lv_label objects

Description

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

ESP32-C6 Dev Board

What LVGL version are you using?

8.3.11 with esp_lvgl_port 1.4.0

What do you want to achieve?

i want to set the font size of a single label to “large!”

What have you tried so far?

I enabled the large font in the menuconfig, initialized a new style, applied the font and applied the style to the label. the label did not change.

Code to reproduce

void create_ui_components(lv_disp_t *disp)
{
   <code ommitted...>
    lv_style_t style;
    lv_style_init(&style);
    lv_style_set_text_font(&style, &lv_font_montserrat_48);
    
    strcat(centerText, getOpModeString());
    strcat(centerText, " - ");
    strcat(centerText, getStatusString());
    
    status_label = lv_label_create(scr);
    lv_label_set_text(status_label, centerText);
    lv_obj_add_style(status_label, &style, 0); // <= i would expect this to work...
    lv_obj_align(status_label, LV_ALIGN_CENTER, 0, 0);
}

any ideas on what i’m doing wrong? it surely cannot be much…
thank you so much!

I dont know if you want to go down this route but I use:

lv_obj_set_style_text_font(status_label, &lv_font_montserrat_48, LV_PART_MAIN);

Hope this helps you in some way…

Or maybe you need to set the style then the text?

Regards

oh nice thank you, that solved it for me!
I still would be interested what i did originally wrong, but this issue is now resolved :slight_smile: