text/v2: add variations to glyph cache keys

This commit is contained in:
Hajime Hoshi 2023-11-16 13:15:51 +09:00
parent c7843a4e2b
commit 68d5fa46e2
2 changed files with 6 additions and 3 deletions

View File

@ -50,6 +50,8 @@ type glyphImageCacheKey struct {
xoffset fixed.Int26_6
yoffset fixed.Int26_6
variations string
}
type glyphImageCacheEntry struct {

View File

@ -338,9 +338,10 @@ func (g *GoTextFace) glyphImage(glyph glyph, origin fixed.Point26_6) (*ebiten.Im
Y: (origin.Y + b.Min.Y) & ((1 << 6) - 1),
}
key := glyphImageCacheKey{
id: uint32(glyph.shapingGlyph.GlyphID),
xoffset: subpixelOffset.X,
yoffset: subpixelOffset.Y,
id: uint32(glyph.shapingGlyph.GlyphID),
xoffset: subpixelOffset.X,
yoffset: subpixelOffset.Y,
variations: g.ensureVariationsString(),
}
img := theGlyphImageCache.getOrCreate(g, key, func() *ebiten.Image {
return segmentsToImage(glyph.scaledSegments, subpixelOffset, b)