[cairo] font thrashing

John Ellson ellson at research.att.com
Fri Apr 30 13:15:09 PDT 2004

There needs to be some caching of font lookups, probably here in 

    _cairo_gstate_select_font (cairo_gstate_t       *gstate,
                               const char           *family,
                               cairo_font_slant_t   slant,
                               cairo_font_weight_t  weight)
        if (gstate->font != NULL)
            cairo_font_destroy (gstate->font);

        gstate->font = _cairo_font_create (family, slant, weight);

        return CAIRO_STATUS_SUCCESS;

If the same font request is repeated (from the SVG for example) then
the previous font resolution (and its glyph caches) should be reused.

Probably there should be a most-recently-used cache of 10 or so fonts.

We noticed severe performance problems today when rendering an svg file 
respecified the same font multiple times.   David Reveman's glyph cache 
didn't help because the cache was destroyed each time the font was 

I wrote the generic font and glyph caching code in Tom Boutell's gd, so
I could take a shot at coding this, unless anyone else wants to claim it?


More information about the cairo mailing list