Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::FontFamilyProvider Class Referenceabstract

Interface implemented by each font source (embedded, system) and by the aggregate FontCatalog. More...

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

Inheritance diagram for donner::svg::FontFamilyProvider:
[legend]

Public Member Functions

virtual std::vector< FontFamilyInfo > families () const =0
 List the families this provider can supply.
virtual bool hasFamily (std::string_view family) const =0
 Returns true if family is available.
virtual FontFaceAvailability availability (std::string_view family, const FontFaceRequest &) const
 Metadata only; the default preserves existing synchronous/system/custom providers.
virtual FontFaceAdmission tryAcquireFace (std::string_view, const FontFaceRequest &) const
 Acquire product-wide copy/decode admission without blocking. Does not fetch missing bytes.
virtual std::vector< uint8_t > loadFamilyData (std::string_view family, const FontFaceRequest &request) const =0
 Load encoded font-file bytes (sfnt, or WOFF2 in a full-text consumer) for the face of family that best matches request, or an empty vector if the family is unavailable.

Detailed Description

Interface implemented by each font source (embedded, system) and by the aggregate FontCatalog.

Lets FontManager resolve a font-family name against providers without depending on the (potentially large) embedded font bytes: the core engine sees only this interface, and the editor injects a concrete catalog.

All lookups by family name are case-insensitive.

Member Function Documentation

◆ availability()

virtual FontFaceAvailability donner::svg::FontFamilyProvider::availability ( std::string_view family,
const FontFaceRequest &  ) const
inlinevirtual

Metadata only; the default preserves existing synchronous/system/custom providers.

Reimplemented in donner::svg::EmbeddedFontProvider, donner::svg::FontCatalog, and donner::svg::SystemFontProvider.

◆ families()

virtual std::vector< FontFamilyInfo > donner::svg::FontFamilyProvider::families ( ) const
pure virtual

List the families this provider can supply.

Implemented in donner::svg::EmbeddedFontProvider, donner::svg::FontCatalog, and donner::svg::SystemFontProvider.

◆ hasFamily()

virtual bool donner::svg::FontFamilyProvider::hasFamily ( std::string_view family) const
pure virtual

Returns true if family is available.

Matching must be case-insensitive: callers fold family names when they index them, so a provider that compared case-sensitively would disagree with its own caller about which families exist.

It must also answer in constant or logarithmic time. Text layout asks once per unresolved family per span, and the number of families a provider holds is set by the host rather than by the document, so a linear scan of the provider's list turns one layout into work proportional to spans times families times installed fonts. Providers that enumerate a list should build a folded index alongside it rather than scanning it per call, and must not perform I/O or re-enumerate the underlying font source here.

Parameters
familyFont family name to test.
Returns
True when this provider can supply the family.

Implemented in donner::svg::EmbeddedFontProvider, donner::svg::FontCatalog, and donner::svg::SystemFontProvider.

◆ loadFamilyData()

virtual std::vector< uint8_t > donner::svg::FontFamilyProvider::loadFamilyData ( std::string_view family,
const FontFaceRequest & request ) const
pure virtual

Load encoded font-file bytes (sfnt, or WOFF2 in a full-text consumer) for the face of family that best matches request, or an empty vector if the family is unavailable.

Providers that only hold a single file per family return it for every request, which means bold and italic render as regular for those families - see EmbeddedFontProvider.

The returned bytes are suitable for FontManager::loadFontData() when its feature tier supports that format. They are not necessarily raw sfnt and must not be passed directly to an SFNT-only consumer such as an ImGui TTF loader.

A synchronous provider whose load cost grows with the font's size should poll ScopedFontLoadInterruption::Requested and may return an empty vector once it is true.

Parameters
familyFamily name to load (case-insensitive).
requestFace within the family to prefer.

Implemented in donner::svg::EmbeddedFontProvider, donner::svg::FontCatalog, and donner::svg::SystemFontProvider.

◆ tryAcquireFace()

virtual FontFaceAdmission donner::svg::FontFamilyProvider::tryAcquireFace ( std::string_view ,
const FontFaceRequest &  ) const
inlinevirtual

Acquire product-wide copy/decode admission without blocking. Does not fetch missing bytes.

Reimplemented in donner::svg::EmbeddedFontProvider, and donner::svg::FontCatalog.


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