DrawBitmapText supplies a small public-domain ASCII font without a font file.
Other scalars render as a replacement unless strict glyph checking is requested.
Tabs/newlines and integer scaling are supported. Font-file APIs read static
OpenType TrueType glyf or CFF1 outlines, including TTC/OTC collection face indexes.
They support cmap formats 4/12, proportional metrics, compound glyphs and CFF Type2/CID
subroutines. Font instruction bytecode is checked/skipped, never executed.
Rendering is grayscale and unhinted, without display-dependent subpixel color.
LoadFont(path) and LoadFontBytes(bytes) return opaque owning Font values.
FontHasGlyph, GetFontMetrics, GetKerning, MeasureText and DrawText borrow
them. Missing glyphs default to glyph zero; StrictGlyphs requests errors before
drawing. A Font cannot be implicitly copied. AddFont(BYREF fonts, TAKE font)
transfers it into an ordered FontSet; AddFontFile is a convenience for loading
and adding. Automatic cleanup drops the whole set.
CreateTextLayout(fonts, text, TextLayoutOptions {...}) returns an independent
opaque TextLayout owning prepared outlines. The single-Font overload uses the
same checked shaping machinery without cloning font bytes. The originating font
or set can leave scope before drawing the layout. DrawTextLayout borrows it;
repeated draws do not reshape or clone the outline buffer. Text measurement,
line/glyph queries and hit testing report original scalar
positions, rather than normalized or visual-order indexes.
Layout includes Unicode 17 extended grapheme boundaries, bidi resolution,
font-aware canonical normalization, whole-grapheme fallback, tabs/newlines,
word/grapheme wrapping, alignment, line spacing and per-line shaping. Public
GraphemeBoundaries, ResolveBidiLevels and BidiVisualOrder expose the relevant
text analysis. Normalization is currently internal to shaping; it is not a new
standalone public normalization API.
The OpenType reader implements GSUB 1–8 and GPOS 1–9 with contextual/extension lookups, ligatures, pair/class kerning, marks and cursive attachments, plus GDEF filtering. Joining/reordering stages cover the scripts in the independent corpus: Latin, Arabic, Hebrew, Devanagari, Bengali, Gujarati, Gurmukhi, Tamil, Telugu, Kannada, Malayalam, Oriya, Sinhala, Thai, Lao, Khmer and Myanmar. Passing that corpus does not establish exhaustive typographic conformance for every font or language. Variable/CFF2/color fonts, WOFF/WOFF2 and hint execution are unsupported.
ReadFontInfo, DiscoverFonts, DiscoverSystemFonts, FindFont and explicit
substitution flags provide bounded metadata discovery. The current Linux system
defaults are /usr/share/fonts and /usr/local/share/fonts, isolated in
linux_fonts.bas
. Pass an
explicit directory list for other locations; bundle licensed fonts when exact
cross-machine appearance matters. Discovery warnings are available separately.
Default font input is bounded to 32 MiB (configurable to 128 MiB). Layout bounds input/shaped glyphs to 65,536 and outlines to a configurable maximum of 1,048,576 edges. Lookup recursion/work and normalization expansion have separate bounds. Malformed fonts and exhausted limits raise CanvasError; file errors retain IoError. Prepared layout construction fails before target rasterization.
The pinned Unicode 17 corpus covers 766 grapheme vectors, 91,707 bidi vectors and 20,034 normalization vectors (200,340 checks). Synthetic fonts exercise malformed tables, outlines, collections, attachments, GSUB/GPOS primitives and atomic preparation failures. Real-font controls compare CFF rasterization with Pillow and glyph identities/positions with HarfBuzz. Source-free library tests return Fonts and prepared layouts, destroy local source fonts, transfer Fonts into sets, and render the returned layout afterwards. See the acceptance for the actual tested inputs and results.