Skip to main content

FontManager

Trait FontManager 

Source
pub trait FontManager: Send {
    // Required methods
    fn family(&mut self, family: &str) -> Vec<Typeface>;
    fn match_character(
        &mut self,
        family: Option<&str>,
        style: Style,
        locales: &[&str],
        character: char,
    ) -> Option<Typeface>;
    fn system_font(&mut self, size: f32, style: Style) -> Option<Typeface>;
    fn families(&self) -> Vec<String>;
    fn face_count(&self) -> usize;
    fn watch(&mut self, on_change: Box<dyn Fn() + Sync + Send>) -> Option<Watch>;

    // Provided method
    fn match_family_style(
        &mut self,
        family: &str,
        style: Style,
    ) -> Option<Typeface> { ... }
}
Expand description

FontManager is the platform’s font lookup, in the shape of Skia’s SkFontMgr.

Answers are typefaces the caller parses; nothing is shaped or rasterised here. A manager may read font files lazily and cache them, hence &mut self.

Required Methods§

Source

fn family(&mut self, family: &str) -> Vec<Typeface>

family returns every face the platform has under family; empty for a family it does not know. Names compare the way the platform compares them.

Source

fn match_character( &mut self, family: Option<&str>, style: Style, locales: &[&str], character: char, ) -> Option<Typeface>

match_character returns a face that covers character, Skia’s matchFamilyStyleCharacter: preferring the languages in locales (BCP 47, most preferred first), then family, then style. None when nothing installed covers it.

Source

fn system_font(&mut self, size: f32, style: Style) -> Option<Typeface>

system_font returns the platform’s own user-interface face for text at size (in points) nearest style: what a program means by “the system font”. None where the platform has no such notion.

Source

fn families(&self) -> Vec<String>

families lists the installed family names.

Source

fn face_count(&self) -> usize

face_count is how many installed faces the platform reports; 0 means the manager found nothing and every answer will be empty.

Source

fn watch(&mut self, on_change: Box<dyn Fn() + Sync + Send>) -> Option<Watch>

watch calls on_change whenever the installed fonts change, from whichever thread the platform reports on, for as long as the returned Watch lives. None where the platform cannot say.

Provided Methods§

Source

fn match_family_style(&mut self, family: &str, style: Style) -> Option<Typeface>

match_family_style returns the family’s face nearest style, Skia’s matchFamilyStyle.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<M> FontManager for Box<M>
where M: FontManager + ?Sized,

A boxed manager is a manager, as std makes a Box<W: Write + ?Sized> a writer: what platform answers can go wherever a FontManager is expected, behind a lock shared by several users among them.

Source§

fn family(&mut self, family: &str) -> Vec<Typeface>

Source§

fn match_family_style(&mut self, family: &str, style: Style) -> Option<Typeface>

Source§

fn match_character( &mut self, family: Option<&str>, style: Style, locales: &[&str], character: char, ) -> Option<Typeface>

Source§

fn system_font(&mut self, size: f32, style: Style) -> Option<Typeface>

Source§

fn families(&self) -> Vec<String>

Source§

fn face_count(&self) -> usize

Source§

fn watch(&mut self, on_change: Box<dyn Fn() + Sync + Send>) -> Option<Watch>

Implementors§