Documentation
¶
Overview ¶
Package display defines the immutable output contract for UI hosts.
Index ¶
- Constants
- Variables
- type Align
- type Alt
- type AltBreakKind
- type AltCancelRole
- type AltColumn
- type AltColumnAlign
- type AltDescription
- type AltFlag
- type AltFontSize
- type AltFractionRole
- type AltFractionStyle
- type AltMathSize
- type AltNode
- type AltNodeKind
- type AltOverlayAlignment
- type AltPart
- type AltPartRole
- type AltPosition
- type AltRaiseDirection
- type AltRow
- type AltScriptRole
- type AltSizingKind
- type AltSpaceKind
- type AltSpaceWidth
- type AltTableRole
- type AltTag
- type AltVariant
- type Box
- func (b *Box) At(p geometry.Point) (Hit, bool)
- func (b *Box) Bounds() geometry.Rect
- func (b *Box) CaretAt(offset int) (CaretStop, bool)
- func (b *Box) Carets() []CaretStop
- func (b *Box) Clone() *Box
- func (b *Box) Covering(r source.Range) []geometry.Rect
- func (b *Box) MarshalCanonical() ([]byte, error)
- func (b *Box) NearestCaret(p geometry.Point) (CaretStop, bool)
- func (b *Box) Split(at Break) (left, right *Box, err error)
- func (b *Box) Validate() error
- type Break
- type BreakKind
- type CaretStop
- type ColorPolicy
- type ColorPolicyMode
- type ColorRolePalette
- type FaceUse
- type FontUsage
- type Hit
- type HitKind
- type HitRange
- type Item
- type ItemKind
- type ItemRange
- type LineBox
- type MissingFallback
- type Paint
- type PathTemplate
- type PixelGrid
- type RGBA
- type Role
- type SnapAxis
- type Style
- type TagBox
Constants ¶
const AltDescriptionVersion = 2
AltDescriptionVersion is the current structured accessibility schema.
const DefaultMinContrast float32 = 4.5
DefaultMinContrast is the WCAG AA contrast threshold used when ColorPolicy.MinContrast is zero.
const FormulaTagLine = -1
FormulaTagLine identifies a tag that belongs to the complete formula rather than one rendered display line or source row.
const NoPath = -1
NoPath marks an item that does not reference Box.Paths.
Variables ¶
var ErrCannotSplit = errors.New("display: cannot split box")
ErrCannotSplit reports a box that cannot be divided into independent inline geometry.
var ErrInvalidAlt = errors.New("display: invalid alternative text")
ErrInvalidAlt reports malformed alternative text.
var ErrInvalidAltDescription = errors.New("display: invalid alternative description")
ErrInvalidAltDescription reports a malformed structured accessibility description.
var ErrInvalidBox = errors.New("display: invalid box")
Functions ¶
This section is empty.
Types ¶
type Align ¶
type Align uint8
Align is horizontal placement within a constrained display line frame. Inline layout and display layout with MaxWidth zero ignore it.
type Alt ¶
type Alt struct {
Speech string
Text string
// Description is a versioned, source-independent semantic tree for hosts
// that localize accessibility output instead of using the English Speech
// string. Nil is permitted for compatibility with host-constructed Alt
// values and older callers.
Description *AltDescription
}
Alt is semantic alternative text derived from the neutral expression tree.
func (Alt) Equal ¶ added in v0.4.0
Equal reports whether two Alt values contain the same text and structured description.
func (Alt) MarshalCanonical ¶
MarshalCanonical returns deterministic JSON for alternative-text tests. It is not a stable cross-language protocol.
type AltBreakKind ¶ added in v0.4.0
type AltBreakKind string
AltBreakKind identifies why a line break is legal.
const ( AltBreakRelation AltBreakKind = "relation" AltBreakBinary AltBreakKind = "binary" AltBreakExplicit AltBreakKind = "explicit" )
type AltCancelRole ¶ added in v0.4.0
type AltCancelRole string
AltCancelRole distinguishes cancellation, negation, and Feynman slash.
const ( AltCancelStrike AltCancelRole = "strike" AltCancelNegation AltCancelRole = "negation" AltCancelSlashed AltCancelRole = "slashed" )
type AltColumn ¶ added in v0.4.0
type AltColumn struct {
Align AltColumnAlign `json:"align"`
}
AltColumn records one table column's alignment.
type AltColumnAlign ¶ added in v0.4.0
type AltColumnAlign string
AltColumnAlign identifies a table column alignment.
const ( AltColumnCenter AltColumnAlign = "center" AltColumnLeft AltColumnAlign = "left" AltColumnRight AltColumnAlign = "right" )
type AltDescription ¶ added in v0.4.0
type AltDescription struct {
Version int `json:"version"`
Root AltNode `json:"root"`
Tags []AltTag `json:"tags,omitempty"`
}
AltDescription is a stable, source-independent semantic description derived from canonical IR. It contains no source ranges, node identities, paint, fonts, or geometry. Hosts map its tokens and literal text payloads to their own locale and accessibility vocabulary.
func (*AltDescription) Clone ¶ added in v0.4.0
func (d *AltDescription) Clone() *AltDescription
Clone returns an independent copy of d.
func (*AltDescription) Equal ¶ added in v0.4.0
func (d *AltDescription) Equal(other *AltDescription) bool
Equal reports whether two structured descriptions are structurally equal.
func (*AltDescription) MarshalCanonical ¶ added in v0.4.0
func (d *AltDescription) MarshalCanonical() ([]byte, error)
MarshalCanonical returns deterministic JSON for a validated structured accessibility description. It is an inspection and golden-test serializer, not an unversioned wire protocol.
func (*AltDescription) Validate ¶ added in v0.4.0
func (d *AltDescription) Validate() error
Validate checks the default-limit structural contract.
func (*AltDescription) ValidateWithLimits ¶ added in v0.4.0
func (d *AltDescription) ValidateWithLimits(limits source.Limits) error
ValidateWithLimits checks the version, semantic shape, text encoding, node and nesting budgets, and aggregate literal-text budget. A zero-value limits uses source.DefaultLimits.
type AltFlag ¶ added in v0.4.0
type AltFlag string
AltFlag carries a stable semantic boolean. Absence means false; a defined positive or negative token records the authored state where needed.
const ( AltFlagBalanced AltFlag = "balanced" AltFlagBar AltFlag = "bar" AltFlagWeak AltFlag = "weak" AltFlagStretchy AltFlag = "stretchy" AltFlagNaturalFit AltFlag = "natural-fit" AltFlagDotless AltFlag = "dotless" AltFlagExactFrameWidth AltFlag = "exact-frame-width" AltFlagCross AltFlag = "cross" AltFlagInverted AltFlag = "inverted" AltFlagCentered AltFlag = "centered" AltFlagCramped AltFlag = "cramped" AltFlagUncramped AltFlag = "uncramped" AltFlagFill AltFlag = "fill" AltFlagBorder AltFlag = "border" AltFlagPhantomWidth AltFlag = "phantom-width" AltFlagPhantomHeight AltFlag = "phantom-height" AltFlagPhantomDepth AltFlag = "phantom-depth" )
type AltFontSize ¶ added in v0.4.0
type AltFontSize struct {
Percent float64 `json:"percent"`
}
AltFontSize is an explicit uniform font-size percentage relative to the root host font size. A value of 100 means 100 percent.
type AltFractionRole ¶ added in v0.4.0
type AltFractionRole string
AltFractionRole identifies the semantic operation represented by a fraction-shaped node.
const ( AltFractionOrdinary AltFractionRole = "ordinary" AltFractionBinomial AltFractionRole = "binomial" AltFractionStacked AltFractionRole = "stacked" )
type AltFractionStyle ¶ added in v0.4.0
type AltFractionStyle string
AltFractionStyle identifies the geometric fraction construction.
const ( AltFractionVertical AltFractionStyle = "vertical" AltFractionNoBar AltFractionStyle = "no-bar" AltFractionSkewed AltFractionStyle = "skewed" AltFractionHorizontal AltFractionStyle = "horizontal" )
type AltMathSize ¶ added in v0.4.0
type AltMathSize string
AltMathSize identifies an explicit math-size wrapper.
const ( AltSizeInherit AltMathSize = "inherit" AltSizeDisplay AltMathSize = "display" AltSizeText AltMathSize = "text" AltSizeScript AltMathSize = "script" AltSizeScriptScript AltMathSize = "script-script" )
type AltNode ¶ added in v0.4.0
type AltNode struct {
Kind AltNodeKind `json:"kind"`
// Text is literal source-independent content for glyph, text, operator,
// delimiter, error, and placeholder nodes. It is not localized prose.
Text string `json:"text,omitempty"`
// Code is a stable error or diagnostic token for error nodes.
Code string `json:"code,omitempty"`
Variant AltVariant `json:"variant,omitempty"`
FractionRole AltFractionRole `json:"fractionRole,omitempty"`
FractionStyle AltFractionStyle `json:"fractionStyle,omitempty"`
ScriptRole AltScriptRole `json:"scriptRole,omitempty"`
TableRole AltTableRole `json:"tableRole,omitempty"`
CancelRole AltCancelRole `json:"cancelRole,omitempty"`
Position AltPosition `json:"position,omitempty"`
Space AltSpaceKind `json:"space,omitempty"`
SpaceWidth AltSpaceWidth `json:"spaceWidth,omitempty"`
Break AltBreakKind `json:"break,omitempty"`
Sizing AltSizingKind `json:"sizing,omitempty"`
Size AltMathSize `json:"size,omitempty"`
OverlayAlignment AltOverlayAlignment `json:"overlayAlignment,omitempty"`
RaiseDirection AltRaiseDirection `json:"raise,omitempty"`
FontSize *AltFontSize `json:"fontSize,omitempty"`
Flags []AltFlag `json:"flags,omitempty"`
Parts []AltPart `json:"parts,omitempty"`
Rows []AltRow `json:"rows,omitempty"`
Columns []AltColumn `json:"columns,omitempty"`
}
AltNode is one semantic node. Kind determines which optional fields and child collections are meaningful.
type AltNodeKind ¶ added in v0.4.0
type AltNodeKind string
AltNodeKind identifies one semantic node in a structured accessibility description. Values are stable protocol tokens, not user-facing prose.
const ( AltKindRow AltNodeKind = "row" AltKindGlyph AltNodeKind = "glyph" AltKindText AltNodeKind = "text" AltKindOperator AltNodeKind = "operator" AltKindSpace AltNodeKind = "space" AltKindFraction AltNodeKind = "fraction" AltKindRadical AltNodeKind = "radical" AltKindScripts AltNodeKind = "scripts" AltKindFenced AltNodeKind = "fenced" AltKindSizedDelimiter AltNodeKind = "sized-delimiter" AltKindAccent AltNodeKind = "accent" AltKindLine AltNodeKind = "line" AltKindCancel AltNodeKind = "cancel" AltKindTable AltNodeKind = "table" AltKindMultiline AltNodeKind = "multiline" AltKindStyle AltNodeKind = "style" AltKindOverlay AltNodeKind = "overlay" AltKindRaise AltNodeKind = "raise" AltKindColor AltNodeKind = "color" AltKindBox AltNodeKind = "box" AltKindPhantom AltNodeKind = "phantom" AltKindError AltNodeKind = "error" AltKindPlaceholder AltNodeKind = "placeholder" AltKindBreak AltNodeKind = "break" AltKindAlignMarker AltNodeKind = "align-marker" )
type AltOverlayAlignment ¶ added in v0.4.0
type AltOverlayAlignment string
AltOverlayAlignment identifies the horizontal placement of zero-width overlay content.
const ( AltOverlayStart AltOverlayAlignment = "start" AltOverlayCenter AltOverlayAlignment = "center" AltOverlayEnd AltOverlayAlignment = "end" )
type AltPart ¶ added in v0.4.0
type AltPart struct {
Role AltPartRole `json:"role"`
Node AltNode `json:"node"`
}
AltPart attaches a child node to a named semantic position.
type AltPartRole ¶ added in v0.4.0
type AltPartRole string
AltPartRole names the semantic position of a child node.
const ( AltPartItem AltPartRole = "item" AltPartBody AltPartRole = "body" AltPartNumerator AltPartRole = "numerator" AltPartDenominator AltPartRole = "denominator" AltPartRadicand AltPartRole = "radicand" AltPartIndex AltPartRole = "index" AltPartBase AltPartRole = "base" AltPartTop AltPartRole = "top" AltPartBottom AltPartRole = "bottom" AltPartTopLeft AltPartRole = "top-left" AltPartBottomLeft AltPartRole = "bottom-left" AltPartTopRight AltPartRole = "top-right" AltPartBottomRight AltPartRole = "bottom-right" AltPartOpen AltPartRole = "open" AltPartClose AltPartRole = "close" AltPartContent AltPartRole = "content" AltPartAccent AltPartRole = "accent" )
type AltPosition ¶ added in v0.4.0
type AltPosition string
AltPosition identifies an above/below decoration.
const ( AltPositionAbove AltPosition = "above" AltPositionBelow AltPosition = "below" )
type AltRaiseDirection ¶ added in v0.4.0
type AltRaiseDirection string
AltRaiseDirection identifies the semantic vertical direction of a raise.
const ( AltRaiseUp AltRaiseDirection = "up" AltRaiseDown AltRaiseDirection = "down" AltRaiseZero AltRaiseDirection = "zero" )
type AltRow ¶ added in v0.4.0
type AltRow struct {
Items []AltNode `json:"items,omitempty"`
}
AltRow is one table or multiline row. Items are cells for tables and row-level components for multiline expressions.
type AltScriptRole ¶ added in v0.4.0
type AltScriptRole string
AltScriptRole identifies the semantic purpose of scripts and limits.
const ( AltScriptOrdinary AltScriptRole = "ordinary" AltScriptLimits AltScriptRole = "limits" AltScriptOverlay AltScriptRole = "overlay" AltScriptBraceLabel AltScriptRole = "brace-label" )
type AltSizingKind ¶ added in v0.4.0
type AltSizingKind string
AltSizingKind identifies a delimiter target policy.
const ( AltSizingContent AltSizingKind = "content" AltSizingRelative AltSizingKind = "relative" AltSizingAbsolute AltSizingKind = "absolute" )
type AltSpaceKind ¶ added in v0.4.0
type AltSpaceKind string
AltSpaceKind identifies the semantic kind of an explicit or interword space.
const ( AltSpaceExplicit AltSpaceKind = "explicit" AltSpaceInterword AltSpaceKind = "interword" AltSpaceIgnored AltSpaceKind = "ignored" )
type AltSpaceWidth ¶ added in v0.4.0
type AltSpaceWidth string
AltSpaceWidth identifies the authored width of an explicit space when it matches a stable semantic width.
const ( AltSpaceWidthZero AltSpaceWidth = "zero" AltSpaceWidthThin AltSpaceWidth = "thin" AltSpaceWidthMedium AltSpaceWidth = "medium" AltSpaceWidthThick AltSpaceWidth = "thick" AltSpaceWidthEn AltSpaceWidth = "en" AltSpaceWidthQuad AltSpaceWidth = "quad" AltSpaceWidthDoubleQuad AltSpaceWidth = "double-quad" AltSpaceWidthNegativeThin AltSpaceWidth = "negative-thin" AltSpaceWidthNegativeMedium AltSpaceWidth = "negative-medium" AltSpaceWidthNegativeThick AltSpaceWidth = "negative-thick" AltSpaceWidthCustom AltSpaceWidth = "custom" )
type AltTableRole ¶ added in v0.4.0
type AltTableRole string
AltTableRole identifies the semantic kind of a table.
const ( AltTableMatrix AltTableRole = "matrix" AltTableArray AltTableRole = "array" AltTableCases AltTableRole = "cases" AltTableVector AltTableRole = "vector" )
type AltTag ¶ added in v0.4.0
type AltTag struct {
Body *AltNode `json:"body,omitempty"`
Manual bool `json:"manual,omitempty"`
Starred bool `json:"starred,omitempty"`
Suppressed bool `json:"suppressed,omitempty"`
Line int `json:"line"`
}
AltTag describes one formula- or row-scoped tag event. A suppressed event has no body. Line is FormulaTagLine for the complete formula or the zero-based source row for a multiline row tag.
type AltVariant ¶ added in v0.4.0
type AltVariant string
AltVariant identifies a semantic math alphabet.
const ( AltVariantNormal AltVariant = "normal" AltVariantItalic AltVariant = "italic" AltVariantBold AltVariant = "bold" AltVariantBoldItalic AltVariant = "bold-italic" AltVariantDoubleStruck AltVariant = "double-struck" AltVariantScript AltVariant = "script" AltVariantBoldScript AltVariant = "bold-script" AltVariantFraktur AltVariant = "fraktur" AltVariantBoldFraktur AltVariant = "bold-fraktur" AltVariantSans AltVariant = "sans-serif" AltVariantBoldSans AltVariant = "bold-sans-serif" AltVariantMonospace AltVariant = "monospace" )
type Box ¶
type Box struct {
Width float32
Ascent float32
Descent float32
// Italic is the signed OpenType MATH italic correction at the end of the
// box. It may be negative; hosts must not treat it as a nonnegative size.
Italic float32
AxisHeight float32
// Overflow is a nonnegative lower bound for rendered ink outside the box and,
// for constrained display boxes, the largest logical line-width excess.
Overflow float32
Items []Item
// Paths contains path templates shared by one or more items. A glyph-path
// item resolves a point as At + templatePoint*Em.
Paths []PathTemplate
Hits []Hit
Breaks []Break
// CaretStops is source ordered in final box coordinates. Use Carets for an
// immutable snapshot and CaretAt to resolve a source offset.
CaretStops []CaretStop
Alt Alt
// Diagnostics reports recoverable layout problems, such as unavailable
// glyphs rendered as visible placeholders. Parse diagnostics remain on the
// high-level RenderResult.
Diagnostics []source.Diagnostic
// FontUsage reports resolved face selection and missing fallback needs for
// shaped text clusters. It is separate from Diagnostics and remains empty
// when a formula contains no shaped text.
FontUsage FontUsage
// Tag is a single-line display equation tag in parent coordinates. Its
// Items and Hits ranges identify its records in this Box. It is excluded
// from formula-root breaks.
Tag *TagBox
// Tags contains source-row-scoped equation tags in ascending row order.
// It is mutually exclusive with Tag. Each range indexes this Box's
// parent-frame Items and Hits and remains row-scoped even when a constrained
// display wraps the formula block as one line.
Tags []TagBox
// Lines is populated only for display layout with a positive Style.MaxWidth.
// A constrained display result always has at least one line, including when
// the complete formula fits. Its Width is the requested MaxWidth, even when
// every line is narrower or an unbreakable line overflows it. Lines are
// source ordered and index the single parent-frame Items and Hits storage.
Lines []LineBox
}
Box is a flattened formula relative to the start of its baseline.
func (*Box) Bounds ¶
Bounds returns the baseline-relative rectangle that contains the box's nominal geometry and its certified overflow. The result is suitable for fitting the complete display list into a host viewport.
func (*Box) CaretAt ¶ added in v0.4.0
CaretAt returns the preferred caret for offset.
An exact source offset wins. When no stop exists at offset, the nearest previous or following proven source boundary is returned. Ties prefer the earlier source offset, then deterministic top-to-bottom and left-to-right geometry. Negative offsets and an empty caret map return false.
func (*Box) Carets ¶ added in v0.4.0
Carets returns an independent copy of the source-ordered caret stops.
func (*Box) Covering ¶
Covering returns the innermost placed areas intersecting source range r. Ancestor structure hits are ignored when a deeper hit also intersects r. Areas on the same line that overlap or touch are merged deterministically.
func (*Box) MarshalCanonical ¶
MarshalCanonical returns deterministic JSON for golden tests and diagnostics. It is not a stable cross-language protocol.
func (*Box) NearestCaret ¶ added in v0.4.0
NearestCaret returns the caret stop geometrically nearest to p.
Vertical distance is minimized first so a point never snaps to a caret on a different line merely because its x coordinate is closer. Within one line, horizontal distance resolves the left/right affinity. Ties use the same stable source and geometry ordering as CaretAt.
func (*Box) Split ¶ added in v0.4.0
Split divides an inline box at one of its legal Break opportunities.
The returned boxes have independent item, path, hit, caret, and break storage. Left keeps parent coordinates and uses at.X as its width. Right is translated so its origin is zero. Hit rectangles are clipped to each side; caret stops on the boundary are retained by both sides. Alt and FontUsage are cleared because neither whole-formula metadata can be divided soundly.
Constrained display boxes, tagged boxes, unknown break values, and endpoint breaks cannot be split. Passing a Break from Box.Breaks is required.
type Break ¶
Break is an inline wrapping opportunity relative to the box baseline origin. Relation, binary, and explicit kinds describe why a cut is legal; they do not carry a relative cost. Display wrapping is width-greedy and chooses the earliest source cut when multiple opportunities have equal width.
type CaretStop ¶ added in v0.4.0
CaretStop is one source-ordered caret position in box coordinates.
Source is an absolute UTF-8 byte offset. X is the caret line's horizontal position and Top/Bottom are its vertical extent. A formula may have multiple stops for one offset, for example where a nested construct contributes more than one baseline. NodeID is the optional semantic identity associated with the stop.
type ColorPolicy ¶ added in v0.4.0
type ColorPolicy struct {
Mode ColorPolicyMode
Palette ColorRolePalette
Background RGBA
MinContrast float32
}
ColorPolicy controls output-time treatment of authored explicit colors.
Semantic role paints are never changed. Preserve is the zero value and keeps explicit colors byte-for-byte unchanged. MapToRoles discards authored color and alpha and emits a serializable semantic role. AdjustContrast preserves alpha and changes only the RGB needed to reach MinContrast against an opaque Background. If the preserved alpha makes the threshold impossible, it moves to the highest-contrast RGB endpoint. A zero MinContrast uses the WCAG AA normal-text threshold 4.5.
func (ColorPolicy) Resolve ¶ added in v0.4.0
func (p ColorPolicy) Resolve(paint Paint) Paint
Resolve returns paint with this policy applied.
Callers must Validate the policy first. Preserve and unknown modes are intentionally no-ops so an unvalidated zero-value policy cannot corrupt output.
func (ColorPolicy) Validate ¶ added in v0.4.0
func (p ColorPolicy) Validate() error
Validate checks a color policy before layout.
type ColorPolicyMode ¶ added in v0.4.0
type ColorPolicyMode uint8
ColorPolicyMode selects how authored explicit colors participate in output.
const ( // ColorPreserve leaves every authored explicit color unchanged. It is the // zero-value policy and the default behavior. ColorPreserve ColorPolicyMode = iota // ColorMapToRoles replaces explicit colors with the perceptually nearest // semantic role in ColorPolicy.Palette. ColorMapToRoles // ColorAdjustContrast minimally adjusts explicit colors until they meet // ColorPolicy.MinContrast against ColorPolicy.Background. ColorAdjustContrast )
type ColorRolePalette ¶ added in v0.4.0
ColorRolePalette supplies concrete colors for semantic paint roles when explicit colors are mapped back to roles.
type FaceUse ¶ added in v0.4.0
FaceUse identifies the resolved face used for one or more shaped text clusters. Source ranges are in logical source order after layout finalization. Fallback is true when the face was not the first face requested for that text role.
type FontUsage ¶ added in v0.4.0
type FontUsage struct {
Faces []FaceUse
Missing []MissingFallback
}
FontUsage reports shaped text face selection for hosts that need to load fallback fonts ahead of future layouts or explain the current selection.
Faces contains resolved face spans in source order. Missing contains merged, deduplicated fallback requirements. Math glyphs selected directly through OpenType MATH tables are not text clusters and are intentionally absent.
func (FontUsage) NeedsFallback ¶ added in v0.4.0
NeedsFallback reports whether any shaped text cluster lacked coverage.
func (FontUsage) UsesFallback ¶ added in v0.4.0
UsesFallback reports whether any shaped text cluster used a non-primary face.
type Hit ¶
type Hit struct {
Source source.Range
Area geometry.Rect
Depth int
Kind HitKind
// NodeID is the optional stable identity of the source node represented by
// this hit. Zero means unassigned.
NodeID identity.NodeID
}
Hit maps a source range to one placed area.
type HitRange ¶
HitRange identifies a contiguous range in Box.Hits.
Start is the zero-based index of the first hit and Count is the number of hits. An empty range is valid. Ranges returned by layout always refer to parent-frame storage.
type Item ¶
type Item struct {
Kind ItemKind
Paint Paint
Bound geometry.Rect
// NodeID is the optional stable identity of the semantic source node that
// produced this item. Zero means the item has no assigned identity.
NodeID identity.NodeID
// PathIndex selects Box.Paths. It is NoPath for items without path data.
PathIndex int
Rect geometry.Rect
// Snap identifies a thin rule's minor axis. It is present even when
// Style.PixelGrid is disabled, allowing hosts to apply their own equivalent
// policy without inferring rule orientation again.
Snap SnapAxis
FontID string
Glyph uint16
// At places Paths[PathIndex] for ItemGlyphPath and is the font glyph origin
// for ItemGlyphRef. Path points resolve as At + templatePoint*Em.
At geometry.Point
Em float32
}
Item is one already-positioned drawing instruction.
type ItemRange ¶
ItemRange identifies a contiguous range in Box.Items.
Start is the zero-based index of the first item and Count is the number of items. An empty range is valid. Ranges returned by layout always refer to parent-frame storage and never require a coordinate translation.
type LineBox ¶
type LineBox struct {
Baseline float32
OffsetX float32
Width float32
Ascent float32
Descent float32
Overflow float32
Items ItemRange
Hits HitRange
// Tag is the borrowed canonical Box.Tag for a tag associated with this
// line. If non-nil, it must be the same pointer as Box.Tag. Its range is
// separate from the line range.
Tag *TagBox
}
LineBox is metadata for one display line inside a constrained Box.
Baseline is the line baseline's vertical offset from the parent box baseline, positive downward. Adjacent baselines are separated by the previous line's descent plus the current line's ascent; no additional leading is invented. OffsetX is the nonnegative horizontal offset of the line inside the parent's MaxWidth-wide alignment frame. Items and Hits are contiguous ranges into the owning Box's parent-frame slices. Overflow is max(line-local ink overflow, line width minus the parent frame width); the parent Box.Overflow covers the assembled aligned aggregate. When Tag is non-nil, line alignment is computed in the reduced frame MaxWidth-Tag.Width; an overfull formula line uses zero offset and the tag follows the formula.
type MissingFallback ¶ added in v0.4.0
MissingFallback identifies text for which none of TriedFaces supplied a usable outline cluster. It is structured lookup data, not a second diagnostic: recovery and CodeMissingGlyph diagnostics remain authoritative.
type PathTemplate ¶
type PathTemplate struct {
Segments []geometry.Segment
// Bound is the local control-point bounds before item placement.
Bound geometry.Rect
}
PathTemplate is one immutable path template in local em coordinates. Items place it in box coordinates with At and Em.
type PixelGrid ¶ added in v0.4.0
PixelGrid describes an optional device-pixel grid for thin rules and stems.
Scale is the host-unit-to-output-pixel scale and PixelRatio is the additional device-pixel ratio. The zero value disables snapping. Both fields must be positive and finite when either is set.
func (PixelGrid) SnapRect ¶ added in v0.4.0
SnapRect aligns the minor axis of a thin rule to the configured grid.
Snapping is deliberately conservative: only rules whose minor thickness is between 0.25 and 3 physical pixels are changed. The start edge moves to the nearest grid boundary, and thickness rounds to the nearest physical-pixel count with a one-pixel minimum. The major axis and all non-rule geometry are unchanged. An unset or invalid axis/grid is a no-op.
type SnapAxis ¶ added in v0.4.0
type SnapAxis uint8
SnapAxis identifies the minor axis of a thin rule that can be aligned.
type Style ¶
type Style struct {
Size float32
// MaxWidth enables constrained display line boxes when positive. A
// constrained Box.Width is the requested frame width.
MaxWidth float32
Align Align
ScriptLevel int
Features []string
GlyphRefs bool
// GenerateAlt requests Box.Alt generation through the public Engine
// facade. Expr.Alt remains available independently for parsed expressions.
GenerateAlt bool
// ColorPolicy controls explicit-color resolution in the serializable
// display list. The zero value preserves authored colors.
ColorPolicy ColorPolicy
// PixelGrid enables conservative device-pixel snapping for thin rules and
// stems. The zero value is a no-op.
PixelGrid PixelGrid
}
Style is a layout request in host units.
type TagBox ¶
type TagBox struct {
Source source.Range
Manual bool
Starred bool
// Line is FormulaTagLine for a formula-level tag, or a zero-based source
// row for a multiline row tag.
Line int
X float32
Y float32
Width float32
Ascent float32
Descent float32
Italic float32
Items ItemRange
Hits HitRange
}
TagBox is equation-tag metadata. Its Items and Hits ranges index the owning Box's parent-frame slices. X and Y are parent-frame coordinates and do not move with LineBox.OffsetX. Line is FormulaTagLine for Box.Tag, or a zero-based source row for an entry in Box.Tags.