lv_font_conv icon indicating copy to clipboard operation
lv_font_conv copied to clipboard

lv_font_conv:Use the tool to generate Chinese font bin file,lv_font_load Failed to load bin file

Open DragonYY123 opened this issue 11 months ago • 12 comments

lv_font_conv --font MiSans-Medium.ttf -r 0x20-0x7F --size 40 --format bin --bpp 2 --no-compress -o cour40_2.bin This bin file ok. lv_font_conv --font MiSans-Medium.ttf -r 0x20-0x7F -r 0x4E00-0x9FA5 --size 40 --format bin --bpp 2 --no-compress -o cour40_2unicode.bin Use lv_font_load() functions.Failed to load ambiq_cour40_2unicode.bin file. Please advise how to deal with it?

DragonYY123 avatar Feb 29 '24 01:02 DragonYY123

Please attach the ttf file and the result bin file too to reproduce the issue.

Which LVGL version do you use?

kisvegabor avatar Mar 05 '24 17:03 kisvegabor

Thank you for the response. Uploading ttf2bin2ambiq.zip…

font_realign.py:Used to generate bin files(ambiq_cour40_2unicode.bin) supported by ambiq LVGL version:8.1.0

DragonYY123 avatar Mar 06 '24 01:03 DragonYY123

The file upload wasn't successful. It seems you have pressed the "Comment" button too early. Please upload again.

LVGL version:8.1.0

It's pretty old. Could you try updating to v8.3.11 (latest from the release/v8.3 branch)?

kisvegabor avatar Mar 11 '24 15:03 kisvegabor

@kisvegabor You can use the ttf file and bin file to reproduce errors in release/v9.0 branch target.zip

916BGAI avatar Mar 28 '24 06:03 916BGAI

I've tried it out and it works but it required 7.5MB of RAM. I suggest taking a look at TinyTTF to render directly from a TTF file.

kisvegabor avatar Apr 02 '24 18:04 kisvegabor

Having a similar issue, I was using --symbols to add the common CJK characters I needed, but when loading the font on the device, I encountered a memory allocation error when loading the CMAP table, the glyph_id_ofs_list pointer was null on load_cmaps_tables function. It seems that when using the --symbols parameter, the tool does not strictly check whether the glyph data of the corresponding characters in the ttf file is valid.

R-YaTian avatar Apr 03 '24 04:04 R-YaTian

In lv_binfont_loader.c really not all mallocs are checked. If you have some time for it, can you send a Pull request to add the required checks?

kisvegabor avatar Apr 04 '24 22:04 kisvegabor

I've tried it out and it works but it required 7.5MB of RAM. I suggest taking a look at TinyTTF to render directly from a TTF file. Thank you for your reply! I used external PSRAM to load successfully.However, some Chinese characters may display garbled characters. The bin file converted by using the following command can be used normally, but a large number of Chinese characters need to be entered, and it is difficult to cover all of them. lv_font_conv --font SourceHanSansCN-Normal-2.otf -r 0x20-0x7F --symbols 一丁...... --size 20 --format bin --bpp 2 --no-compress -o mycour_siyuan20_2unicode.bin I use this command to convert the bin file.

DragonYY123 avatar Apr 22 '24 11:04 DragonYY123

I used external PSRAM to load successfully.However, some Chinese characters may display garbled characters.

Which characters are scrambled? Please mention a few examples so that we can try it out.

kisvegabor avatar Apr 28 '24 10:04 kisvegabor

I've tried it out and it works but it required 7.5MB of RAM. I suggest taking a look at TinyTTF to render directly from a TTF file.

So if I use a file (misans.bin) to load, I need to prepare 7.5MB of RAM in MCU? So do you recommend using tinyttf for real-time rendering? This only requires 4KB of RAM to complete?

And my MCU RAM is <200KB, So Which way can I use to load the font?

@kisvegabor

Linjieqiang avatar May 28 '24 07:05 Linjieqiang

I used external PSRAM to load successfully.However, some Chinese characters may display garbled characters.

Which characters are scrambled? Please mention a few examples so that we can try it out.

For example:硬件测试

DragonYY123 avatar May 28 '24 08:05 DragonYY123

I suggest trying it out, but tiny ttf can be solution for sure.

kisvegabor avatar Jun 04 '24 12:06 kisvegabor