diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2022-07-04 18:31:24 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2022-07-06 04:28:22 -0400 |
commit | 01d44d70e9bd770ac365c88e09c5e432d2e517ad (patch) | |
tree | d8f63098b8244751f27fd2ba59046571bf5ce329 | |
parent | 698e205b657f9192df07962e7823a2eae80e1c17 (diff) | |
download | xorg-lib-libXft-01d44d70e9bd770ac365c88e09c5e432d2e517ad.tar.gz |
when tracking glyph memory usage, unload the oldest glyph rather than randomly
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r-- | src/xftglyphs.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/xftglyphs.c b/src/xftglyphs.c index 8db0929..076acc5 100644 --- a/src/xftglyphs.c +++ b/src/xftglyphs.c @@ -1031,7 +1031,18 @@ _XftFontUncacheGlyph (Display *dpy, XftFont *pub) if (XftDebug() & XFT_DBG_CACHE) _XftFontValidateMemory (dpy, pub); - if (font->use_free_glyphs) + if (font->track_mem_usage) + { + /* + * Remove the oldest glyph from the font. + */ + if (font->newest != FT_UINT_MAX) { + XftGlyphUsage *xuse = (XftGlyphUsage *) font->glyphs[font->newest]; + if ((glyphindex = xuse->newer) != FT_UINT_MAX) + XftFontUnloadGlyphs (dpy, pub, &glyphindex, 1); + } + } + else if (font->use_free_glyphs) { /* * Pick a random glyph from the font and remove it from the cache |