Custom Default Fonts

Description

Trying to set two custom fonts as default

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

iMX6-Custom board-gcc for arm

What LVGL version are you using?

v7

What do you want to achieve?

See the new fonts

What have you tried so far?

I used the font online converter starting from WOFF files to get my c files.
I added my custom fonts in lv_conf.f:

#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(grotesque_regular_16) \
							   LV_FONT_DECLARE(source_sans_pro_regular_16)

but nothing happened.
Probably I’m missing this instruction:

  • Set the font in a style: style.text.font = &my_font_name;

but my static lv_style_t style does not have any text.font, just a map field.

Thank you for your time

Paste your font into your code, then use LV_FONT_DECLARE (your_font) in the code.

Already done: I saved my font in a *.c file and used LV_FONT_DECLARE, but no result.

For v7 you can set the default fonts in lv_conf.h. If you want to change the font for one widget, please refer to this code sample:

    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_text_font(&style, LV_STATE_DEFAULT, &custom_font);

That’s right!

Now LV_FONT_CUSTOM_DECLARE works. I forgot to disable the default font (montserrat)