text/v2: reduce members in structs

This commit is contained in:
Hajime Hoshi 2023-11-15 14:22:21 +09:00
parent 586a4b6d6e
commit a612b3c861
4 changed files with 5 additions and 17 deletions

View File

@ -40,15 +40,8 @@ func init() {
} }
type faceCacheKey struct { type faceCacheKey struct {
stdFaceID uint64 id uint64
goTextFaceSourceID uint64
goTextFaceDirection Direction
goTextFaceSizeInPixels float64 goTextFaceSizeInPixels float64
goTextFaceLanguage string
goTextFaceScript string
goTextFaceVariations string
goTextFaceFeatures string
} }
type glyphImageCacheKey struct { type glyphImageCacheKey struct {

View File

@ -236,13 +236,8 @@ func (g *GoTextFace) ensureFeaturesString() string {
// faceCacheKey implements Face. // faceCacheKey implements Face.
func (g *GoTextFace) faceCacheKey() faceCacheKey { func (g *GoTextFace) faceCacheKey() faceCacheKey {
return faceCacheKey{ return faceCacheKey{
goTextFaceSourceID: g.Source.id, id: g.Source.id,
goTextFaceDirection: g.Direction,
goTextFaceSizeInPixels: g.SizeInPixels, goTextFaceSizeInPixels: g.SizeInPixels,
goTextFaceLanguage: g.Language.String(),
goTextFaceScript: g.Script.String(),
goTextFaceVariations: g.ensureVariationsString(),
goTextFaceFeatures: g.ensureFeaturesString(),
} }
} }

View File

@ -124,7 +124,7 @@ func NewGoTextFaceSourcesFromCollection(source io.ReadSeeker) ([]*GoTextFaceSour
func finalizeGoTextFaceSource(source *GoTextFaceSource) { func finalizeGoTextFaceSource(source *GoTextFaceSource) {
runtime.SetFinalizer(source, nil) runtime.SetFinalizer(source, nil)
theGlyphImageCache.clear(func(key faceCacheKey) bool { theGlyphImageCache.clear(func(key faceCacheKey) bool {
return key.goTextFaceSourceID == source.id return key.id == source.id
}) })
} }

View File

@ -54,7 +54,7 @@ func NewStdFace(face font.Face) *StdFace {
func finalizeStdFace(face *StdFace) { func finalizeStdFace(face *StdFace) {
runtime.SetFinalizer(face, nil) runtime.SetFinalizer(face, nil)
theGlyphImageCache.clear(func(key faceCacheKey) bool { theGlyphImageCache.clear(func(key faceCacheKey) bool {
return key.stdFaceID == face.id return key.id == face.id
}) })
} }
@ -85,7 +85,7 @@ func (s *StdFace) UnsafeInternal() any {
// faceCacheKey implements Face. // faceCacheKey implements Face.
func (s *StdFace) faceCacheKey() faceCacheKey { func (s *StdFace) faceCacheKey() faceCacheKey {
return faceCacheKey{ return faceCacheKey{
stdFaceID: s.id, id: s.id,
} }
} }