Skip to main content

Module layout

Module layout 

Source
Expand description

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

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

Structs§

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

Constants§

LAYOUT_WRAP_SLACK
Pixels added to a text node’s wrapping width so float summation order cannot re-break a text sized to its own max-content width. Lines and heights may overflow the box by less than this.

Functions§

fit_texts
Fits the font size of each text node with a font_size_fit to its content box in resolved (resolve), with lines from shape, and updates its font size, lines and overflow. The boxes keep the sizes they were laid out at.
layout_texts
Each text node’s store key in preorder (None for empty text), and each distinct key’s raster request at its font size in resolved, wrapped at its unrounded content width plus the slack and clamped in its content height plus the slack.
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 exactly as a frame is.
resolve
Lays layout out on a picture of size pixels. shaped holds each text node’s shaped text in preorder, None for empty text.
shape_texts
Shapes each text node’s text in preorder with shape on a picture of size, as resolve lays them out.