I have tried several different ways of doing this, and found that the attached patch is the best solution. It supports anti-aliasing, kerning, and bwfonts.
It implements glyph-by-glyph streaming, which both avoids the flicker, and noticeably improves performance.
The only state I have added are the streaming window coordinates and the cursor position.
I use the gdisp generic streaming functions, to take full advantage of the accelerations available also for non-streaming displays.
gdispFillString() previously took 47ms to draw "Hello World" in a 32pt aa font.
This is now down to 35ms. So, about 25% faster.
Glyph-by-glyph streaming is incompatible with kerning, so the patch implements line-by-line glyph streaming when kerning is enabled.
"Hello World" with kerning previously took 55ms, and is now down to 42ms.
Wordwrap is the only feature which is not supported (yet).
gdispGFillStringBox() will fallback to the original implementation if GDISP_NEED_TEXT_WORDWRAP is enabled.
I have tested this on a ST7789 streaming display with SPI bus.
To see the difference in screen refresh flicker, just run this code:
while(1)
gdispFillString(0, 50, "Hello World", font, GFX_WHITE, GFX_BLACK );
FlickerlessFillstring.patch