fontfallback

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetID

func AssetID(ctx context.Context, font Font) (d2scene.AssetID, error)

AssetID computes the scene font identity without retaining caller data.

Types

type CacheStats

type CacheStats struct {
	Assets      int
	Hashes      uint64
	Copies      uint64
	CopiedBytes int64
}

CacheStats reports retained trusted-asset preparation work.

func CacheStatsFor

func CacheStatsFor(resolver any) (CacheStats, bool)

CacheStatsFor returns private cache accounting for validation and metrics.

type Font

type Font struct {
	Name      string
	MIMEType  string
	Data      []byte
	FaceIndex uint16
}

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.

type Request

type Request struct {
	Runes  []rune
	Family string
	Style  string
	Weight int
}

Request carries missing code points and the source text style.

type SceneCache

type SceneCache struct {
	// contains filtered or unexported fields
}

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.

func NewSceneCache

func NewSceneCache(resolve SceneResolveFunc) *SceneCache

NewSceneCache creates a private scene handoff backed by resolve.

func (*SceneCache) HasTrusted

func (c *SceneCache) HasTrusted() bool

HasTrusted reports whether PrepareTrusted has retained its trusted resource.

func (*SceneCache) PrepareTrusted

func (c *SceneCache) PrepareTrusted(ctx context.Context, source Font) (SceneFont, bool, error)

PrepareTrusted copies and hashes the resolver's trusted source exactly once for this cache. A canceled attempt publishes neither data nor accounting.

type SceneFont

type SceneFont struct {
	Font
	ID     d2scene.AssetID
	Face   *fontface.ParsedFace
	Shared bool
}

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.

func ResolveForScene

func ResolveForScene(ctx context.Context, resolver any, request Request) ([]SceneFont, bool, error)

ResolveForScene uses a resolver's private scene handoff when available.

type SceneResolveFunc

type SceneResolveFunc func(context.Context, Request) ([]SceneFont, error)

SceneResolveFunc resolves fonts for the internal scene-builder handoff.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL