egui icon indicating copy to clipboard operation
egui copied to clipboard

Rendering of Chinese characters is very slow

Open lionelfung7 opened this issue 2 years ago • 7 comments

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

lionelfung7 avatar Dec 17 '21 06:12 lionelfung7

Did you try release mode? How's the CPU or GPU usage looking when you are running the app?

coderedart avatar Dec 17 '21 07:12 coderedart

Do you insert the TTF once or every frame? (I've seen people do the latter before)

emilk avatar Dec 17 '21 10:12 emilk

Did you try release mode? How's the CPU or GPU usage looking when you are running the app? egui

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

lionelfung7 avatar Dec 18 '21 14:12 lionelfung7

add_code 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

lionelfung7 avatar Dec 18 '21 14:12 lionelfung7

I tried it locally and had no problems with performance. Make sure you compile with --release!

emilk avatar Dec 29 '21 20:12 emilk

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?

emilk avatar Apr 16 '22 20:04 emilk

mine works fine. maybe he didn't context.request_repaint?

blueberrynotblue avatar Apr 17 '22 04:04 blueberrynotblue