text/v2: increase the soft limit of the glyph cache if the face is small

Updates #2843
This commit is contained in:
Hajime Hoshi 2023-11-16 12:07:11 +09:00
parent 2e60c67ec9
commit 8352be9369

View File

@ -101,7 +101,7 @@ func (g *glyphImageCache) getOrCreate(face Face, key glyphImageCacheKey, create
// If the number of glyphs exceeds this soft limits, old glyphs are removed.
// Even after cleaning up the cache, the number of glyphs might still exceed the soft limit, but
// this is fine.
const cacheSoftLimit = 512
cacheSoftLimit := 128 * glyphVariationCount(face)
if len(g.cache[faceCacheKey]) > cacheSoftLimit {
for key, e := range g.cache[faceCacheKey] {
// 60 is an arbitrary number.