Skip to main content

FontLibrary

Struct FontLibrary 

Source
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

Source

pub fn new() -> Self

Creates an empty library with no filesystem access or discovery.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn load_system_family(&mut self, family: &str) -> Result<usize>

Explicitly discovers installed fonts, indexing only the requested family.

Source

pub fn default_family(self, family: impl Into<String>) -> Self

Sets generic family aliases in a new snapshot, without font discovery.

Source

pub fn database(&self) -> &Database

Borrows the frozen parser database for SVG/formula import adapters. Mutation still requires a new FontLibrary snapshot.

Source

pub fn snapshot_id(&self) -> u64

Identity of this immutable environment for resource/layout cache keys.

Source

pub fn len(&self) -> usize

Registered face count, including collection faces.

Source

pub fn is_empty(&self) -> bool

Whether no fonts have been registered.

Source

pub fn retained_bytes(&self) -> usize

Logical retained source bytes, excluding parser and platform overhead.

Source

pub fn used_fonts(&self) -> Vec<FontIdentity>

Actual selected faces and non-cryptographic source hashes, in stable order.

Trait Implementations§

Source§

impl Clone for FontLibrary

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FontLibrary

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FontLibrary

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&FontLibrary> for FontEnvironment

Source§

fn from(fonts: &FontLibrary) -> Self

Converts to this type from the input type.
Source§

impl From<FontLibrary> for FontEnvironment

Source§

fn from(fonts: FontLibrary) -> Self

Converts to this type from the input type.
Source§

impl RefUnwindSafe for FontLibrary

Source§

impl UnwindSafe for FontLibrary

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.