--- pangocairo-fcfont.c.federico 2005-10-25 23:25:12.000000000 -0400 +++ pangocairo-fcfont.c 2005-10-25 23:24:11.000000000 -0400 @@ -67,6 +67,7 @@ PangoGlyph glyph; } GlyphCacheEntry; +#define GLYPH_INFO_SIZE 1024 struct _PangoCairoFcFont { PangoFcFont font; @@ -77,8 +78,7 @@ cairo_matrix_t ctm; cairo_font_options_t *options; - GHashTable *glyph_info; - PangoCairoFcGlyphInfo *recent [256]; + PangoCairoFcGlyphInfo *glyph_info [GLYPH_INFO_SIZE]; GlyphCacheEntry *char_to_glyph_cache; }; @@ -93,6 +93,7 @@ PangoGlyph glyph; PangoRectangle logical_rect; PangoRectangle ink_rect; + PangoCairoFcGlyphInfo *next; }; GType pango_cairo_fc_font_get_type (void); @@ -178,6 +179,7 @@ pango_cairo_fc_font_finalize (GObject *object) { PangoCairoFcFont *cffont = PANGO_CAIRO_FC_FONT (object); + int i; if (cffont->font_face) cairo_font_face_destroy (cffont->font_face); @@ -186,7 +188,18 @@ if (cffont->options) cairo_font_options_destroy (cffont->options); - g_hash_table_destroy (cffont->glyph_info); + for (i = 0; i < GLYPH_INFO_SIZE; i++) + { + PangoCairoFcGlyphInfo *info; + info = cffont->glyph_info [i]; + while (info) + { + PangoCairoFcGlyphInfo *temp; + temp = info->next; + g_free (info); + info = temp; + } + } if (cffont->char_to_glyph_cache) { @@ -252,11 +265,10 @@ { PangoCairoFcFont *cffont = (PangoCairoFcFont *)font; PangoCairoFcGlyphInfo *info; + guint cur = glyph & (GLYPH_INFO_SIZE - 1); - info = cffont->recent [glyph & 0xff]; - if (info && info->glyph == glyph) return info; - - info = g_hash_table_lookup (cffont->glyph_info, GUINT_TO_POINTER (glyph)); + info = cffont->glyph_info [cur]; + while (info && info->glyph != glyph) info = info->next; if (!info) { info = g_new0 (PangoCairoFcGlyphInfo, 1); @@ -265,8 +277,9 @@ compute_glyph_extents (font, glyph, &info->ink_rect, &info->logical_rect); - - g_hash_table_insert (cffont->glyph_info, GUINT_TO_POINTER (glyph), info); + + info->next = cffont->glyph_info [cur]; + cffont->glyph_info [cur] = info; } return info; @@ -470,12 +483,7 @@ static void pango_cairo_fc_font_init (PangoCairoFcFont *cffont) { - cffont->glyph_info = g_hash_table_new_full (g_direct_hash, - NULL, - NULL, - (GDestroyNotify)g_free); - - memset (cffont->recent, 0, 256 * 4); + memset (cffont->glyph_info, 0, GLYPH_INFO_SIZE * sizeof (PangoCairoFcGlyphInfo *)); #ifdef PROFILE_GLYPH_CACHE num_cairo_fc_fonts++;