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.
- Canvas
Rect - A rectangle as fractions of the canvas, y down.
- Font
Files - The faces a host registers from a list of font files, and each file’s bytes.
- Picture
Size - 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). - Shadow
Pixels - A text shadow in pixels of the picture its text is placed on.
- Text
Animation - A text’s animators sampled at one time, with what they select from.
- Text
Bounds - 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. - Text
Draw - What the engine draws for one text: the raster, and the shadows composited under its glyphs.
Enums§
- Font
File Error - Why a font file could not be registered (
fonts_from_files). - Picture
Size Error - 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_keyforcontentinstyleshowntimeafter 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
styledraws at on a picture ofsize, astext_requestsets it. - fonts_
from_ files - Loads the fonts at
pathsin 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
textinstylelies on a canvas ofsize, laid out withrasterizer’s fonts and placed exactly as a frame places it, without drawing it. - rgba8
- A straight, sRGB-encoded color as bytes.
- shadow_
pixels shadowsin pixels of afont_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 strokesin pixels of afont_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 mostMAX_STROKE_PIXELS.- text_
draw - The
TextDrawoftextinstyleon a picture ofsize, with content versionkey. - 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
textinstyleon a picture ofsize, with content versionkey. Sizes are scaled from canvas fractions to pixels and clamped to what the host draws.