Skip to main content

Crate alpha2_layout

Crate alpha2_layout 

Source
Expand description

Where alpha2 text and layout boxes lie, without a GPU.

A text style or a layout generator’s box tree becomes the requests the text host (alpha2-text) draws and the rectangles they fill: text by its style’s position and anchor, a layout by CSS flexbox and grid. The engine draws from these same requests and rectangles, so a measurement and a frame place text alike, and a host without a GPU (a wasm page, the Python package) measures what a render would draw. json writes the measurements in the one JSON form every binding returns.

Re-exports§

pub use layout::LAYOUT_WRAP_SLACK;
pub use layout::LayoutBounds;
pub use layout::NodeBounds;
pub use layout::NodeRects;
pub use layout::ResolvedLayout;
pub use layout::layout_texts;
pub use layout::measure_layout;
pub use layout::resolve;
pub use layout::shape_texts;

Modules§

json
Measurements as JSON, from generators as a project holds them: the one form the wasm binding and the Python package return.
layout
Layout generators: box trees laid out by CSS flexbox and grid with the fonts the engine draws with.

Structs§

Baselines
Where a text’s first and last lines’ alphabetic baselines lie, y as a fraction of the canvas (or picture) height, as a CanvasRect’s top is: a text’s baseline lines up with another’s, or with a point, by arithmetic.
CanvasRect
A rectangle as fractions of the canvas, y down.
FontFiles
The faces a host registers from a list of font files, and each file’s bytes (fonts_from_files).
PictureSize
The size, in pixels, of a picture text and layouts are placed on: never empty, and within the largest frame the engine draws (alpha2_media::MAX_FRAME_DIMENSION, alpha2_media::MAX_FRAME_PIXELS).
TextBounds
Where a text lies, as fractions of the canvas, (0, 0) top-left to (1, 1) bottom-right, as its style’s position is: on the picture a text generator draws, before its clip’s transform and effects, and on the canvas for a caption. measure_text measures it.

Enums§

FontFileError
Why a font file could not be registered (fonts_from_files).
PictureSizeError
Why a size is not a PictureSize.

Constants§

MAX_FONT_PIXELS
The largest font, outline, and padding the text host draws, in pixels.
MAX_OUTLINE_PIXELS
See MAX_FONT_PIXELS.
MAX_PADDING_PIXELS
See MAX_FONT_PIXELS.

Functions§

fonts_from_files
The fonts of the files at paths, in fallback order, as a host registers them, and each file’s bytes, read once: each file’s family is its file stem, and every face of a collection is registered, in its order, sharing the file’s bytes, so its weights can be matched. A measurement and a render given the same paths draw with the same faces.
layout_text_key
A layout text’s raster request as a text store key: FNV-1a over a domain byte and every field of the request. Never zero.
measure_text
Where text in style lies on a canvas of size (TextBounds), laid out with rasterizer’s fonts as the engine’s text store lays it out and placed as a frame places it, without drawing it. Measured at the size a frame is drawn at, it agrees with that frame to the pixel; text laid out at another size can break its lines elsewhere.
rgba8
A straight, sRGB-encoded color as bytes.
shaped_key
What a request is shaped from, as a shaped-text cache key: equal keys shape alike with the same fonts.
text_key
A text’s identity at a render size: the text, its style, and the size, hashed (FNV-1a). Never zero.
text_request
The text host request for text in style on a picture of size, its content version key: sizes scaled from canvas fractions to pixels, within what the text host draws.