package fontface

Import Path
	github.com/pancsta/d2/d2renderers/internal/fontface (on go.dev)

Dependency Relation
	imports 19 packages, and imported by 5 packages

Involved Source Files bundled_faces.go colrv1.go Package fontface owns the renderer-internal OpenType parsing, shaping, and color-glyph pipeline shared by scene construction and native raster output. face.go noto_color_emoji_coverage.go noto_color_emoji_digest.go noto_color_emoji_native.go shaping.go unicode.go
Package-Level Type Names (total 31)
/* sort by: | */
BundledFaceSource is an authenticated, package-owned clone source. Its parser state is not exposed. COLR0GlyphLayers resolves immutable COLRv0 table data without allocating a mutable go-text Face clone. Returned layers are detached value records. CloneReadOnly returns independent shaping caches while sharing go-text's documented read-only Font. It is for renderer-owned faces whose parsed table fields are never reassigned by the caller. CloneReadOnlyInto is CloneReadOnly with caller-owned result storage. CompileBundledNotoColorEmojiCOLRv1Plan compiles an immutable renderer plan through the authenticated package-private color tables. GlyphDataKind reports only the diagnostic category of a glyph. Keeping the table-backed GlyphData value private prevents callers from retaining or modifying parser-owned slices while still preserving renderer errors. GlyphRenderBounds reads glyph paint bounds without constructing per-Face shaping caches. IsBundledNotoColorEmoji reports whether this source is D2's authenticated color-emoji font without exposing its parser face. Outline returns the immutable sfnt reader for this authenticated source. sfnt.Font has no mutable exported state; callers supply their own Buffer for every operation, so the reader may safely be shared by concurrent renders. SupportsRenderableRune checks exact bundled-font coverage without mutating a shaping face cache, so one registered source can serve concurrent resolvers. The fixed ordinary D2 fonts contain only authenticated outline glyphs, so a matching non-zero cmap entry is sufficient. The bundled color-emoji source additionally validates its supported COLR paint path. func RegisteredBundledFace(data []byte, faceIndex uint16) (*BundledFaceSource, bool, error) func RegisteredBundledFaceDigest(data []byte, faceIndex uint16, digest [32]byte) (*BundledFaceSource, bool, error)
BundledNotoColorEmojiSource preserves the specific name used by the bundled emoji resolver and its authenticated color-paint and coverage APIs.
Collection parses one font source with both libraries used by the raster text pipeline. A source is accepted only when outline lookup and HarfBuzz-compatible shaping agree on its face topology. Face returns one parser-authenticated face by zero-based index. NumFaces reports the number of matching outline and shaping faces. func ParseFaceCollectionWithLimit(data []byte, maxFaces int) (*Collection, error)
ColorGlyphLayer is one foreground or palette-colored outline in a COLRv0 glyph. Layers are returned in paint order. Color color.NRGBA Foreground bool GlyphID uint32 func (*BundledFaceSource).COLR0GlyphLayers(glyphID uint32) ([]ColorGlyphLayer, bool, error) func (*ParsedFace).COLR0GlyphLayers(glyphID uint32) ([]ColorGlyphLayer, bool, error)
Dx float64 Dy float64 Xx float64 Xy float64 Yx float64 Yy float64
XMax float64 XMin float64 YMax float64 YMin float64
Stops []COLRv1ColorStop
Color color.NRGBA Offset float64
Backdrop COLRv1Paint Mode COLRv1CompositeMode Source COLRv1Paint COLRv1Composite : COLRv1Paint
const COLRv1CompositeSoftLight const COLRv1CompositeSrcIn
GlyphID uint32 Paint COLRv1Paint COLRv1Glyph : COLRv1Paint
Paints []COLRv1Paint COLRv1Layers : COLRv1Paint
Limit string Maximum int Value int (*COLRv1LimitError) Error() string *COLRv1LimitError : error
ColorLine COLRv1ColorLine X0 float64 X1 float64 X2 float64 Y0 float64 Y1 float64 Y2 float64 COLRv1LinearGradient : COLRv1Paint
COLRv1Paint is the closed set of paint operations emitted by the trusted compiler. COLRv1Composite COLRv1Glyph COLRv1Layers COLRv1LinearGradient COLRv1RadialGradient COLRv1Solid COLRv1Transform
COLRv1Plan is a renderer-neutral, fully palette-resolved paint graph for one glyph. Coordinates remain in the font's design units. Renderers choose their own outline rasterizer, transform convention, and temporary-layer strategy. Clip *COLRv1ClipBox GlyphID uint32 Root COLRv1Paint Usage COLRv1PlanUsage func (*BundledFaceSource).CompileBundledNotoColorEmojiCOLRv1Plan(glyphID uint32) (*COLRv1Plan, bool, error) func (*ParsedFace).CompileBundledNotoColorEmojiCOLRv1Plan(glyphID uint32) (*COLRv1Plan, bool, error)
ColorLine COLRv1ColorLine Radius0 float64 Radius1 float64 X0 float64 X1 float64 Y0 float64 Y1 float64 COLRv1RadialGradient : COLRv1Paint
Color color.NRGBA COLRv1Solid : COLRv1Paint
Matrix COLRv1Affine Paint COLRv1Paint COLRv1Transform : COLRv1Paint
Mode uint8 (*COLRv1UnsupportedCompositeError) Error() string *COLRv1UnsupportedCompositeError : error
Extend uint8 (*COLRv1UnsupportedExtendError) Error() string *COLRv1UnsupportedExtendError : error
Type string (*COLRv1UnsupportedPaintError) Error() string *COLRv1UnsupportedPaintError : error
COLRv1UntrustedFontError says that a caller attempted to use the compiler for arbitrary external font data. ( COLRv1UntrustedFontError) Error() string COLRv1UntrustedFontError : error
FaceCountLimitError reports a collection rejected before the shaping parser constructs one Face per entry. Count int Limit int (*FaceCountLimitError) Error() string *FaceCountLimitError : error
ParsedFace is one matching outline/shaping face. The Shaping face owns mutable lookup caches and must not be shared across concurrent renders. Outline *sfnt.Font Shaping *gotextfont.Face COLR0GlyphLayers returns the default-palette layers for one supported COLRv0 glyph. A false second result means the glyph should use its ordinary outline; this preserves outline fallback for other color-font formats. Clone returns a face with fresh shaping caches while preserving provenance only when this value still contains the exact parser-selected components. It is safe to use the resulting face independently in another render. CloneInto is Clone with caller-owned result storage. CompileBundledNotoColorEmojiCOLRv1Plan compiles the static COLRv1 subset used by D2's bundled Noto Color Emoji asset. A false result means the glyph has no COLR paint. Parser-issued provenance is checked before inspecting the color table; arbitrary external COLRv1 fonts remain unsupported and callers cannot replace the safety ceilings. GlyphRenderBounds returns paint bounds in the same fixed-point coordinate system as sfnt.LoadGlyph. Authenticated COLRv1 glyphs use their static COLR clip box; all other faces use outlines or COLRv0 layers. IsBundledNotoColorEmoji reports whether this face retains parser-issued provenance for D2's exact bundled color-emoji resource. SupportsRenderableRune reports whether both parsers select the same non-zero glyph and the raster pipeline can paint its base outline, COLRv0/CPAL layers, or an authenticated bundled COLRv1 plan. Empty outline glyphs are valid: spaces and spacing format controls can intentionally paint no contour while still contributing advance. func ParseFace(data []byte, faceIndex uint16) (*ParsedFace, error) func (*BundledFaceSource).CloneReadOnly() (*ParsedFace, error) func (*Collection).Face(index int) (*ParsedFace, error) func (*ParsedFace).Clone() (*ParsedFace, error) func (*BundledFaceSource).CloneReadOnlyInto(clone *ParsedFace) error func (*ParsedFace).CloneInto(clone *ParsedFace) error
ShapedGlyph is renderer-neutral placement for one glyph. Ink stays in the source font's fixed-point, Y-down coordinate system and is relative to the glyph position. Empty glyphs intentionally carry ID zero and no ink. Advance float64 Empty bool Face int HasInk bool ID uint32 Ink fixed.Rectangle26_6 PositionX float64 PositionY float64 Source rune SourceIndex int
ShapedText is one visually ordered, left-to-right placed line. Work reports the charged units so a caller can update aggregate document/frame budgets. Advance float64 CoverageChecks int64 Glyphs []ShapedGlyph Runes int Runs int func (*ShapingWorkspace).ShapeTextTransient(ctx context.Context, text string, size fixed.Int26_6, faces []ShapeFace, limits ShapeLimits) (ShapedText, error)
ShapeFace couples a caller-owned identifier to one parsed OpenType face. ParsedFace.Shaping contains mutable lookup caches, so callers must not share one ShapeFace concurrently between shaping calls. Face *ParsedFace ID string func (*ShapingWorkspace).ShapeTextTransient(ctx context.Context, text string, size fixed.Int26_6, faces []ShapeFace, limits ShapeLimits) (ShapedText, error)
ShapeLimits bounds all work which shaping cannot interrupt internally. Every field must be positive. Callers enforcing document-wide budgets pass the remaining aggregate allowance for CoverageChecks, Runs, and Glyphs. CoverageChecks int64 Faces int Glyphs int Runes int Runs int func (*ShapingWorkspace).ShapeTextTransient(ctx context.Context, text string, size fixed.Int26_6, faces []ShapeFace, limits ShapeLimits) (ShapedText, error)
ShapingWorkspace owns mutable scratch state for a sequence of shaping calls. Reusing one workspace for an operation lets go-text retain its HarfBuzz font cache and segmentation buffers without sharing mutable state between concurrent document builds or renders. A ShapingWorkspace must not be used concurrently. Returned ShapedText values borrow their Glyphs until the workspace is reused. ParsedFace pointers and their exported Outline and Shaping fields must remain unchanged between calls; the workspace deliberately caches immutable font answers. ShapeTextTransient applies pure-Go HarfBuzz-compatible shaping with bidi, script, ligature, mark, and ordered font-fallback support. Font selection has grapheme-cluster affinity: one face must cover every visible rune in a UAX #29 extended grapheme cluster. This prevents a combining mark that happens to exist in the primary font from being detached from a fallback base. It reuses the workspace's output storage in addition to its internal scratch. The returned Glyphs remain valid only until the next call to ShapeTextTransient on this workspace. It is intended for document pipelines which immediately translate the neutral glyphs into owned scene or raster records.
Package-Level Functions (total 11)
BundledNotoColorEmojiCoversRune reports whether the pinned font's ordinary cmap maps value to a non-zero glyph. Variation selectors are handled by the shaper after fallback selects the base character's face.
IsDefaultIgnorableRune reports whether the pinned pure-Go HarfBuzz shaper treats value as default-ignorable. These code points normally affect shaping or protocol state without painting a glyph of their own. Keep this exact range list shared by scene construction and raster shaping. It intentionally follows HarfBuzz's spacing-glyph exceptions for Hangul fillers and its shorthand-format-control exception, rather than blindly copying Unicode's broader Default_Ignorable_Code_Point property. Using the still broader General_Category=Cf would also incorrectly hide visible prepended concatenation marks such as U+0600 and U+06DD.
ParseFace parses one face from a TrueType, OpenType, or collection resource.
ParseFaceCollectionWithLimit inspects the cheap sfnt collection directory first and rejects excessive face counts before go-text eagerly constructs its per-face parser state.
RegisterBundledFace records the authenticated size and digest of a D2 font. It does not retain data. Parsing and a private backing copy are created lazily from the first matching candidate, so a public font registry cannot expose or mutate parser-owned tables. Callers must not register dynamic fonts.
RegisteredBundledFace authenticates data against D2's fixed bundled-font registry. A non-match is not an error so arbitrary scene fonts continue down the ordinary bounded parser path.
RegisteredBundledFaceBackingDigest identifies the exact process-owned backing of a registered font without scanning it. The source is still authenticated and dual-parsed by RegisteredBundledFaceDigest before use. Byte-identical copies deliberately do not match this identity-only path.
RegisteredBundledFaceDigest is RegisteredBundledFace for callers that have already computed the source digest as part of their own bounded cache key.
RegisteredBundledNotoColorEmoji authenticates an exact candidate and returns a package-owned source for parser-issued clones. The registered Face and its mutable caches remain private; clones share only go-text's concurrent-safe, read-only Font tables. A same-sized unrelated font is not claimed, so callers can continue through their ordinary parser path.
RegisteredBundledNotoColorEmojiBackingDigest identifies the exact private decoded backing without scanning it. RegisteredBundledNotoColorEmoji still authenticates and parses the resource before a clone source is used.
RegisterOwnedBundledNotoColorEmoji authenticates and takes ownership of a freshly allocated decoded resource. The caller must not retain or mutate data after this call. This avoids a complete second decoded-font allocation and is restricted to D2's private loader, which has sole ownership of its decoder output.
Package-Level Constants (total 2)