Skip to main content

Crate alpha2_text

Crate alpha2_text 

Source
Expand description

Text shaping and rasterization for alpha2 hosts.

Produces the engine’s TextTexture in pure Rust from caller-supplied fonts. Paragraphs are split by direction (UAX #9), script and font, shaped with rustybuzz, broken per UAX #14 and rasterized with ab_glyph_rasterizer (color glyphs in color). The same request and fonts give the same pixels natively and in wasm, so browser preview and native export match.

Structs§

ClusterInfo
One cluster of a TextLayout.
ClusterState
Animation state of one cluster.
ColorMix
A color change base * keep + add in premultiplied linear light. Mixing toward a target by w is keep = 1 - w, add = w * target; mixes compose.
LineInfo
One line of a TextLayout.
LineMetrics
Lines of a shaped text at one wrapping width (ShapedText::lines_at).
ShapedText
Text shaped once (TextRasterizer::shape) so lines can be broken at any width without reshaping.
TextBackground
A box behind each non-empty line (advance by one em, grown by padding). Touching boxes merge.
TextFont
One caller-owned font registered in fallback order.
TextGradient
A gradient over a text’s layout box. Points are fractions of the box ((0, 0) top-left) and a radius is a fraction of its shorter side.
TextGradientStop
One color of a TextGradient.
TextLayout
Cluster and line positions, matching TextRasterizer::rasterize.
TextMeasure
Text geometry from TextRasterizer::measure. Rectangles are [left, top, right, bottom] in pixels from the layout box’s top-left, which sits at (TextTexture::layout_x, TextTexture::layout_y) in the rasterized texture.
TextRasterRequest
One text layout request.
TextRasterResult
Rasterized pixels and their text-specific layout descriptor.
TextRasterizer
Deterministic text host with version-key result caching.
TextStroke
An outline band drawn behind the glyphs and earlier strokes.

Enums§

TextFill
What paints a text’s glyphs.
TextGradientKind
Where a gradient’s offsets lie.
TextRasterError
Typed text-host failure.
TextSpread
What a linear or radial gradient shows past its first and last stops.

Constants§

DEFAULT_TEXT_CACHE_BYTES
Default result cache budget in bytes: a few full-frame 4K titles.

Functions§

check_font
Checks that bytes hold an OpenType face at face_index, as TextRasterizer::add_font would, so a host can reject a file at import.
face_count
Number of faces in a font collection (.ttc, .otc), else 1.
fold_family
Normalizes a family name for comparison: NFC, then Unicode lowercase.
font_family
The face’s typographic family (name ID 16), else family (name ID 1), preferring US English. None for unparsable bytes or no family name.
font_family_names
Every distinct name ID 16 and 1 family name in every language, in table order. A project may name a family by any of them. Empty for unparsable bytes.
half_leading
CSS half-leading above the em box, or zero when lines are closer than an em.