lvgl / lv_font_conv

Converts TTF/WOFF fonts to compact bitmap format
https://lvgl.io/tools/fontconverter
MIT License
187 stars 79 forks source link

Use lv_font_conv to convert Chinese display garbled code #124

Open flashsim opened 4 weeks ago

flashsim commented 4 weeks ago

I use LVGL 9.1.1 version. After using the official online and offline font conversion tools to convert a Chinese character, the demo example shows garbled characters on the LCD. I don't know where the error is. Can you give me some suggestions? thinks

The command to use the offline conversion tool is: lv_font_conv --no-compress --format bin --font QingNiaoHuaGuangJianMeiHei-2.ttf -o my_font-guo.bin --bpp 4 --size 30 --symbols "国"

I used the online method to save the bin file and compared it with the bin file generated above. The generated bin files are the same. the test code is: void lvgl_font_test(void) { lv_font_t * font_18 = lv_binfont_create("0:my_font.bin"); if (font_18 == NULL) { printf("font load failed \r\n"); return; }

lv_obj_t *label_name = lv_label_create(lv_screen_active());
lv_label_set_text(label_name, "国");
lv_obj_set_style_text_color(label_name, lv_color_hex(0x003a57), LV_PART_MAIN);
lv_obj_set_style_text_font(label_name, font_18, LV_PART_MAIN);
lv_obj_align(label_name, LV_ALIGN_CENTER, 0, 0);

lv_binfont_destroy(font_18);

}

Christer-Ekholm commented 3 weeks ago

My first try debugging test would be

lv_font_conv --no-compress --format bin --font QingNiaoHuaGuangJianMeiHei-2.ttf -o my_font-guo.bin --bpp 4 --size 30 --r 0x56FD

lv_label_set_text(label_name, u8"\u56FD");

I am not sure if those UTF codes are correct because I have worked so little with those. I am newer trusting encodings of editors and consoles so I would try numerical values first.