library text
Modules
font::faceA 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::outlineGlyph 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::rasterOutlines 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::readerBig-endian numbers read out of font data, 0 past its end, so a truncated or malformed font reads as zeros rather than faulting.
paragraphsLaying 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::applyApplying 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
atare those already done, HarfBuzz's output buffer, the rest its input.shaping::bufferThe 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::contextContextual 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::fallbackMarks placed without GPOS, around their base's ink box by their combining class, as HarfBuzz places them (hb-ot-shape-fallback.cc).
shaping::gposGlyph 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::gsubGlyph substitution (GSUB): single, multiple, alternate, ligature, contextual, chained contextual and reverse chained lookups, through extensions, applied as HarfBuzz applies them.
shaping::normalizeNormalizing 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::opentypeWhat 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::planWhat 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::shaperShaping 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::shapersThe 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
ComplexShapertheir plan keeps, the default shaper's done here.shaping::tagsOpenType'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'.textText 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::drawdraws 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::graphemesExtended grapheme clusters, by UAX #29's rules (Unicode 16.0): what a caret steps over and a selection takes whole.
unicode::linesLine break opportunities, by UAX #14's rules (Unicode 16.0) with LB1's default resolution of classes.
unicode::propertiesA code point's Unicode properties, from the generated tables, and UTF-8 decoding.
unicode::runsText 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::tablesGenerated 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::wordsWord 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::disposeValues that must be released by a call, not only freed.
std::equalEquality: the Equal interface.
std::ffiValues C holds for Alloy (LANGUAGE_SPEC.md section 6.3): a C library that calls back through an
extern (...) -> Rfunction often passes along avoid *its caller gave it.c_pointeris that pointer: made from a reference, read back as one by the callback, which names the type it was made from.std::float_digitsThe 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::formatFormatting values as text: the Format interface.
std::fsThe file system: directories, paths and what is at them.
std::hashHashing: the Key interface of hash map keys.
std::ioConsole and file input/output.
std::iterableThe iteration interfaces driving
forloops.std::macrosThe built-in compile-time macros (LANGUAGE_SPEC.md section 7.4).
std::mapThe hash map.
std::mathMathematics over floats (LANGUAGE_SPEC.md section 6.1a).
std::numberThe numeric constraint interface.
std::optionThe optional value: a payload (
Some) or its absence (None).std::processThe running process's environment.
std::sortSorting in place.
std::stringThe owned, growable byte string.
std::syncWhat tasks share (LANGUAGE_SPEC.md section 5.6).
std::vectorThe growable array.