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. The engine draws from the same requests and rectangles, so a host without a GPU (a wasm page, the Python package) measures exactly what a render draws. json writes the measurements in the 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, in the form the wasm binding and the Python package return.
layout
Layout generators: box trees laid out by CSS flexbox and grid with the engine’s fonts.
text_animation
Text animators applied to a laid-out text: each cluster’s selection and resulting state.

Structs§

Baselines
A text’s first and last alphabetic baselines, as fractions of the canvas (or picture) height, y down.
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.
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).
ShadowPixels
A text shadow in pixels of the picture its text is placed on.
TextAnimation
A text’s animators sampled at one time, with what they select from.
TextBounds
Where a text lies, as fractions of the canvas from (0, 0) top-left to (1, 1) bottom-right. For a text generator this is on its picture, before the clip’s transform and effects; for a caption it is on the canvas.
TextDraw
What the engine draws for one text: the raster, and the shadows composited under its glyphs.

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, stroke extent, and padding the text host draws, in pixels.
MAX_PADDING_PIXELS
See MAX_FONT_PIXELS.
MAX_STROKE_PIXELS
The most a text’s strokes reach together, in pixels. See MAX_FONT_PIXELS.

Functions§

animated_text_key
text_key for content in style shown time after its holder started. Without animators this is the static key; otherwise the runs and time are mixed in, so each moment of an animation is a distinct text. Never zero.
font_pixels
The pixel font size style draws at on a picture of size, as text_request sets it.
fonts_from_files
Loads the fonts at paths in fallback order, as a host registers them.
layout_text_key
A layout text’s raster request, shadows and animators hashed as a text store key (FNV-1a over a domain byte and every field). Never zero.
measure_text
Where text in style lies on a canvas of size, laid out with rasterizer’s fonts and placed exactly as a frame places it, without drawing it.
rgba8
A straight, sRGB-encoded color as bytes.
shadow_pixels
shadows in pixels of a font_size-pixel font (lengths are fractions of the font size), first on top.
shaped_key
What a request is shaped from, as a shaped-text cache key. Equal keys shape alike with the same fonts.
stroke_pixels
strokes in pixels of a font_size-pixel font (widths are fractions of the font size). Each is at least the smallest positive width, and the last is shortened so together they reach at most MAX_STROKE_PIXELS.
text_draw
The TextDraw of text in style on a picture of size, with content version key.
text_fill
A paint as the text host’s fill: a color as bytes, or a gradient over the layout box with the same stops and the conic angle in radians.
text_key
A text’s identity at a render size: the text, its style and the size, hashed with FNV-1a. Never zero.
text_request
The text host request for text in style on a picture of size, with content version key. Sizes are scaled from canvas fractions to pixels and clamped to what the host draws.