Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::FontManager::HostFontOverlay Struct Reference

Fonts a document lends to a document it references with an external <use>, for one occurrence of that <use>. More...

#include "donner/svg/resources/FontManager.h"

Static Public Member Functions

static std::shared_ptr< const HostFontOverlay > Make (std::span< const css::FontFace > faces, const FontManager *hostFonts)
 Build the overlay a host lends.

Public Attributes

std::vector< css::FontFace > faces
 The host's @font-face rules, each reduced to its data sources, in declaration order, after any faces the host was itself lent. At most kMaximumLentFaces.
std::vector< std::string > faceKeys
 css::FontFaceIdentityKey of each of faces, in the same order.
std::vector< std::pair< std::string, std::string > > genericFamilies
 The host's CSS generic family mappings, as (lowercased generic name, family) pairs sorted by generic name.
uint64_t digest = 0
 Digest of faces and genericFamilies; never zero. Overlays with equal content have equal digests, since face identity follows css::FontFaceIdentityKey.

Detailed Description

Fonts a document lends to a document it references with an external <use>, for one occurrence of that <use>.

The referenced element renders as an instance of the <use>, so its text resolves families the host declares, as it would if the element were in the host. The overlay holds only data sources: sources the host already turned into bytes. Lending fonts therefore fetches nothing on the referenced document's behalf, and a face whose bytes the host has not loaded is not lent. An overlay is immutable once built, so one overlay can be lent to many occurrences.

Member Function Documentation

◆ Make()

std::shared_ptr< const HostFontOverlay > donner::svg::FontManager::HostFontOverlay::Make ( std::span< const css::FontFace > faces,
const FontManager * hostFonts )
static

Build the overlay a host lends.

Its cost is linear in the host's faces and mappings, so callers build it once per host and frame rather than once per occurrence.

Parameters
facesThe host's @font-face rules.
hostFontsThe host's font manager, for its generic family mappings and any overlay the host is itself lent. May be nullptr.
Returns
The overlay, or nullptr when the host has nothing to lend.

The documentation for this struct was generated from the following file: