diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 7a47219..aa89d25 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -334,7 +334,7 @@ _cairo_scaled_font_keys_equal (const void *abstract_key_a, const void *abstract_ * separately is probably not what we want anyway. Would probably be * much better to have a single cache for glyphs with random * replacement across all glyphs of all fonts. */ -#define MAX_GLYPHS_CACHED_PER_FONT 256 +#define MAX_GLYPHS_CACHED_PER_FONT 4096 /* * Basic cairo_scaled_font_t object management @@ -350,6 +350,8 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font, { cairo_matrix_t inverse; cairo_status_t status; + static int inited = 0; + static int cache_size; status = cairo_font_options_status ((cairo_font_options_t *) options); if (status) @@ -369,9 +371,26 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font, if (status) return status; + if (!inited) { + char *str; + int have_size; + + inited = 1; + have_size = 0; + + str = getenv ("CAIRO_SCALED_GLYPH_CACHE_SIZE"); + if (str) { + if (sscanf (str, "%d", &cache_size) == 1) + have_size = 1; + } + + if (!have_size) + cache_size = 256; + } + scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal, _cairo_scaled_glyph_destroy, - MAX_GLYPHS_CACHED_PER_FONT); + cache_size); if (scaled_font->glyphs == NULL) return CAIRO_STATUS_NO_MEMORY;