text#
fonts (SGF1, TrueType, CFF, COLR), glyph cache, text runs -- crate root lib/text/lib.rs
text -- fonts (embedded SGF1 / TrueType, runtime OpenType / collections, synthetic styles,
colour glyphs), the glyph cache and text runs [src/text/*.s]
Text::new(fonts, names) register the style's four embedded fonts
set_font(font, size_fx) select a font id and the pixel size (24.8)
draw(dc, sf, x, y, s) -> px y = baseline (origin-relative); stops at NUL / newline
draw_n(dc, sf, x, y, s, len) at most len bytes (a UTF-8 sequence cut by len ends it)
measure(s) -> 24.8 width(s) -> px (rounded up) ascent() / descent() / line_h() -> px
hit(s, len, x) -> byte index caret_x(s, index) -> px
decor(dc, sf, x, y, w, TD_*) underline / strikeout rectangles
icon_draw(dc, sf, cp, x, y, size_fx) FONT_ICON with its em box at x, y
gc_get / gc_get_bitmap / gc_box / gc_flush / gc_scale / gc_usage the glyph cache
(glyphcache.rs)
png_decode / img_scale CBDT hooks (default: img_png::decode, img_core::ops::scale)
font registry: registry.rs; system font database: fontdb.rs; generic families,
substitutes and the languages' fonts (a light fontconfig): fontconf.rs
segment: grapheme clusters, words (UAX #29) and line break opportunities (UAX #14)
set_antialias(on) / antialias() smoothed (default) or black-and-white glyph masks
(the system's "font smoothing off"; glyphs too large for
the cache stay smoothed)
set_subpixel(SUBPIXEL_*) / subpixel() subpixel (LCD) smoothing in the display's order
on opaque targets (lcd.rs); NONE (default): greyscale
set_fallback_fonts / set_system_fallback / fallback_for characters the font lacks come
from other fonts (fallback.rs; also when shaping)
set_bidi(on) / has_rtl(s) (default on) lines with right-to-left characters in their
visual order, Hebrew and Arabic shaped by their fallback
font, also while set_shaping is off (bidi.rs); other lines
keep their metrics
record_n / record_icon / glyphs glyphs placed now, blended later from the glyph cache by
any thread (record.rs: GlyphRec, GlyphView)
var_axes / var_instances / var_values / vary / vary_named variable fonts: their axes,
named instances and instances at axis values (registry.rs,
var.rs: gvar, avar, HVAR, MVAR; shaping at the same
coordinates)
Pen positions are 24.8 fixed point; glyphs are placed on quarter pixels and their
coverage masks are cached per (font, glyph, size, phase, greyscale / subpixel). Colour
fonts: COLR glyphs are drawn layer by layer (palette 0; the foreground entry uses the
current colour, palette alphas are multiplied by the current colour's alpha), CBDT glyphs
as PARGB bitmaps (not drawn into A8 targets). Glyphs too large for the glyph cache are
filled directly. U+00AD SOFT HYPHEN is not drawn and has no width (line wrapping shows a
hyphen where it breaks: text::segment::wrap_end_hyph).