From 024617e5ecd199dfb426abb6c75a2c1ff6b01a7b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 22 Mar 2025 10:28:18 -0400 Subject: [PATCH] Don't cache glyphs with fine subpixel grid Having up to 16x16 variants of each glyph in the cache is a bit too much, and GTK does not need any caching, since it is doing its own caching in a texture atlas. --- src/cairo-image-compositor.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c index 98f3a35b6..88bb90ce3 100644 --- a/src/cairo-image-compositor.c +++ b/src/cairo-image-compositor.c @@ -960,6 +960,20 @@ composite_glyphs (void *_dst, glyph_cache, pg - pglyphs, pglyphs); } + /* Don't keep 64x64 versions of each glyph in the cache */ + if (info->font->options.subpixel_positions == CAIRO_SUBPIXEL_POSITIONS_FINE) { + int res = _cairo_subpixel_resolution (info->font->options.subpixel_positions); + for (i = 0; i < info->num_glyphs; i++) { + unsigned long index = info->glyphs[i].index; + unsigned long xphase, yphase; + xphase = _cairo_subpixel_phase (info->glyphs[i].x, res); + yphase = _cairo_subpixel_phase (info->glyphs[i].y, res); + index = index | (xphase << XSHIFT) | (yphase << YSHIFT); + + pixman_glyph_cache_remove (glyph_cache, info->font, (void *)(uintptr_t)index); + } + } + out_thaw: pixman_glyph_cache_thaw (glyph_cache);