Expand description
Line layout: text in, broken lines out.
Knuth-Plass total fit. A paragraph is flattened into style runs, shaped, and modelled as boxes, glue and penalties; the breaker picks the set of breaks with the fewest demerits over the whole paragraph rather than the most text on each line. The break source is UAX #14 with word boundaries from UAX #29, plus optional hyphenation, which enters as a flagged penalty.
Justified text has its glue stretched or shrunk to the measure
here. The adjustment lands on the glyphs’ own advances, so a
painter positions what it is given and never re-derives spacing.
A Line is shaped runs: measurement happened here.
Units: advances come out of the shaper in font units; the measure
arrives in points and converts once, via units_per_em * size.
The stages have a file each: flatten makes one string of styled
spans, shape turns spans into glyphs, opportunity says where a
line may end, breaker picks the breaks, justify moves the glue
on a line that was set to its measure, and line is what comes
out.
Structs§
- Broken
- One paragraph broken into lines: the lines themselves, and where each of them ended.
- Face
- The face
::first-lineasks its runs for: a family, a slope and a weight, each one set only where the rule set it. - First
Line - What
::first-linechanges about the paragraph it opens. - Generated
- Text the sheet generates around one inline element: what
::beforeand::afterhold, each with the style it is set in. - Hanging
Punctuation - Which marks may hang past the measure, from
hanging-punctuation. - Inherited
- Every inline takes the style of the block around it.
- Inline
Box - What one inline element paints around its runs, and what that takes on each edge.
- Inline
Fragment - One inline element’s box on one line: where it sits, and which of its edges it paints there.
- Line
- One typeset line: shaped runs plus its width in font units.
- Line
Break Options - How a paragraph is broken and filled. The defaults are ragged right, no hyphenation, and no mark hanging past the measure.
- Line
Layout - The layout pass: one paragraph → lines that fit the measure.
- Line
Span - One span of a line: the runs set in it, and where they go.
- Measure
- The spans a paragraph breaks to, in reading order.
- Opening
- What sets a paragraph’s opening apart from the rest of it.
- Paragraph
Style - Everything one paragraph’s layout depends on, and the colour its runs are painted in. The style tree compiles down to this.
- Patterns
- The syllable patterns
hyphens: autobreaks words by. - Shaped
- A paragraph shaped once, and everything about it the measure does not decide: the flattened text, the runs it shaped into, and the style and options it was set with.
- Shaped
Run - A run of glyphs sharing one font and size — the paintable unit.
- Span
- One place a line may start and how wide it may run.
Enums§
- HangEnd
- How far
hanging-punctuationgoes at the end of a line. - Spans
- The spans of one line, read as a slice either way. A band set undivided holds its span inline: the ordinary line of a book does not pay for an allocation.
Traits§
- Inline
Styles - Where line layout gets the style of one inline node.