Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
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 via <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). The document's own fonts always win.
  2. The attached font provider, if one is installed via 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.

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.