Weird behaviour with in-memory fonts and OSX Layouts

Hi Jules,

I have looked at this again and updated my test project on github. My output looks like this:

JUCE v4.1.0
Time taken to create Native font Layout: 35.4491
Time taken to create Bundled font Layout: 4634.54
Time taken to draw Native font Layout: 1149.28
Time taken to draw Bundled font Layout: 1132.54

Also is there a bug in layout.draw? Should it clip to the rectangle as follows? I am happy to make a new thread for this if needed.


void TextLayout::draw (Graphics& g, const Rectangle<float>& area) const
{
    const Point<float> origin (justification.appliedToRectangle (Rectangle<float> (width, getHeight()), area).getPosition());
    LowLevelGraphicsContext& context = g.getInternalContext();
    context.saveState();
    context.clipToRectangle(area.toNearestInt());
    for (int i = 0; i < lines.size(); ++i)
    {
        const Line& line = getLine (i);
        const Point<float> lineOrigin (origin + line.lineOrigin);
        for (int j = 0; j < line.runs.size(); ++j)
        {
            const Run& run = *line.runs.getUnchecked (j);
            context.setFont (run.font);
            context.setFill (run.colour);
            for (int k = 0; k < run.glyphs.size(); ++k)
            {
                const Glyph& glyph = run.glyphs.getReference (k);
                context.drawGlyph (glyph.glyphCode, AffineTransform::translation (lineOrigin.x + glyph.anchor.x,
                                                                                  lineOrigin.y + glyph.anchor.y));
            }
        }
    }
    context.restoreState();
}