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§
- Cluster
Info - One cluster of a
TextLayout. - Cluster
State - Animation state of one cluster.
- Color
Mix - A color change
base * keep + addin premultiplied linear light. Mixing toward a target bywiskeep = 1 - w,add = w * target; mixes compose. - Line
Info - One line of a
TextLayout. - Line
Metrics - Lines of a shaped text at one wrapping width (
ShapedText::lines_at). - Shaped
Text - Text shaped once (
TextRasterizer::shape) so lines can be broken at any width without reshaping. - Text
Background - A box behind each non-empty line (advance by one em, grown by
padding). Touching boxes merge. - Text
Font - One caller-owned font registered in fallback order.
- Text
Gradient - 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. - Text
Gradient Stop - One color of a
TextGradient. - Text
Layout - Cluster and line positions, matching
TextRasterizer::rasterize. - Text
Measure - 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. - Text
Raster Request - One text layout request.
- Text
Raster Result - Rasterized pixels and their text-specific layout descriptor.
- Text
Rasterizer - Deterministic text host with version-key result caching.
- Text
Stroke - An outline band drawn behind the glyphs and earlier strokes.
Enums§
- Text
Fill - What paints a text’s glyphs.
- Text
Gradient Kind - Where a gradient’s offsets lie.
- Text
Raster Error - Typed text-host failure.
- Text
Spread - 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
byteshold an OpenType face atface_index, asTextRasterizer::add_fontwould, 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.
Nonefor 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.