Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::FontCatalog Class Reference

Aggregate font catalog: the single surface the editor's font picker and FontManager resolution consume. More...

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

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

Public Member Functions

 FontCatalog ()
 Construct with the default providers: embedded fonts, then platform system fonts.
 FontCatalog (std::shared_ptr< CatalogEncodedFontStore > store)
 Use a session-owned deferred catalog store followed by the platform system provider.
std::shared_ptr< CatalogEncodedFontStore > encodedStore () const
 The default bundled provider's delivery/admission store; null for an explicit custom list.
 FontCatalog (std::vector< std::unique_ptr< FontFamilyProvider > > providers)
 Test/advanced constructor: supply the ordered provider list explicitly (first wins on ties). Empty-byte fallback between legacy synchronous providers is supported. An immutable asset provider must precede synchronous claimants for the same family; it cannot be their fallback because doing so would separate its bytes from the selected metadata/admission contract.
 FontCatalog (const FontCatalog &)=delete
FontCatalog & operator= (const FontCatalog &)=delete
std::vector< FontFamilyInfo > families () const override
 All available families, Bundled group first then System group, each group sorted by name.
bool hasFamily (std::string_view family) const override
 True if any provider supplies family (case-insensitive).
std::optional< FontFamilyInfo > find (std::string_view family) const
 Resolve family (case-insensitive) to its catalog entry, or std::nullopt if no provider supplies it (in which case a document naming this family renders through the Public Sans fallback).
std::vector< uint8_t > loadFamilyData (std::string_view family, const FontFaceRequest &request) const override
 Encoded font-file bytes for family from the first provider that has it (Bundled before System).
FontFaceAvailability availability (std::string_view family, const FontFaceRequest &request) const override
 Metadata only; the default preserves existing synchronous/system/custom providers.
FontFaceAdmission tryAcquireFace (std::string_view family, const FontFaceRequest &request) const override
 Acquire product-wide copy/decode admission without blocking. Does not fetch missing bytes.
std::vector< FontFamilyInfo > familiesBySource (FontSource source) const
 Families from a single source (Bundled or System), sorted by name.
std::vector< uint8_t > loadFace (std::string_view family) const
 Alias for loadFamilyData(), named for the picker's preview use. Previews show the family's default face, so this asks for the regular upright one.

Detailed Description

Aggregate font catalog: the single surface the editor's font picker and FontManager resolution consume.

The default catalog also resolves the CSS generic sans-serif family through bundled regular, bold, and italic faces without listing it as a named picker family.

A default-constructed catalog contains the generic sans-serif faces, an embedded provider (curated Google Fonts), then a system provider (CoreText on macOS; a no-op stub elsewhere). Providers are consulted in order, so resolution and loadFace() prefer Bundled families over System families, and families() lists the Bundled group before the System group.

The catalog implements FontFamilyProvider, so it can be installed directly on a FontManager (via setFontProvider() or SetDefaultFontProvider()).

Picker contract

Member Function Documentation

◆ availability()

FontFaceAvailability donner::svg::FontCatalog::availability ( std::string_view family,
const FontFaceRequest &  ) const
overridevirtual

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

Reimplemented from donner::svg::FontFamilyProvider.

◆ families()

std::vector< FontFamilyInfo > donner::svg::FontCatalog::families ( ) const
overridevirtual

All available families, Bundled group first then System group, each group sorted by name.

If the same family name appears in both groups the Bundled one wins and the System duplicate is dropped (case-insensitive).

Implements donner::svg::FontFamilyProvider.

◆ find()

std::optional< FontFamilyInfo > donner::svg::FontCatalog::find ( std::string_view family) const

Resolve family (case-insensitive) to its catalog entry, or std::nullopt if no provider supplies it (in which case a document naming this family renders through the Public Sans fallback).

The returned FontFamilyInfo::source tells the caller whether it resolved to an Bundled or System font, mirroring findFont() precedence.

◆ hasFamily()

bool donner::svg::FontCatalog::hasFamily ( std::string_view family) const
overridevirtual

True if any provider supplies family (case-insensitive).

Implements donner::svg::FontFamilyProvider.

◆ loadFamilyData()

std::vector< uint8_t > donner::svg::FontCatalog::loadFamilyData ( std::string_view family,
const FontFaceRequest & request ) const
overridevirtual

Encoded font-file bytes for family from the first provider that has it (Bundled before System).

Implements donner::svg::FontFamilyProvider.

◆ tryAcquireFace()

FontFaceAdmission donner::svg::FontCatalog::tryAcquireFace ( std::string_view ,
const FontFaceRequest &  ) const
overridevirtual

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

Reimplemented from donner::svg::FontFamilyProvider.


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