pub struct FontDb { /* private fields */ }Implementations§
Source§impl FontDb
impl FontDb
pub fn new() -> FontDb
pub fn family_count(&self) -> usize
Sourcepub fn family_name(&self, i: usize) -> &str
pub fn family_name(&self, i: usize) -> &str
the family’s name (“” when i is out of range)
Sourcepub fn family_range(&self, i: usize) -> Range<usize> ⓘ
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)
Sourcepub fn family_faces(&self, i: usize) -> &[FdFace]
pub fn family_faces(&self, i: usize) -> &[FdFace]
the faces of family i (empty when out of range)
pub fn face_count(&self) -> usize
pub fn face(&self, i: usize) -> Option<&FdFace>
Sourcepub fn scan_dirs(&mut self, dirs: &[&str], flags: u32) -> usize
pub fn scan_dirs(&mut self, dirs: &[&str], flags: u32) -> usize
scan these folders instead of the system’s -> number of faces
Sourcepub fn find(
&self,
family: &str,
weight: u32,
italic: bool,
) -> Option<(usize, u32)>
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)
Sourcepub fn resolve(
&self,
conf: &FontConf,
family: &str,
lang: &str,
weight: u32,
italic: bool,
) -> Option<(usize, u32, String)>
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
Sourcepub fn load_resolved(
&mut self,
text: &mut Text,
conf: &FontConf,
family: &str,
lang: &str,
weight: u32,
italic: bool,
) -> (i32, String)
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)
Sourcepub fn load(
&mut self,
text: &mut Text,
family: &str,
weight: u32,
italic: bool,
) -> i32
pub fn load( &mut self, text: &mut Text, family: &str, weight: u32, italic: bool, ) -> i32
fontdb_load(text, family, weight, italic) -> font id / ERR_*
Sourcepub fn load_face(&mut self, text: &mut Text, fi: usize, syn: u32) -> i32
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
Sourcepub fn variations(&mut self, i: usize) -> Option<&FdVar>
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
Sourcepub fn var_values(
&mut self,
i: usize,
weight: u32,
italic: bool,
size_pt: Option<f32>,
axes: &[([u8; 4], f32)],
) -> Option<(Vec<f32>, u32)>
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
Sourcepub 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
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)
Sourcepub fn save_cache(&self, path: &str) -> i32
pub fn save_cache(&self, path: &str) -> i32
fontdb_save_cache(path) -> 0 / -1
Sourcepub fn load_cache(&mut self, path: &str) -> i32
pub fn load_cache(&mut self, path: &str) -> i32
fontdb_load_cache(path) -> 0 / -1 (a malformed file is rejected as a whole)