diff --git a/src/font/loader/font_config.rs b/src/font/loader/font_config.rs index 92060918c..b9179dd8c 100644 --- a/src/font/loader/font_config.rs +++ b/src/font/loader/font_config.rs @@ -1,17 +1,19 @@ use crate::config::FontAttributes; +use crate::font::fcwrap; use crate::font::loader::{FontDataHandle, FontLocator}; use failure::Fallible; +use fcwrap::Pattern as FontPattern; /// A FontLocator implemented using the system font loading /// functions provided by font-config pub struct FontConfigFontLocator {} -impl FontLocator for FontLoaderFontLocator { +impl FontLocator for FontConfigFontLocator { fn load_fonts(&self, fonts_selection: &[FontAttributes]) -> Fallible> { let mut fonts = vec![]; let mut fallback = vec![]; - for attr in style.font_with_fallback() { + for attr in fonts_selection { let mut pattern = FontPattern::new()?; pattern.family(&attr.family)?; if attr.bold { @@ -45,14 +47,14 @@ impl FontLocator for FontLoaderFontLocator { // The additional items in this loop are fallback fonts // suggested by fontconfig and are lower precedence if idx == 0 { - self.fonts.push(handle); + fonts.push(handle); } else { - self.fallback.push(handle); + fallback.push(handle); } } } - fonts.extend_from_slice(&mut fallback); + fonts.append(&mut fallback); Ok(fonts) }