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. - 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 (
fonts_from_files). - 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). - Text
Bounds - 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_textmeasures it.
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, 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
textinstylelies on a canvas ofsize(TextBounds), laid out withrasterizer’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
textinstyleon a picture ofsize, its content versionkey: sizes scaled from canvas fractions to pixels, within what the text host draws.