Documentation
¶
Overview ¶
Package display defines the immutable output contract for UI hosts.
Index ¶
Constants ¶
const FormulaTagLine = -1
FormulaTagLine identifies a tag that belongs to the complete formula rather than one rendered display line. It is the only Phase-1 TagBox line value.
const NoPath = -1
NoPath marks an item that does not reference Box.Paths.
Variables ¶
var ErrInvalidAlt = errors.New("display: invalid alternative text")
ErrInvalidAlt reports malformed alternative text.
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 ¶
Alt is semantic alternative text derived from the neutral expression tree.
func (Alt) MarshalCanonical ¶
MarshalCanonical returns deterministic JSON for alternative-text tests. It is not a stable cross-language protocol.
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
Alt Alt
// 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
// 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) Covering ¶
Covering returns the placed areas intersecting source range 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.
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 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
// PathIndex selects Box.Paths. It is NoPath for items without path data.
PathIndex int
Rect geometry.Rect
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 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 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
}
Style is a layout request in host units.
type TagBox ¶
type TagBox struct {
Source source.Range
Manual bool
Starred bool
// Line is FormulaTagLine. Zero-based row tags are reserved for future
// multiline equation-tag support and are not emitted by Phase 1.
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 the formula-level Phase-1 contract.