[cairo] Fontconfig performance issue in the toy API
Keith Packard
keithp at keithp.com
Fri Aug 26 04:38:37 PDT 2005
Playing with Roadster, I discovered a serious performance problem in the
FreeType support for the toy API.
When an application uses a toy font, cairo automatically constructs a
cairo_scaled_font_t using the backend toy font constructor. In the case
of the FreeType backend, this involves building a Fontconfig pattern and
matching it and then using the resulting pattern to find the appropriate
FT_Face object. Fontconfig has some performance 'issues' with this
particular operation to the point where pango caches the results of this
kind of operation.
Now a cairo_toy_font_face_t always has the same family, style and
weight, the only thing which can change is the font matrix and ctm.
The FreeType backend computes a pixel size and uses those four elements
to locate a suitable FT_Face object. The rest of the CTM and font_matrix
are unused for this operation.
I suggest that we either codify this particular behaviour of the toy API
(selecting faces purely on the basis of family/slant/weight/size) up in
the backend-independent toy API code, or that we hack the FT backend to
map each combination of cairo_toy_font_face_t and pixel size to the
appropriate cairo_ft_unscaled_font_t. With that in place, converting a
cairo_toy_font_face_t + ctm/font_matrix would avoid Fontconfig most of
the time.
This hits Roadster quite hard as it rotates text to align names with
roads. No amount of cairo_scaled_font_t caching could match the number
of different orientations, so it was constantly hitting fontconfig with
the same data over and over again, as the fonts were identical up to
rotation. I kludged around this by snapping the rotation to one of 60
possible values, so with a larger holdback cache size (upped to 256 from
24), I was able to hit it all of the time.
The other alternative is to push this caching operation down into
fontconfig where it could cache the Match result. That has a certain
appeal as it would help more applications. But, short circuiting things
up in cairo would be easier in most other ways.
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050826/8317c832/attachment.pgp
More information about the cairo
mailing list