页次: 1
请发一下你的字库,还有代码的改动点,我们这边测试一下。
1. make menuconfig,进入 menuconfig
ArtInChip Luban SDK Configuration --->
Third-party packages --->
freetype --->选择但取消二进制预编译
2.在lv_conf.h头文件中打开宏定义
#define LV_USE_FREETYPE 1
#define LV_BUILD_EXAMPLES 1
3.修改main.c中的入口函数:
/*Create a Demo*/
void base_ui_init();
base_ui_init();
4.复制TTF字体到lvgl-ui/base_ui/asserts/font目录下
5. 修改lvgl-ui\base_ui\base_ui.c
void base_ui_init()
{
FAKE_IMAGE_INIT(bg_dark, 1024, 600, 0, 0x00000000);
img_bg = lv_img_create(lv_scr_act());
lv_img_set_src(img_bg, LVGL_PATH(global_bg.png));
lv_obj_set_pos(img_bg, 0, 0);
/*Create a font*/
static lv_ft_info_t info;
/*FreeType uses C standard file system, so no driver letter is required.*/
info.name = "/usr/local/share/lvgl_data/font/GenJyuuGothic-Light-2.ttf";
info.weight = 48;
info.style = FT_FONT_STYLE_NORMAL;
info.mem = NULL;
if(!lv_ft_font_init(&info)) {
LV_LOG_ERROR("create failed.");
}
/*Create style*/
static lv_style_t font_style;
lv_style_init(&font_style);
lv_style_set_text_font(&font_style, info.font);
main_title = lv_label_create(img_bg);
lv_obj_set_width(main_title, LV_SIZE_CONTENT);
lv_obj_set_height(main_title, LV_SIZE_CONTENT);
lv_obj_align(main_title, LV_ALIGN_TOP_MID, 0, 0);
lv_obj_set_pos(main_title, 0, 10);
lv_obj_add_style( main_title, &font_style, 0 );
lv_label_set_text(main_title, "Meter");
lv_obj_set_style_text_color(main_title, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(main_title, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
bg_fps = lv_label_create(img_bg);
lv_obj_set_width(bg_fps, LV_SIZE_CONTENT);
lv_obj_set_height(bg_fps, LV_SIZE_CONTENT);
lv_obj_align(bg_fps, LV_ALIGN_TOP_RIGHT, 0, 0);
lv_obj_set_pos(bg_fps, -130, 50);
lv_label_set_text(bg_fps, "");
lv_obj_set_style_text_color(bg_fps, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(bg_fps, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(bg_fps, &ui_font_Title, LV_PART_MAIN | LV_STATE_DEFAULT);
bg_logo = lv_label_create(img_bg);
lv_obj_set_width(bg_logo, LV_SIZE_CONTENT);
lv_obj_set_height(bg_logo, LV_SIZE_CONTENT);
lv_obj_align(bg_logo, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
lv_obj_set_pos(bg_logo, -30, -30);
lv_obj_add_style( bg_logo, &font_style, 0 );
lv_label_set_text(bg_logo, "矢量字");
lv_obj_set_style_text_color(bg_logo, lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(bg_logo, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
其它的都不变
D21x linux SDK包LVGL UI示例怎么设置 支持显示中文字符
选择freetype包,编译打包提示错误
Scanning dependencies of target test_lvgl
[ 97%] Building C object CMakeFiles/test_lvgl.dir/base_ui/base_ui.c.o
[ 97%] Building C object CMakeFiles/test_lvgl.dir/base_ui/cpu_mem.c.o
[ 98%] Building C object CMakeFiles/test_lvgl.dir/base_ui/font/ui_font_H1.c.o
[ 98%] Building C object CMakeFiles/test_lvgl.dir/base_ui/font/ui_font_Title.c.o
[ 98%] Building C object CMakeFiles/test_lvgl.dir/base_ui/font/ui_font_Big.c.o
[ 98%] Building C object CMakeFiles/test_lvgl.dir/main.c.o
[ 98%] Building C object CMakeFiles/test_lvgl.dir/lv_drivers/aic_dec.c.o
[ 99%] Building C object CMakeFiles/test_lvgl.dir/lv_drivers/lv_fbdev.c.o
[ 99%] Building C object CMakeFiles/test_lvgl.dir/lv_drivers/lv_ge2d.c.o
[ 99%] Building C object CMakeFiles/test_lvgl.dir/lv_drivers/lv_port_indev.c.o
[ 99%] Building C object CMakeFiles/test_lvgl.dir/lv_drivers/lv_port_disp.c.o
[100%] Linking C executable test_lvgl
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: warning: libpng16.so.16, needed by /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so, not found (try using -rpath or -rpath-link)
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_expand_gray_1_2_4_to_8@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_read_end@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_get_error_ptr@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_gray_to_rgb@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_read_info@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_destroy_read_struct@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_read_user_transform_fn@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_read_image@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_create_read_struct@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_get_IHDR@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_read_update_info@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_longjmp_fn@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_get_valid@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_read_fn@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_create_info_struct@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_tRNS_to_alpha@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_interlace_handling@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_error@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_filler@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_get_io_ptr@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_packing@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_palette_to_rgb@PNG16_0'
/home/mcgs/d211-master/output/d211_demo128_nand/host/opt/ext-toolchain/bin/../lib/gcc/riscv64-unknown-linux-gnu/10.4.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/mcgs/d211-master/output/d211_demo128_nand/host/riscv64-linux-gnu/sysroot/usr/lib64xthead/lp64d/libfreetype.so: undefined reference to `png_set_strip_16@PNG16_0'
collect2: error: ld returned 1 exit status
CMakeFiles/test_lvgl.dir/build.make:241: recipe for target 'test_lvgl' failed
make[4]: *** [test_lvgl] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/test_lvgl.dir/all' failed
make[3]: *** [CMakeFiles/test_lvgl.dir/all] Error 2
Makefile:132: recipe for target 'all' failed
make[2]: *** [all] Error 2
package/utils/pkg-generic.mk:398: recipe for target '/home/mcgs/d211-master/output/d211_demo128_nand/build/lvgl-ui/.stamp_built' failed
make[1]: *** [/home/mcgs/d211-master/output/d211_demo128_nand/build/lvgl-ui/.stamp_built] Error 2
Makefile:73: recipe for target '_all' failed
make: *** [_all] Error 2
页次: 1