text

library text

Modules

font::face

A font face read from TrueType data: where its tables are, its metrics, characters to glyphs, advances and outlines. Its bytes are kept as given, read in place.

font::outline

Glyph outlines: from glyf, contours of on- and off-curve points (quadratic curves), composite glyphs assembled from their components; from CFF and CFF2 (text_fonts' cff.alloy), lines and cubic curves.

font::raster

Outlines into coverage masks (PLAN.md, F4 question 2): every line's signed area accumulated per pixel, then summed along each row, as font-rs does; curves are flattened into lines first. Grayscale, unhinted.

font::reader

Big-endian numbers read out of font data, 0 past its end, so a truncated or malformed font reads as zeros rather than faulting.

paragraphs

Laying text out: paragraphs between mandatory breaks, each given its direction and levels by UAX #9 (text_scripts' bidi, else left to right) and shaped in runs of one style and level, then filled into lines in the text's order at UAX #14's opportunities (spaces at a line's end hang past it; a word wider than a line breaks between clusters, and with text_scripts words of Thai, Lao, Khmer and Myanmar between any two graphemes), each line's glyphs put in visual order by their levels (L1, L2), lines stacked by their faces' metrics and aligned on their paragraph's side.

shaping::apply

Applying GSUB's and GPOS's lookups to a buffer, as HarfBuzz's apply context does (hb-ot-layout-gsubgpos.hh): each lookup over the glyphs its feature's mask selects, skipping those its flags ignore and the default ignorables; sequences matched by glyph, class or coverage, ligatures formed with the marks between their components kept apart, and the lookups a contextual rule names applied at positions within its match. The buffer is one array: the glyphs before at are those already done, HarfBuzz's output buffer, the rest its input.

shaping::buffer

The glyphs being shaped, as HarfBuzz's buffer keeps them: each with its cluster, the features it takes (a mask), what Unicode says of its character, what GDEF and substitutions say of its glyph, the ligature it belongs to, its syllable and what its script's shaper found; and their positions, with what each is attached to. Glyphs stay in the text's order, right to left too.

shaping::context

Contextual lookups, GSUB's 5 and 6 and GPOS's 7 and 8: a sequence of glyphs matched by glyph, class or coverage, with what comes before and after it, then other lookups applied at positions within it.

shaping::fallback

Marks placed without GPOS, around their base's ink box by their combining class, as HarfBuzz places them (hb-ot-shape-fallback.cc).

shaping::gpos

Glyph positioning (GPOS): single and pair adjustments, cursive attachment, marks attached to bases, ligatures and other marks, contextual and chained contextual lookups, through extensions, applied as HarfBuzz applies them. Attached glyphs keep what they attach to, resolved into offsets once every lookup ran (resolve_attachments).

shaping::gsub

Glyph substitution (GSUB): single, multiple, alternate, ligature, contextual, chained contextual and reverse chained lookups, through extensions, applied as HarfBuzz applies them.

shaping::normalize

Normalizing a run's characters as HarfBuzz does for the face (hb-ot-shape-normalize.cc): each character decomposed where the face lacks it and has its parts (or always, for some shapers), marks put in canonical order, then each mark composed with its base where the face has the result; every character given the glyph the face maps it to.

shaping::opentype

What GSUB and GPOS share: the script, language and feature lists that pick lookups, coverage and class tables, lookup flags and GDEF's glyph classes.

shaping::plan

What shaping a run applies, compiled once for a face, script, language, direction and set of features (HarfBuzz's shape plan and feature map, hb-ot-map.cc and hb-ot-shape.cc): the script's shaper, the language system its features are read from, each feature's mask, and the lookups of GSUB and GPOS in stages, each stage ending in what the shaper does between them.

shaping::shaper

Shaping a run of text in one face, in one direction, as HarfBuzz's OpenType shaper does (hb-ot-shape.cc): characters given their Unicode props and grapheme clusters, prepared by their script's shaper, mirrored right to left, normalized and mapped to glyphs, then substituted and positioned by the plan's lookups in stages, default ignorables hidden at the end.

shaping::shapers

The script shapers HarfBuzz chooses between (hb-ot-shaper.hh): what each asks of normalization and positioning; the complex ones (pkg::alloy::text_scripts) add steps of shaping through a ComplexShaper their plan keeps, the default shaper's done here.

shaping::tags

OpenType's script tags for a run, as HarfBuzz gives them (hb-ot-tag.cc): a script's new tags (dev3, dev2) before its old one (deva). The language systems a BCP 47 tag names are text_scripts'.

text

Text in pure Alloy (PLAN.md, stages F4 and F10): TrueType faces, text split into runs by script and emoji presentation, shaping by the faces' OpenType features, line breaking by UAX #14 with carets on grapheme clusters by UAX #29, and glyphs rasterized into coverage masks. It knows nothing of the GPU: pkg::alloy::draw draws a layout. Text is shaped as HarfBuzz shapes it. The bundled font is Inter Regular, made bold by thickening it. Two packages install more on the fonts (REFOCUS.md, R6d): pkg::alloy::text_scripts the complex scripts' shapers and both directions mixed by UAX #9, pkg::alloy::text_fonts CFF, variable and color faces (COLR, CBDT, sbix, as premultiplied RGBA) and fallback to the system's fonts. Without them every run is shaped by the default shaper, left to right, and characters Inter lacks show as boxes, the same on every target.

unicode::graphemes

Extended grapheme clusters, by UAX #29's rules (Unicode 16.0): what a caret steps over and a selection takes whole.

unicode::lines

Line break opportunities, by UAX #14's rules (Unicode 16.0) with LB1's default resolution of classes.

unicode::properties

A code point's Unicode properties, from the generated tables, and UTF-8 decoding.

unicode::runs

Text split into runs a face shapes whole (decisions/F10.md, question 1): by script, each character's Script and Script_Extensions (UAX #24) resolved as HarfBuzz and ICU resolve them, Common and Inherited characters joining the run around them and a closing bracket the run of its opening one; and by emoji presentation (UTS #51), a grapheme cluster at a time, so a run never splits one.

unicode::tables

Generated by unicode/generate.alloy from the Unicode Character Database 16.0.0: do not edit. A code point's value is VALUES[BLOCKS[MIDDLE[TOP[c >> 9] * 32 + (c >> 4 & 31)] * 16 + (c & 15)]].

unicode::words

Word boundaries, by UAX #29's rules (Unicode 16.0): where a screen reader's and the caret's words start and end. Thai, Lao, Khmer and Myanmar have no dictionary here, so a run of them is one word.

Dependencies

std::dispose

Values that must be released by a call, not only freed.

std::equal

Equality: the Equal interface.

std::ffi

Values C holds for Alloy (LANGUAGE_SPEC.md section 6.3): a C library that calls back through an extern (...) -> R function often passes along a void * its caller gave it. c_pointer is that pointer: made from a reference, read back as one by the callback, which names the type it was made from.

std::float_digits

The shortest decimal digits of a float that read back to the same value, by Ryu (Ulf Adams, "Ryu: fast float-to-string conversion", PLDI 2018), which std::format writes floats with (LANGUAGE_SPEC.md section 6.5). Integer arithmetic only, so compile-time code formats floats too.

std::format

Formatting values as text: the Format interface.

std::fs

The file system: directories, paths and what is at them.

std::hash

Hashing: the Key interface of hash map keys.

std::io

Console and file input/output.

std::iterable

The iteration interfaces driving for loops.

std::macros

The built-in compile-time macros (LANGUAGE_SPEC.md section 7.4).

std::map

The hash map.

std::math

Mathematics over floats (LANGUAGE_SPEC.md section 6.1a).

std::number

The numeric constraint interface.

std::option

The optional value: a payload (Some) or its absence (None).

std::process

The running process's environment.

std::sort

Sorting in place.

std::string

The owned, growable byte string.

std::sync

What tasks share (LANGUAGE_SPEC.md section 5.6).

std::vector

The growable array.