当前位置:网站首页>Esp32 development -lvgl uses internal and external fonts

Esp32 development -lvgl uses internal and external fonts

2022-06-11 04:07:00 z_ Curtain

code

LVGL Two types of encoding are supported , Namely ASCII Coding and UTF-8 code .
ASCII Encoding only supports the display of English characters .
UTF-8 code It can support the display of all characters in the world , Including displaying Chinese , Display icon font, etc .


typeface

LVGL Multiple fonts are supported by default , Including Chinese fonts . however LVGL Its own Chinese font library and Does not include all commonly used words .

Internal font library

LVGL The internal font library is in lvgl/src/lv_font In the folder . If you need to use a certain font , Only need to lv_conf.h Open the macro definition of the font in .

// Internal Chinese font library 
define  LV_FONT_SIMSUN_16_CJK            1  /*1000 most common CJK radicals*/

External font library

1、 Generating font files

To use an external font library, you must first use tools to generate font files . What we use here is LvglFontTool.
The tool will directly generate a .c file , Directly copy to the project for use .
 Insert picture description here

2、 Use font library

Copy the generated file to the project , You can use fonts by adding styles .

extern lv_font_t myFont;
lv_style_set_text_font(&style, LV_STATE_DEFAULT, &myFont);

Be careful :
1、 except extern You can also use LVGL Macro declaration for custom font library .
for example :LV_FONT_DECLARE(myFont)

2、 The generated file needs to be modified after being copied to the project lvgl The header file path of .


effect

 Insert picture description here

原网站

版权声明
本文为[z_ Curtain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020549199582.html