Select a custom default font in KConfig

lvgl 9.5.0 on an ESP32S3 board.

Hi all,

my GUI uses custom fonts exclusively, so all montserrat fonts are disabled. In my lv_conf.h I select my custom default font in this way:

#define LV_FONT_CUSTOM_DECLARE \
    LV_FONT_DECLARE(font_geist_medium_20)

/** Always set a default font */
#define LV_FONT_DEFAULT &font_geist_medium_20

So far so good, no problems there.

Now I want to replicate this environment by using idf.py menuconfig but I did not find any way to do that, apart from setting CONFIG_LV_CONF_SKIP=n and using a custom lv_conf.h. I did not try that because it seems to me a clear declaration of defeat.

Am I missing something?

There is this in the release notes for the new v9.6

Migrating from v9.5 to v9.6 | LVGL Open

what I have done with some required “configs” was to add to the project CMakeList.txt

add_compile_definitions(CONFIG_LV_SYSMON_GET_IDLE=lv_timer_get_idle)
add_compile_definitions(CONFIG_LV_ATTRIBUTE_LARGE_RAM_ARRAY=EXT_RAM_BSS_ATTR)

for example…

cc @AndreCostaaa

Hi these work arounds are no longer required. So the whole issue is that it’s impossible to declare raw C expression in kconfig, it requires a header file or via some compiler definitions

Starting in v9.6 the following pattern was introduced:

that is you can directly define in your .config file:

LV_SYSMON_USE_CUSTOM_INCLUDE=y

LV_SYSMON_CUSTOM_INCLUDE=“path/to/something.h”

LVGL then includes path/to/something.h for you so you can define LV_SYSMON_GET_IDLE in that file and it will be picked up

The same pattern exists for all modules where the user can pass a custom C expression, font is also one of them

Let me know what you think

If I understood you correctly, in 9.6 I could include my own custom header file after the generated one. In my case I would need to do something like:

#undef LV_FONT_CUSTOM_DECLARE
#define LV_FONT_CUSTOM_DECLARE \
    LV_FONT_DECLARE(font_geist_medium_20)

#undef LV_FONT_DEFAULT
#define LV_FONT_DEFAULT &font_geist_medium_20

After that I would need to add font_geist_medium_20.c (or whatever C file defines that font) to the linking process in some way.

That sounds reasonable to me, although I would rename LV_SYSMON_USE_CUSTOM_INCLUDE and friends to LV_USE_CUSTOM_INCLUDE as the current name is quite misleading.

Yes that is correct, although

in this case you would use

LV_FONT_USE_CUSTOM_INCLUDE and LV_FONT_CUSTOM_INCLUDE instead of SYSMON

There is one custom include per module that needs it as to avoid having one big custom include with every possibility

Even better. Thank you for your help.

I can confirm it works. And this is the content of main/gui-font.h:

#define LV_FONT_CUSTOM_DECLARE \
        LV_FONT_DECLARE(font_geist_bold_24) \
        LV_FONT_DECLARE(font_geist_medium_20) \
        LV_FONT_DECLARE(font_geist_medium_40) \
        LV_FONT_DECLARE(font_geist_medium_48) \
        LV_FONT_DECLARE(font_geist_regular_20)
#undef LV_FONT_DEFAULT
#define LV_FONT_DEFAULT &font_geist_medium_20