pub struct FontLibrary { /* private fields */ }Expand description
A copy-on-write font database. Construction never discovers system fonts. Registered source bytes are retained; cloned libraries share snapshots.
Implementations§
Source§impl FontLibrary
impl FontLibrary
Sourcepub fn load_file(
&mut self,
path: impl AsRef<Path>,
) -> Result<Vec<FontIdentifier>>
pub fn load_file( &mut self, path: impl AsRef<Path>, ) -> Result<Vec<FontIdentifier>>
Loads one explicit font file into immutable memory, never a lazy file source.
Sourcepub fn load_data(&mut self, data: Arc<[u8]>) -> Result<Vec<FontIdentifier>>
pub fn load_data(&mut self, data: Arc<[u8]>) -> Result<Vec<FontIdentifier>>
Registers bounded in-memory OpenType/TrueType data atomically, including collections and color fonts. At most 4096 faces / 256 MiB are admitted.
Sourcepub fn load_dir(&mut self, directory: impl AsRef<Path>) -> Result<usize>
pub fn load_dir(&mut self, directory: impl AsRef<Path>) -> Result<usize>
Loads a sorted project directory tree atomically; symlink directories are not followed. At most 4096 entries are visited, independent of face count.
Sourcepub fn load_system_fonts(&mut self) -> Result<usize>
pub fn load_system_fonts(&mut self) -> Result<usize>
Explicitly indexes installed font metadata without retaining every file. Font discovery still performs I/O; bytes are loaded on first use.
Sourcepub fn load_system_family(&mut self, family: &str) -> Result<usize>
pub fn load_system_family(&mut self, family: &str) -> Result<usize>
Explicitly discovers installed fonts, indexing only the requested family.
Sourcepub fn default_family(self, family: impl Into<String>) -> Self
pub fn default_family(self, family: impl Into<String>) -> Self
Sets generic family aliases in a new snapshot, without font discovery.
Sourcepub fn database(&self) -> &Database
pub fn database(&self) -> &Database
Borrows the frozen parser database for SVG/formula import adapters. Mutation still requires a new FontLibrary snapshot.
Sourcepub fn snapshot_id(&self) -> u64
pub fn snapshot_id(&self) -> u64
Identity of this immutable environment for resource/layout cache keys.
Sourcepub fn retained_bytes(&self) -> usize
pub fn retained_bytes(&self) -> usize
Logical retained source bytes, excluding parser and platform overhead.
Sourcepub fn used_fonts(&self) -> Vec<FontIdentity>
pub fn used_fonts(&self) -> Vec<FontIdentity>
Actual selected faces and non-cryptographic source hashes, in stable order.