[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.c:


    cairo_status_t
    _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 
that
respecified the same font multiple times.   David Reveman's glyph cache 
patch
didn't help because the cache was destroyed each time the font was 
respecified.


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?

John










More information about the cairo mailing list