FreeType based font rendrer for opefl-next (and starling-openfl)

To make font rendering as fast as possible on native targets, I wrote FreeType based font renderer for openfl-next (mostly) by myself.
This only works on modified openfl-next and starling-openfl for now.

To minimize waste of memory for texture, I used MaxRects rectangular pakcer provided by relaxguy: http://www.openfl.org/archive/community/programming-haxe/gm2d-rectangle-packing-class/
This font renderer caches font glyphs into OpenGL texture as needed, while original implementation of lime’s font renderer tries to render all glyphs at once.
Each font cache texture may contain rendered glyphs from multiple fonts/sizes. If current texture does not have enough space to render next font glyphs, the renderer symply creates next one. Even after that, it’s still possible to draw glyphs from the same texture at once, thanks to Starling’s QuadBatch.

Since openfl-stage3d does not support alpha-only texture and updating part of texture, I had to add these functions, too. But should we avoid adding functions that originaly didn’t exist in flash?

You can try it out this renderer from these links. It has still some limitations though.

  • If specified rectangle does not have enough space to render all text, rendering may get corrupted
  • You cannot delete texture cache for now
  • Kerning is not supported for now (it shouldn’t be too difficult though)

GitHub Repos:



io.js version of starling demo:

ScreenShot:

Font cache:

3 Likes

Awesome :slight_smile: It would be great to have this feature on html5 as well but I guess it wouldn’t be very fast. Anyway amazing work :smile: