Skip to main content

Module layout

Module layout 

Source
Expand description

Layout generators: box trees laid out by CSS flexbox and grid with the fonts the engine draws with.

A layout is resolved where text is prepared, which holds the fonts, so its text is measured and drawn by the same code. It is resolved at the render size, in render pixels, and rounded to whole pixels; a text node breaks its lines at its unrounded content width plus LAYOUT_WRAP_SLACK, when measured and when drawn alike.

Structs§

LayoutBounds
Where a layout’s nodes lie (measure_layout), in preorder.
NodeBounds
Where one layout node lies, before its clip’s transform and before node visuals: its layout boxes, not where it is drawn.
NodeRects
One node’s boxes in render pixels, [left, top, right, bottom], whole pixels from the picture’s top-left corner.
ResolvedLayout
Every node’s boxes, in preorder (resolve).

Constants§

LAYOUT_WRAP_SLACK
What a text node’s wrapping width adds to its content width, in pixels: float summation order cannot then break a text sized to its own max-content width again. A line it lets through overflows its box by under this much, and a text taller than its box by under this much still fits it.

Functions§

layout_texts
Each text node’s store key in preorder (None for empty text), and each distinct key’s raster request: wrapped at its unrounded content width plus the slack, as it was measured.
measure_layout
Where each node of a valid layout tree lies on a picture of size, at picture time time, laid out with rasterizer’s fonts as a frame lays it out. canvas is the project canvas, which the tree’s pixel lengths are pixels of (the picture’s own size when they are measured at it). Rects are before the clip’s transform and before node visuals: layout boxes, not where they are drawn. An invalid tree gives unspecified rects, but never panics.
resolve
Lays layout out on a picture of size pixels. shaped holds each text node’s shaped text, in preorder, None for an empty text.
shape_texts
Each text node’s shaped text, in preorder, shaped by shape on a picture of size: what resolve lays the texts out with.