pub struct BytesFontProvider { /* private fields */ }Expand description
In-memory font registry. Register bundled and project fonts up front; this implementation never scans the system.
Two BTreeMaps are maintained:
by_key:(family_lower, weight, style) -> FontDataforresolve.by_id:id -> FontDataforby_id.
Implementations§
Source§impl BytesFontProvider
impl BytesFontProvider
Sourcepub fn register(
&mut self,
family: &str,
weight: u16,
style: FontStyle,
bytes: Arc<[u8]>,
index: u32,
source: FontSource,
) -> String
pub fn register( &mut self, family: &str, weight: u16, style: FontStyle, bytes: Arc<[u8]>, index: u32, source: FontSource, ) -> String
Register a font face and return its stable id.
The id is computed as "{family_kebab_lower}-{weight}-{style_lower}",
e.g. "noto-sans-400-normal". If the same face is registered more than
once, the most recent registration wins and reuses the original id.
Because kebab-casing can collapse distinct families (e.g. "My Font"
and "my-font") onto the same base id, a numeric suffix is appended
when the base id is already taken by a different face, so every
registered face keeps a unique id. Returns the assigned stable id as a
convenience; callers may register purely for the side effect.
source records the provenance of the face (FontSource); it is
carried on the resolved FontData so the compile stage can emit a
font.local advisory when a face resolves from the local system.
Sourcepub fn available_families(&self) -> Vec<String>
pub fn available_families(&self) -> Vec<String>
Return the lowercase family names of all registered faces (deduplicated, sorted).