2

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?

Luke Zhou
  • 125
  • 2
  • 10
  • I suspect a design failure here. DirectWrite is way faster than humans. There's no way that humans can read 8*350 lines per second. Even 50 is a stretch. – MSalters Jun 17 '19 at 11:13
  • @MSalters This is sort of a worst case scenario. I'm trying to implement a minimap like that of sublime text, where it's apparently unwise to pre-render all the text. I've implemented some caching, however for very large files it's not going to make much of a difference if the user scrolls quickly around the document. In this case, it's usually necessary to re-draw the whole visible part of the minimap, i.e., 300-400 lines, which can lead to very visible stutters. In contrast, the FreeType + OpenGL implementation is butter smooth. – Luke Zhou Jun 17 '19 at 15:03
  • How do you render exactly? Performance hit from layout process will apply only once, unless you constantly change layout properties, or recreate layout object. Comparing to bare freetype output is simply wrong. Regarding features, I don’t think you can disable default set, and you shouldn’t. – bunglehead Jun 17 '19 at 21:03
  • @bunglehead As described above, the text is constantly changing, so it's inevitable to constantly re-create layout objects. On the other hand, can you elaborate on how comparing this to freetype is wrong? – Luke Zhou Jun 18 '19 at 03:42
  • If it’s changing, you’ll provably have to implement layout part yourself and use directwrite for shaping and rendering, while using glyph bitmap cache and, depending on your use case, shaped “words” cache. Freetype does not provide layout or shaping functionality at all. – bunglehead Jun 18 '19 at 05:18

0 Answers0