I'm implementing a custom text layouting engine and I need a simple text output function that would function similar to WinAPI's TabbedTextOut. That is, it shouldn't wrap words or anything like that.
QPainter's drawText seems to be very slow for this purpose. It's not very fast in general, but some Unicode characters (smileys) can cause the rendering to take up to 500ms (on Ryzen 3900x)! It probably does a lot of unnecessary things compared to TabbedTextOut, and this obviously causes huge hiccups.
I don't want to resort to platform-dependent solutions. I reckon that there should be a way to speed this up considerably.
What I tried:
- Preparing text to be painted as an QImage in a worker thread (thead pool, really). Works well, but fast scrolling leads to cache misses and skipped frames nevertheless. And image cache takes a lot of memory!
- QML's ListView. Is not really that much faster, and I'd rather stick to a widget-only solution.
- Using QStaticText. Still doesn't solve the problem of a cache miss.
- Using QTextLayout. Same thing, a cache miss causes hiccups.
Please hint me the direction which is worth exploring further. Thanks!
P.S. I use Qt 5.15 on Windows 10.