lvgl修改字体大小

Viewed 254

重现步骤

在设置好lvgl组件后,想设置label的字体大小,查了lvgl的api和https://docs.lvgl.io/master/API/font/lv_font.html中的资料,始终无法成功,后来通过REPL串口交互调试发现lvgl好像只内置了14号和16号大小的字体,如下图

期待结果和实际结果

怎么设置字体大小或者怎么导入其他大小的字体文件

软硬件版本信息

k230,CanMV-K230_01Studio_micropython_v1.1-0-g5a6fc54_nncase_v2.9.0.img

错误日志

尝试解决过程

补充材料

1 Answers

重新编译镜像,repo把源码拉下来后在src/canmv/port/3rd-party/lv_bindings/lv_conf.h中有默认支持的字体大小,按需自行修改编译镜像。镜像编译教程见:https://developer.canaan-creative.com/k230_canmv/zh/dev/zh/userguide/how_to_build.html

修改代码:

/*==================
 *   FONT USAGE
 *===================*/

/*Montserrat fonts with ASCII range and some symbols using bpp = 4
 *https://fonts.google.com/specimen/Montserrat*/
#define LV_FONT_MONTSERRAT_8  0
#define LV_FONT_MONTSERRAT_10 0
#define LV_FONT_MONTSERRAT_12 0
#define LV_FONT_MONTSERRAT_14 1
#define LV_FONT_MONTSERRAT_16 1
#define LV_FONT_MONTSERRAT_18 0
#define LV_FONT_MONTSERRAT_20 0
#define LV_FONT_MONTSERRAT_22 0
#define LV_FONT_MONTSERRAT_24 0
#define LV_FONT_MONTSERRAT_26 0
#define LV_FONT_MONTSERRAT_28 0
#define LV_FONT_MONTSERRAT_30 0
#define LV_FONT_MONTSERRAT_32 0
#define LV_FONT_MONTSERRAT_34 0
#define LV_FONT_MONTSERRAT_36 0
#define LV_FONT_MONTSERRAT_38 0
#define LV_FONT_MONTSERRAT_40 0
#define LV_FONT_MONTSERRAT_42 0
#define LV_FONT_MONTSERRAT_44 0
#define LV_FONT_MONTSERRAT_46 0
#define LV_FONT_MONTSERRAT_48 0