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§
Sourcefn family(&mut self, family: &str) -> Vec<Typeface>
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.
Sourcefn match_character(
&mut self,
family: Option<&str>,
style: Style,
locales: &[&str],
character: char,
) -> Option<Typeface>
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.
Sourcefn system_font(&mut self, size: f32, style: Style) -> Option<Typeface>
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.
Sourcefn face_count(&self) -> usize
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.
Provided Methods§
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.
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.