Skip to main content

register_generic_fallback

Function register_generic_fallback 

Source
pub fn register_generic_fallback(data: Vec<u8>, generics: &[GenericSlot])
Expand description

Registers data (raw font bytes) as a fallback face for each generic family slot in generics, applied to every TextContext — existing, on its next TextContext::sync_app_fonts, and future, seeded for free by TextContext::new — via fontique::Collection::append_generic_families.

§Why this exists

TextContext::new builds parley::FontContext::new()’s fontique collection with the platform’s real system-font backend on every target except wasm32-unknown-unknown, where fontique falls back to a dummy backend whose generic-family map is empty: crate::FontFamily::SystemUi (this crate’s default family) and any bare GenericSlot then resolve to nothing and shape zero glyph runs. This function is the seam a host (a shell) calls once at startup with a bundled face to give a generic slot something to resolve to on that target; a platform whose backend already populates the generic map is unaffected unless it opts in too, since the registered face is only ever appended — never a replacement.

A stack that names a concrete family (crate::FontFamily::Named/crate::FontFamily::NamedWithGeneric, registered via TextContext::register_fonts) still resolves before a generic fallback, since a named lookup is always tried first.

No-op (records nothing) when generics is empty. Bytes fontique cannot parse into any face register zero families when eventually applied, so this is a harmless no-op then too — the same “no error surface” contract TextContext::sync_app_fonts already follows for app fonts.