Documentation
¶
Overview ¶
Package layout places the text of resolved generated pages. It joins the pure domain of package assembly (resolved page sizes and appearances) with package typeset (fonts, shaping, wrapping, overflow), so that neither knows about the other.
Index ¶
- Constants
- func Params(spec *assembly.BlankSpec) typeset.Params
- func Place(ctx context.Context, layout *assembly.Layout, fonts FontSet) ([]*typeset.Placed, error)
- func PlaceBounds(ctx context.Context, layout *assembly.Layout, fonts FontSet, ...) ([]*typeset.Placed, error)
- func PlaceSpec(shaper *typeset.Shaper, table *assembly.Layout, index int, fonts FontSet) (*typeset.Placed, error)
- func ValidateText(ctx context.Context, flat *assembly.Flattened, fonts FontSet) error
- type FontSet
Constants ¶
const ( // StageLayout is text shaping, wrapping, and overflow on a resolved page. StageLayout assembly.Stage = "layout" // CodeTextOverflow means text with overflow "error" leaves its box or the page. CodeTextOverflow assembly.Code = "text_overflow" // CodeTextUnsupported means the text has characters the font or the shaper cannot render. CodeTextUnsupported assembly.Code = "text_unsupported" // CodeTextParameter means a text value is outside what the typesetter supports. CodeTextParameter assembly.Code = "text_parameter_invalid" // CodeFontInvalid means the font file is damaged: it loads, but an outline the text needs cannot be read. CodeFontInvalid assembly.Code = "font_invalid" // CodeTextFailed means shaping failed for another reason. CodeTextFailed assembly.Code = "text_layout_failed" )
Variables ¶
This section is empty.
Functions ¶
func Params ¶
Params maps a resolved blank to typeset parameters. The nine anchors and four alignments share their grid order with typeset's, offsets are points with +y up, and the wrap width is the block width.
func Place ¶
Place lays out the text of every distinct resolved spec exactly once, in table order, and returns the placements parallel to layout.Specs. A spec that cannot be placed, or whose text overflows under the "error" policy, retains available bounds/findings with diagnostics locating its effective declaration. Distinct declarations remain distinct faults despite appearance sharing; complete consumer references identify all affected contributions. Geometry-independent rejection has no placement. ctx is checked between specs.
func PlaceBounds ¶
func PlaceBounds(ctx context.Context, layout *assembly.Layout, fonts FontSet, observer observation.Observer) ([]*typeset.Placed, error)
PlaceBounds is Place for a check that renders nothing: only the bounds and findings of each placement are kept, so a check does not hold every shaped glyph of thousands of distinct texts.
func PlaceSpec ¶
func PlaceSpec(shaper *typeset.Shaper, table *assembly.Layout, index int, fonts FontSet) (*typeset.Placed, error)
PlaceSpec shapes one resolved spec and returns its located error without discarding overflow geometry. A shared Shaper keeps only bounded font caches between sequential pages.