package fontfallback
Import Path
github.com/pancsta/d2/d2renderers/internal/fontfallback (on go.dev)
Dependency Relation
imports 8 packages, and imported by 2 packages
Involved Source Files
Package fontfallback contains the renderer-internal handoff used to retain
trusted fallback assets across multiple scene builds without widening D2's
public font resolver interface.
Package-Level Type Names (total 6)
CacheStats reports retained trusted-asset preparation work.
Assets int
CopiedBytes int64
Copies uint64
Hashes uint64
func CacheStatsFor(resolver any) (CacheStats, bool)
Font is one resolved font face. Data is owned by the result and may be
retained by a scene builder. FaceIndex selects a face in a collection.
Data []byte
FaceIndex uint16
MIMEType string
Name string
func AssetID(ctx context.Context, font Font) (d2scene.AssetID, error)
func (*SceneCache).PrepareTrusted(ctx context.Context, source Font) (SceneFont, bool, error)
Request carries missing code points and the source text style.
Family string
Runes []rune
Style string
Weight int
func ResolveForScene(ctx context.Context, resolver any, request Request) ([]SceneFont, bool, error)
SceneCache is embedded privately by a resolver that supports the internal
scene handoff. Its unexported marker keeps the capability out of public
resolver interfaces while allowing this package to recover the cache.
HasTrusted reports whether PrepareTrusted has retained its trusted resource.
PrepareTrusted copies and hashes the resolver's trusted source exactly once
for this cache. A canceled attempt publishes neither data nor accounting.
func NewSceneCache(resolve SceneResolveFunc) *SceneCache
SceneFont is the internal scene-builder result. Shared is set only for data
copied into the resolver-owned immutable cache. Face is a build-local clone
whose mutable shaping caches are never shared between scene builds.
Face *fontface.ParsedFace
Font Font
Font.Data []byte
Font.FaceIndex uint16
Font.MIMEType string
Font.Name string
ID d2scene.AssetID
Shared bool
func ResolveForScene(ctx context.Context, resolver any, request Request) ([]SceneFont, bool, error)
func (*SceneCache).PrepareTrusted(ctx context.Context, source Font) (SceneFont, bool, error)
SceneResolveFunc resolves fonts for the internal scene-builder handoff.
func NewSceneCache(resolve SceneResolveFunc) *SceneCache
Package-Level Functions (total 4)
AssetID computes the scene font identity without retaining caller data.
CacheStatsFor returns private cache accounting for validation and metrics.
NewSceneCache creates a private scene handoff backed by resolve.
ResolveForScene uses a resolver's private scene handoff when available.
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |