egui
egui copied to clipboard
Rendering of Chinese characters is very slow
Describe the bug
To be able to display Chinese in the UI, I added a Chinese TTF file to the fonts.rs file using the font_data.insert() method. This file contains thousands of Chinese characters and some nerd characters. I then recompiled egui_demo_app in debug mode, ran it again, and found that it was very slow to open. After opening it, I tried to enter Chinese characters in an input box and the Chinese characters displayed normally, but they also appear to be slow and sluggish.
To Reproduce Steps to reproduce the behavior:
Expected behavior
Screenshots
Desktop (please complete the following information):
- OS: Windows 11
- Browser
- Version
Smartphone (please complete the following information):
- Device:
- OS:
- Browser
- Version
Additional context
Did you try release mode? How's the CPU or GPU usage looking when you are running the app?
Do you insert the TTF once or every frame? (I've seen people do the latter before)
Did you try release mode? How's the CPU or GPU usage looking when you are running the app?
After adding Chinese TTF, it took about 10 seconds to open egui_demo_app. Attached is CPU usage. If compiled in Release mode, the opening speed increases by about 5 seconds
sarasa-mono-sc-nerd-regular.zip
Please refer to the attachment. I have added codes in these two places. I have also attached the TTF file
I tried it locally and had no problems with performance. Make sure you compile with --release
!
Is this really an issue? If you take https://github.com/emilk/egui/blob/master/examples/custom_font/src/main.rs and modify it with your own font, does it lag? On native, web, or both? Are you using --release
? Is it the IME that is lagging? Can you use a profiler (e.g. puffin) to track down the problem?
mine works fine. maybe he didn't context.request_repaint?