layout

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

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

View Source
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

func Params(spec *assembly.BlankSpec) typeset.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

func Place(ctx context.Context, layout *assembly.Layout, fonts FontSet) ([]*typeset.Placed, error)

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.

func ValidateText

func ValidateText(ctx context.Context, flat *assembly.Flattened, fonts FontSet) error

ValidateText caches geometry-independent constraints and aggregates faults by their actual declaration and font/text constraint. Consumer references remain complete after style deduplication.

Types

type FontSet

type FontSet func(path string) (*typeset.Font, bool)

FontSet returns a captured font, or the built-in font for the empty path.

Jump to

Keyboard shortcuts

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