Skip to main content

FontDb

Struct FontDb 

Source
pub struct FontDb { /* private fields */ }

Implementations§

Source§

impl FontDb

Source

pub fn new() -> FontDb

Source

pub fn clear(&mut self)

fontdb_clear(): forget the scan result (the cache stays)

Source

pub fn family_count(&self) -> usize

Source

pub fn family_name(&self, i: usize) -> &str

the family’s name (“” when i is out of range)

Source

pub fn family_range(&self, i: usize) -> Range<usize> ⓘ

the indices (face(i), variations(i)) of family i’s faces (empty when out of range)

Source

pub fn family_faces(&self, i: usize) -> &[FdFace]

the faces of family i (empty when out of range)

Source

pub fn face_count(&self) -> usize

Source

pub fn face(&self, i: usize) -> Option<&FdFace>

Source

pub fn scan(&mut self, flags: u32) -> usize

fontdb_scan(flags) -> number of faces

Source

pub fn scan_dirs(&mut self, dirs: &[&str], flags: u32) -> usize

scan these folders instead of the system’s -> number of faces

Source

pub fn find( &self, family: &str, weight: u32, italic: bool, ) -> Option<(usize, u32)>

fontdb_find(family, weight, italic) -> (face index, FS_SYN_* flags to add)

Source

pub fn resolve( &self, conf: &FontConf, family: &str, lang: &str, weight: u32, italic: bool, ) -> Option<(usize, u32, String)>

the first installed candidate of conf for family in lang (generic families, substitutes, the language’s choices), else sans-serif’s -> (face index, FS_SYN_* flags, the family name found). A substitute without Latin letters (FDFF_NOLATIN) only counts when nothing else fits, except for emoji and math: fontconfig ranks the language above such a rule’s family, and Fedora’s rules put Noto Sans Arabic first in sans-serif and monospace. Another script’s characters come from fallback.rs

Source

pub fn load_resolved( &mut self, text: &mut Text, conf: &FontConf, family: &str, lang: &str, weight: u32, italic: bool, ) -> (i32, String)

resolve and load -> (font id / ERR_*, the family found)

Source

pub fn load( &mut self, text: &mut Text, family: &str, weight: u32, italic: bool, ) -> i32

fontdb_load(text, family, weight, italic) -> font id / ERR_*

Source

pub fn load_face(&mut self, text: &mut Text, fi: usize, syn: u32) -> i32

load face fi with the synthetic styles syn (FS_SYN_) -> font id / ERR_; each (face, style) once until the next scan

Source

pub fn variations(&mut self, i: usize) -> Option<&FdVar>

the axes and named instances of face i (None: not a variable face, or its file cannot be read); read from the file on first use

Source

pub fn var_values( &mut self, i: usize, weight: u32, italic: bool, size_pt: Option<f32>, axes: &[([u8; 4], f32)], ) -> Option<(Vec<f32>, u32)>

the axis values of a choice on variable face i (see the module header) -> (one value per axis, the FS_SYN_* flags still needed); None: not a variable face

Source

pub fn load_var( &mut self, text: &mut Text, fi: usize, syn: u32, weight: u32, italic: bool, size_pt: Option<f32>, axes: &[([u8; 4], f32)], ) -> i32

load variable face fi at the axis values of a choice (var_values) with the synthetic styles syn asks for that no axis gives -> font id / ERR_*; a face that is not variable: load_face(fi, syn)

Source

pub fn save_cache(&self, path: &str) -> i32

fontdb_save_cache(path) -> 0 / -1

Source

pub fn load_cache(&mut self, path: &str) -> i32

fontdb_load_cache(path) -> 0 / -1 (a malformed file is rejected as a whole)

Trait Implementations§

Source§

impl Default for FontDb

Source§

fn default() -> Self

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

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<T> ErasedDestructor for T
where T: 'static,

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, 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.