pub struct Database { /* private fields */ }Expand description
Manages the list of available fonts and font selection
This database exists as a singleton, accessible through the fonts
function.
After initialization font loading and alias adjustment is disabled. The reason for this is that font selection uses multiple caches and there is no mechanism for forcing fresh lookups everywhere.
Implementations§
source§impl Database
impl Database
sourcepub fn families_upper(&self) -> impl Iterator<Item = &str>
pub fn families_upper(&self) -> impl Iterator<Item = &str>
Access the list of discovered font families
All family names are uppercase.
sourcepub fn alias_keys(&self) -> impl Iterator<Item = &str>
pub fn alias_keys(&self) -> impl Iterator<Item = &str>
List all font family alias keys
All family names are uppercase.
sourcepub fn aliases_of(&self, family: &str) -> Option<impl Iterator<Item = &str>>
pub fn aliases_of(&self, family: &str) -> Option<impl Iterator<Item = &str>>
List all aliases for the given family
The family parameter must be upper case (or no matches will be found).
All returned family names are uppercase.
sourcepub fn font_family_from_alias(&self, family: &str) -> Option<String>
pub fn font_family_from_alias(&self, family: &str) -> Option<String>
Resolve the substituted font family name for this family
The input must be upper case. The output will be the loaded font’s case.
Example: SANS-SERIF
sourcepub fn add_aliases<I>(
&mut self,
family: Cow<'static, str>,
aliases: I,
mode: AddMode
)
pub fn add_aliases<I>( &mut self, family: Cow<'static, str>, aliases: I, mode: AddMode )
Add font aliases for family
When searching for family, all aliases will be searched too. Both
the family parameter and all aliases are converted to upper case.
This method may only be used before initialization; if used afterwards, only a warning will be issued.
sourcepub fn set_load_system_fonts(&mut self, load: bool)
pub fn set_load_system_fonts(&mut self, load: bool)
Control whether system fonts will be loaded on initialization
Default value: true
sourcepub fn load_font_data(&mut self, data: Vec<u8>)
pub fn load_font_data(&mut self, data: Vec<u8>)
Loads a font data into the Database.
Will load all font faces in case of a font collection.
This method may only be used before initialization; if used afterwards, only a warning will be issued. By default, system fonts are loaded on initialization.
sourcepub fn load_font_file<P>(&mut self, path: P) -> Result<(), Error>
pub fn load_font_file<P>(&mut self, path: P) -> Result<(), Error>
Loads a font file into the Database.
Will load all font faces in case of a font collection.
This method may only be used before initialization; if used afterwards, only a warning will be issued. By default, system fonts are loaded on initialization.
sourcepub fn load_fonts_dir<P>(&mut self, dir: P)
pub fn load_fonts_dir<P>(&mut self, dir: P)
Loads font files from the selected directory into the Database.
This method will scan directories recursively.
Will load ttf, otf, ttc and otc fonts.
Unlike other load_* methods, this one doesn’t return an error.
It will simply skip malformed fonts and will print a warning into the log for each of them.
This method may only be used before initialization; if used afterwards, only a warning will be issued. By default, system fonts are loaded on initialization.
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.