library text_scripts
Modules
shaping::arabicThe Arabic shaper (hb-ot-shaper-arabic.cc), for Arabic, Syriac and, through the Universal Shaping Engine, the other joining scripts: each character's joining form from its Joining_Type and its neighbors' (
isol,fina,fin2,fin3,medi,med2,init), the features in the order the Arabic specification applies them,stch's pieces repeated to fill the word they stretch, and the modifier combining marks of UTR #53 moved before the other marks.shaping::complexThe complex shapers HarfBuzz chooses between (hb-ot-shaper.hh): which one a script takes, and the steps of shaping each adds, dispatched here to their modules from the
ComplexShapera plan keeps.shaping::hangulThe Hangul shaper (hb-ot-shaper-hangul.cc): jamo composed into the syllable they spell where the face has its glyph, syllables decomposed into jamo where it has not (or a trailing jamo follows), the jamo then given
ljmo,vjmoandtjmo; tone marks moved before their syllable when they take space.shaping::hebrewHebrew's shaper (hb-ot-shaper-hebrew.cc): presentation forms composed for faces without GPOS marks, and patah or qamats moved after a sheva or hiriq before a meteg.
shaping::indicThe Indic shaper (hb-ot-shaper-indic.cc), for Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada and Malayalam: the syllables its machine finds, each reordered before the basic features (the base consonant found, reph and pre-base matras marked, below and post-base forms told apart by asking the face) and again after them (pre-base matras and reph moved to where the forms formed put them), in either the old OpenType specification's order or the new one's.
shaping::khmerThe Khmer shaper (hb-ot-shaper-khmer.cc): syllables found by its machine, a coeng Ra moved first for
prefand the consonants after it givencfar, pre-base vowels moved first, and the split vowels decomposed into their two parts.shaping::language_tagsGenerated by unicode/language_tags.alloy from HarfBuzz 14.1.0's hb-ot-tag-table.hh (MIT licensed): do not edit. Tags are four bytes, big-endian, spaces after a shorter one.
shaping::languagesThe OpenType language systems a BCP 47 tag names, as HarfBuzz gives them (hb-ot-tag.cc), from the tables language_tags.alloy holds.
shaping::machinesGenerated by unicode/machines.alloy from HarfBuzz 14.1.0's syllable machines (hb-ot-shaper-*-machine.hh, generated there by Ragel; MIT licensed): do not edit.
shaping::myanmarThe Myanmar shaper (hb-ot-shaper-myanmar.cc), for faces made for the
mym2specification: syllables found by its machine, each sorted by the positions its parts take around the base (kinzi after the base, medial Ra and pre-base vowels before it).shaping::syllablesWhat the syllabic shapers share (hb-ot-shaper-syllabic.cc): their syllables found by a machine of Ragel's tables (machines.alloy), dotted circles inserted in broken clusters, and in vowel sequences that would look like another vowel.
shaping::thaiThe Thai and Lao shaper (hb-ot-shaper-thai.cc): Sara Am split into Nikhahit and Sara Aa, the Nikhahit moved before the above-base marks before it; for a Thai face without GSUB's Thai script, marks and descenders moved by the face's private-use glyphs, as Windows and the Mac lay them out.
shaping::universalThe Universal Shaping Engine (hb-ot-shaper-use.cc), for Tibetan, Sinhala, Javanese, Mongolian and the other scripts HarfBuzz sends to it: syllables found by its machine over the USE categories (CGJ left out, ZWNJ before a mark too), a repha moved after the base, pre-base vowels before it, and joining forms by syllable, or by Arabic's joining for the scripts that join.
text_scriptsComplex scripts for pkg::alloy::text (REFOCUS.md, R6d): the shapers HarfBuzz has for Arabic and Syriac, Hebrew, the nine Indic scripts, Khmer, Myanmar, Thai and Lao, Hangul and the 84 scripts of the Universal Shaping Engine, with their syllable machines and tables; text in either direction and both mixed by UAX #9; lines of Thai, Lao, Khmer and Myanmar broken between graphemes; and the OpenType language systems of every BCP 47 tag HarfBuzz knows. A program installs them on its fonts before laying text out:
unicode::bidiThe Unicode Bidirectional Algorithm, UAX #9 (Unicode 16.0): a paragraph's embedding levels from its characters' Bidi_Class (P2-P3, explicit embeddings, overrides and isolates X1-X10, weak types W1-W7, paired brackets N0, neutrals N1-N2, implicit levels I1-I2), a line's whitespace back at the paragraph's level (L1) and its visual order (L2). Unicode's BidiTest.txt and BidiCharacterTest.txt check it (conformance.alloy).
unicode::levelsLaying out text in either direction: a paragraph's levels by UAX #9 (bidi.alloy), and a line's glyphs put in visual order by them.
unicode::script_propertiesThe Unicode properties bidi and the complex shapers read, from the generated tables (script_tables.alloy, which text's unicode/generate.alloy writes).
unicode::script_tablesGenerated by text/unicode/generate.alloy from the Unicode Character Database 16.0.0: do not edit.
Dependencies
pkg::alloy::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.pkg::alloy::text::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.
pkg::alloy::text::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.pkg::alloy::text::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.
pkg::alloy::text::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.
pkg::alloy::text::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.
pkg::alloy::text::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.pkg::alloy::text::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.
pkg::alloy::text::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.
pkg::alloy::text::shaping::fallbackMarks placed without GPOS, around their base's ink box by their combining class, as HarfBuzz places them (hb-ot-shape-fallback.cc).
pkg::alloy::text::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).pkg::alloy::text::shaping::gsubGlyph substitution (GSUB): single, multiple, alternate, ligature, contextual, chained contextual and reverse chained lookups, through extensions, applied as HarfBuzz applies them.
pkg::alloy::text::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.
pkg::alloy::text::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.
pkg::alloy::text::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.
pkg::alloy::text::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.
pkg::alloy::text::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.pkg::alloy::text::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'.pkg::alloy::text::unicode::graphemesExtended grapheme clusters, by UAX #29's rules (Unicode 16.0): what a caret steps over and a selection takes whole.
pkg::alloy::text::unicode::linesLine break opportunities, by UAX #14's rules (Unicode 16.0) with LB1's default resolution of classes.
pkg::alloy::text::unicode::propertiesA code point's Unicode properties, from the generated tables, and UTF-8 decoding.
pkg::alloy::text::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.
pkg::alloy::text::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)]].
pkg::alloy::text::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.
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::textSearching and parsing byte text.
std::vectorThe growable array.