Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DragonYY123 opened this issue Feb 29, 2024 · 11 comments

Comments

@DragonYY123
Copy link

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?

@kisvegabor
Copy link
Member

kisvegabor commented Mar 5, 2024

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

Which LVGL version do you use?

@DragonYY123
Copy link
Author

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

@kisvegabor
Copy link
Member

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)?

@916BGAI
Copy link

916BGAI commented Mar 28, 2024

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

@kisvegabor
Copy link
Member

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.

@R-YaTian
Copy link

R-YaTian commented Apr 3, 2024

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.

@kisvegabor
Copy link
Member

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?

@DragonYY123
Copy link
Author

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.

@kisvegabor
Copy link
Member

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.

@Linjieqiang
Copy link

Linjieqiang commented May 28, 2024

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

@DragonYY123
Copy link
Author

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:硬件测试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants