Skip to main content

Crate valo_text

Crate valo_text 

Source
Expand description

valo-text — typographer + paragraph layout, no GPU. The pipeline: style spans → per-character font fallback → bidi levels → harfrust shaping (endless line) → greedy wrapping with UAX #14 opportunities → per-line UAX #9 visual reorder → placed glyph runs. Glyph raster (swash alpha masks, SDF distance fields, skrifa outline paths) also lives here — CPU-only; the renderer’s atlas calls in.

Structs§

Decoration
An underline / strike-through / overline, drawn from the font’s own decoration metrics (post/OS2 tables; skparagraph’s Decorations.cpp).
FaceSet
The host’s registered fonts: families for styles to name, plus a global fallback chain consulted per character. Immutable once built — register everything, then Arc it for builders and the renderer.
Font
FontAttrs
One registered font: immutable bytes + the metrics every layout needs. Shaping (harfrust), outlines (skrifa), and raster (swash) all re-read the same bytes — no parsed state is shared across those seams. A variant’s place in its family — CSS-style matching picks by these.
FontCollection
Faces plus the sources that can find more — Skia’s FontCollection (skparagraph FontCollection.h: the asset/dynamic/default SkFontMgrs live INSIDE the collection, and findTypefaces/defaultFallback are its methods). Shaping consults this at every miss; what no source can answer accumulates as the demand a host fetches asynchronously (Flutter web’s _unprocessedCodePoints).
FontDemand
What shaping could not resolve — the host’s font-loading demand signal (Flutter web’s missing-font detection reshaped as an API). families: requested names the collection has NO face for at all. codepoints: chars NO present face covers, each with the attrs of the span that wanted it — a bold span’s missing glyph should be answered with a bold face (for subset-chunk families this doubles as “which chunk is missing”). valo detects; the host owns the loading policy — Google, a mirror, bundled files, the OS, anything.
FontId
Index into a FontCollection — stable for the collection’s lifetime.
GlyphImage
A rasterized glyph: A8 coverage (or normalized distance for SDF), plus the placement of the bitmap’s top-left relative to the glyph origin (left right of origin, top above the baseline — swash conventions).
GlyphStroke
The stroke a glyph raster can carry: valo_geometry::Stroke without its dashes, which a fixed-size atlas key has nowhere to put. Impeller’s StrokeParameters carries the same four fields for the same reason. width is in the raster’s own pixels, like px.
Line
LineMetrics
Per-line metrics for caret/selection UIs (skparagraph’s LineMetrics).
Paragraph
The retained paragraph, with Skia’s state tiers made explicit (SkParagraph’s kShaped/kWrapped/kFormatted ladder):
ParagraphBuilder
Collects styled spans; build() runs fallback segmentation + shaping once and hands back the retained Paragraph.
ParagraphStyle
Paragraph-level knobs, fixed at build (Flutter’s ParagraphStyle).
PlacedGlyph
One positioned glyph: x/y in paragraph-local px, y on the baseline.
PlacedRun
A line’s worth of one font+size+color — exactly what one GlyphRun display-list op carries.
PositionWithAffinity
A byte offset plus which side of it the position leans (SkParagraph’s PositionWithAffinity): downstream = the caret belongs to the glyph AFTER the offset.
Rasterizer
CPU glyph rasterization, on swash. One per renderer — swash’s context caches scaling state, and the stroker its segment buffers.
Shadow
One text shadow: an offset, optionally blurred copy in color.
TextStyle
How one span of text looks (skparagraph’s TextStyle, the subset valo implements). Families are tried in order per character (then the collection’s fallback chain); weight/italic pick within a family’s variants.

Enums§

DecorationKind
TextAlign
Paragraph-level horizontal alignment (needs a finite layout width).
TextDirection
Which way the paragraph reads before its content gets a say.
VariantCaps
CSS font-variant-caps, lowered to the OpenType features a shaper understands. Every variant here is a font capability: a face without the feature renders unchanged rather than synthesizing small capitals, which is what browsers do for font-synthesis: none and what valo always does.

Constants§

SDF_PAD
SDF spread in texels: distance saturates ±this many pixels from the edge (0.5 = on the edge). Also the raster padding so the field has room.

Traits§

FontSource
Somewhere fonts can come FROM when the collection lacks them — the pluggable half of the demand loop. Implementations only locate and parse (an installed-fonts scan today; a platform-native CoreText/DirectWrite lookup can replace it without touching policy); the growth policy itself lives in FaceSet::grown_by.

Functions§

glyph_path
The glyph as a valo Path at px, baseline-origin, y-down — the huge- text tier: stencil-then-cover handles it like any shape.

Type Aliases§

FontData
Font file bytes however the host owns them: an owned buffer, or a memory-mapped file from a system-font source — faces only ever read.