Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
Elements: Text

Text elements render strings of glyphs using fonts loaded from @font-face rules. Donner supports per-character positioning, text-anchor, text-decoration, baseline control, and text layout along arbitrary paths with <textPath>. An optional HarfBuzz tier (--config=text-full) adds complex-script shaping.

The DOM base classes for text are SVGTextContentElement and SVGTextPositioningElement.

Font resolution and fallback

A font-family name is resolved by FontManager in this order:

  1. **Document @font-face rules** registered from the document's stylesheets (data sources, WOFF/WOFF2 where enabled). Fonts supplied by the document take precedence.
  2. The attached font provider, if one is installed with FontManager::setFontProvider() / FontManager::SetDefaultFontProvider(). The Donner editor installs a FontCatalog, which consults its providers in order:
    • Embedded: the curated Google Fonts set baked into the build (third_party/google_fonts/fonts.bzl).
    • System: fonts installed on the host OS (CoreText enumeration on macOS; none elsewhere).
  3. Public Sans, the embedded last-resort fallback.

Document @font-face rules use their declared font-weight, font-style, and font-stretch for matching, independently of the font file's embedded metadata. Supported descriptors are integer weights from 1 through 1000 (plus normal and bold), inclusive weight ranges, normal / italic / oblique styles, and the nine named widths from ultra-condensed through ultra-expanded, numeric nonnegative width percentages, and inclusive width ranges. The font-width descriptor is an alias for font-stretch. Reversed weight/width ranges are normalized; a scalar is equivalent to a range with equal endpoints, and width keywords are equivalent to their CSS percentages (for example, condensed is 75%). An omitted descriptor uses its normal value. The last valid occurrence wins; invalid or !important descriptors are ignored.

Face matching filters width before style and weight, follows the CSS weight search direction, and uses the last declared face when matching descriptors tie. Weight and width ranges select faces; they do not instantiate variable-font axes. The public font lookup continues to accept named widths. Descriptor auto, width math expressions, fractional weights, oblique angles, unicode-range, and font-display remain unsupported.

This cascade has consequences for portability. A file that names a font the viewer lacks (not in the document, not embedded, not installed) renders in Public Sans, so text stays legible but metrics and appearance differ from the authoring machine. A file that names a system font renders correctly on machines that have it and falls back elsewhere; only document @font-face data and the embedded set are guaranteed to travel. Lookups are case-insensitive, and generic CSS families (serif, sans-serif, monospace, ...) resolve through FontManager::setGenericFamilyMapping() before this cascade.