linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.25k stars 94 forks source link

Slow DirectWrite text rendering with many TextColor range attributes #390

Open ForLoveOfCats opened 3 years ago

ForLoveOfCats commented 3 years ago

Piet version: 0.3.2 (as pulled in by Druid, Windows tests built with https://github.com/linebender/druid/commit/b40a363d3c7d934fb2d5cc69710a82c65b43c120) Reproduction: https://gist.github.com/ForLoveOfCats/0919bbb3df3eb122f97fd07e79fd501a

In the above code the "normal" text renders between ~3 to ~6 ms on my Win10 system (Ryzen 5 3500U mobile APU, fully updated OS at time of writing) while the line with many TextColor range attributes takes between ~30 to ~50 ms to render. For comparison the Pango powered Linux text PR renders the "normal" text in 0 ms and the text with many range attributes in ~2 ms (different machine, Ryzen 3 3200G w/R7 360).

While the render time for the marked up text is exceedingly bad it also appears that the normal text rendering is also rather slow when compared to Pango at the very least (I don't have access to a Mac to test the CoreText backend)