Glyph rendering performance

Jules, is there a better way of rendering glyph runs rather than drawing them one by one. For now I am calling
context.drawGlyph() for each glyph:

    LowLevelGraphicsContext& context = pg->target().getInternalContext();

    context.setFont ( ... );
    context.setFill ( ... );
    float x = 0;
    for(uint i = 0; i < gr.glyph_count; ++i) {
      context.drawGlyph (tf.glyph_indices[gr.glyph_start + i] , AffineTransform::translation (at.x + x, at.y));
      x += tf.glyph_justified_advances[gr.glyph_start + i];

Ideally it should be something like context.drawGlyphs( glyphIndices, glyphAdvances, glyphOffsets ).
Something close to ID2D1RenderTarget::DrawGlyphRun() to be short. 

Or did I miss some method that already exists?


Well, it's probably better to use a GlyphArrangement, but essentially it won't be any faster than what you've got there. Certainly if you're using the software renderer, that's already as fast as it'll go. There'd be maybe some tiny improvements possible for the CoreGraphics renderer if I refactored it to draw the glyphs in batches, but I've never noticed this to be a performance bottleneck.

You can also use a TextLayout to let the OS functions take care of layout (good for non-latin scripts) and rendering, but that's usually slower than just drawing the glyphs directly.

Unfortunately TextLayout cannot be used to render HTML/CSS in general.  

Consider <img style="float:right"> with some text wrapped around it. You cannot define such text flow in terms of TextLayout (that's just a rectangular box of text). So I am forced to do glyph runs positioning on my side. With all these BIDI, glyph clustering, etc. details.