Skip to main content

FontProvider

Trait FontProvider 

Source
pub trait FontProvider {
    // Required methods
    fn resolve(
        &self,
        families: &[String],
        weight: u16,
        style: FontStyle,
    ) -> Option<FontData>;
    fn by_id(&self, id: &str) -> Option<FontData>;
    fn all_faces(&self) -> Vec<FontData>;
}
Expand description

Resolve font bytes by family + weight + style, or by stable id.

Implementations must never access system fonts.

Required Methods§

Source

fn resolve( &self, families: &[String], weight: u16, style: FontStyle, ) -> Option<FontData>

Resolve by a priority-ordered family list, weight, and style.

Iterates families in order. For each family:

  1. Tries exact (family, weight, style).
  2. Falls back to the same family with any weight/style (first BTreeMap entry).

Returns None only if no registered family matches any entry in families. Family comparison is case-insensitive.

Source

fn by_id(&self, id: &str) -> Option<FontData>

Resolve by the stable id recorded on a shaped run.

Source

fn all_faces(&self) -> Vec<FontData>

All registered faces, in a deterministic order (for building an SVG fontdb, etc.).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§