Description
What MCU/Processor/Board and compiler are you using?
PC Simulator
What LVGL version are you using?
V9.1.0
What do you want to achieve?
I want to add multiple sizes of custom fonts e.g 16px and 32px of the font awesome font.
What have you tried so far?
I have converted the ttf files into c files using the lv_conv_font tool. If both the C files are included in the same C file then the same issue that PierreRambaud had occurs where the static definitions in the C files collide. I have come up with 2 approaches to fix this but I am unsure which of these is recommended since it is not mentioned in the relevant documentation.
-
Compile the C files separately before linking them with the main executable using CMake / Makefiles
-
Create header files to hide static definitions in C files from each other.
The header files would look something like this.
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
extern const lv_font_t font_awesome;
#else
lv_font_t font_awesome;
#endif
The header file can then be included in the main file and the c file added as an extra source file for the main executable.
What I am wondering what is the recommend/most used approach for add multiple custom fonts and could we add a note to the documentation to point new LVGL developers in the right direction?