How to improve DirectWrite performance when rendering lots of text?

Luke Zhou picture Luke Zhou · Jun 17, 2019 · Viewed 9.2k times · Source

I'm working on an application that renders lots of text (~350 lines with ~100 characters per line, possibly each frame). I find that DirectWrite takes way too long to layout these text, and the frame rate drops to 8-10 FPS.

I've already chopped the text into small fragments. In my experiments I found that by chopping the text up I can significantly speed up the layout process, but not enough to make the speed satisfactory. In a previous implementation, I can achieve much better (20-30 FPS) performance using FreeType and OpenGL and only considering the kerning between characters. I feel that DirectWrite is slow because it's using too many font features: I don't want bidirectional text support; all the features that I really care about are relative positioning and ligatures, and I want to also support font fallback. Is there a way I can disable unnecessary features? If not, how should I implement these features myself?

Answer