GNOME Bugzilla – Bug 320665
Use a cache to map gunichar->glyph_index in each PangoCairoFcFont
Last modified: 2005-11-04 23:14:54 UTC
In Pango profiles, pango_cairo_fc_font_get_glyph() shows up pretty high in the profile, at around 16% of the time spent in Pango. An analysis of this is here: http://primates.ximian.com/~federico/news-2005-10.html#gtkfilechooser-profile-5 With the attached patch, this gets reduced to 4% of the Pango time for most languages. The patch implements a simple, fixed-size cache that maps gunichars to per-font glyph indices. I still need to see what happens for different cache sizes.
Created attachment 54299 [details] [review] fmq-gunichar-to-glyph-index.diff
Created attachment 54329 [details] [review] Updated fmq-gunichar-to-glyph-index.diff This is a cleaned-up patch. It now uses #defines instead of explicit numbers for the cache size and the cache mask. I'll commit this in a second.
OK, it's on CVS now in HEAD. 2005-11-04 Federico Mena Quintero <federico@ximian.com> Fixes #320665: * pango/pangocairo-fcfont.c: Use a simple, fixed-size cache to map gunichars to glyph indices within the font. The cache is described in detail here: http://primates.ximian.com/~federico/news-2005-10.html#gtkfilechooser-profile-5 (GlyphCacheEntry): new structure to hold a gunichar and a PangoGlyph. (struct _PangoCairoFcFont): Add a char_to_glyph_cache field. (pango_cairo_fc_font_get_glyph): Allocate the char_to_glyph_cache if needed. We do it on demand because while many fonts will be alive at any one time (in order to cover the whole Unicode space), only very few of them will be actually accessed for glyph lookups. (pango_cairo_fc_font_get_glyph): Look up the gunichar in the cache, and replace the cache entry if necessary. (pango_cairo_fc_font_finalize): Free the char_to_glyph_cache.