Struct rust_fontconfig::FcFontCache
source · pub struct FcFontCache { /* private fields */ }
Implementations§
source§impl FcFontCache
impl FcFontCache
sourcepub fn build() -> Self
pub fn build() -> Self
Builds a new font cache from all fonts discovered on the system
NOTE: Performance-intensive, should only be called on startup!
Examples found in repository?
examples/getfont.rs (line 6)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let start = Instant::now();
let cache = FcFontCache::build();
let end = Instant::now();
let start2 = Instant::now();
let results = cache.query(&FcPattern {
name: Some(String::from("Purisa")),
..Default::default()
});
let end2 = Instant::now();
println!("built cache in: {:?}", end - start);
println!("font results: {:?} - queried in {:?}", results, end2 - start2);
}
sourcepub fn list(&self) -> &BTreeMap<FcPattern, FcFontPath>
pub fn list(&self) -> &BTreeMap<FcPattern, FcFontPath>
Returns the list of fonts and font patterns
sourcepub fn query_all(&self, pattern: &FcPattern) -> Vec<&FcFontPath>
pub fn query_all(&self, pattern: &FcPattern) -> Vec<&FcFontPath>
Queries a font from the in-memory font -> file
mapping, returns all matching fonts
sourcepub fn query(&self, pattern: &FcPattern) -> Option<&FcFontPath>
pub fn query(&self, pattern: &FcPattern) -> Option<&FcFontPath>
Queries a font from the in-memory font -> file
mapping, returns the first found font (early return)
Examples found in repository?
examples/getfont.rs (lines 10-13)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let start = Instant::now();
let cache = FcFontCache::build();
let end = Instant::now();
let start2 = Instant::now();
let results = cache.query(&FcPattern {
name: Some(String::from("Purisa")),
..Default::default()
});
let end2 = Instant::now();
println!("built cache in: {:?}", end - start);
println!("font results: {:?} - queried in {:?}", results, end2 - start2);
}
Trait Implementations§
source§impl Clone for FcFontCache
impl Clone for FcFontCache
source§fn clone(&self) -> FcFontCache
fn clone(&self) -> FcFontCache
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FcFontCache
impl Debug for FcFontCache
source§impl Default for FcFontCache
impl Default for FcFontCache
source§fn default() -> FcFontCache
fn default() -> FcFontCache
Returns the “default value” for a type. Read more
source§impl Ord for FcFontCache
impl Ord for FcFontCache
source§fn cmp(&self, other: &FcFontCache) -> Ordering
fn cmp(&self, other: &FcFontCache) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for FcFontCache
impl PartialEq for FcFontCache
source§fn eq(&self, other: &FcFontCache) -> bool
fn eq(&self, other: &FcFontCache) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for FcFontCache
impl PartialOrd for FcFontCache
source§fn partial_cmp(&self, other: &FcFontCache) -> Option<Ordering>
fn partial_cmp(&self, other: &FcFontCache) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for FcFontCache
impl StructuralEq for FcFontCache
impl StructuralPartialEq for FcFontCache
Auto Trait Implementations§
impl RefUnwindSafe for FcFontCache
impl Send for FcFontCache
impl Sync for FcFontCache
impl Unpin for FcFontCache
impl UnwindSafe for FcFontCache
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
Mutably borrows from an owned value. Read more