How to set a font in V7?

Hello!

I’m trying to set a larger font for the label in the bottom of my gauge.
I never changed the font, but I thought it would not me too difficult. But I was wrong!

I’m using an ESP32 WROVER with ILI9341 and lvgl V7.

First I tried setting it in the style of the gauge, but there the lv.font was no attribute of the module.
Then I tried to do it locally, in different ways:

gauge1.set_style_local_text_font(lv.STATE.DEFAULT, lv.font_montserrat_20)

gauge1.set_style_local_text_font(lv.STATE.DEFAULT, lv_font_montserrat_20)

But I can’t seem to make it work.
I’m correct in understanding that this is a built-in font, isn’t it?

It’s easy to change font! You just need to know how to do it.
It’s documented on LVGL docs on “Fonts” chapter.

By default in lv_micropython, only font_montserrat_14 and font_montserrat_16 built-in fonts are enabled. The rest of them are disabled, to save memory.
It’s very easy to enable other fonts - just edit lv_conf.h, set LV_FONT_MONTSERRAT_XX to 1 and re-build lv_micropython.

You can also add custom built-in fonts by setting LV_FONT_CUSTOM_DECLARE.

Another option is to load font dynamically on runtime from the file system.
Here is an example script.

check this:

    static lv_style_t style;
    lv_style_init(&style);
	lv_style_set_text_font(&style, LV_STATE_DEFAULT, &lv_font_montserrat_28);//change font

    lv_obj_t * tempLabel;
    tempLabel = lv_label_create(lv_scr_act(), NULL);
    lv_obj_add_style(tempLabel, LV_OBJ_PART_MAIN, &style);
    lv_label_set_text(tempLabel, "Big TEXT");

Thank you! This was literally the only thing I missed. After changing from 20 to 16, everything worked as expected.
I have read the LVGL docs for 99%, but sometimes I am not fully aware what the differences are with the ‘smaller lvgl’ we use. Therefore I read about the builtin fonts (from 12px to 48px) and just assumed that they were all available in lv_micropython as well. Now that I realized this, I checked it, rebuilt lv_micropython with the extra fonts and everything works as expected.