Skip to content

Commit

Permalink
Switch over to using font_match everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
hlieberman authored and jwilm committed Mar 2, 2017
1 parent 50f27af commit 6ed7d99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion font/src/ft/list_fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub mod fc {
}

/// Find the font closest matching the provided pattern.
#[allow(dead_code)]
pub fn font_match(
config: &ConfigRef,
pattern: &mut PatternRef,
Expand All @@ -90,6 +89,7 @@ pub mod fc {
}

/// list fonts by closeness to the pattern
#[allow(dead_code)]
pub fn font_sort(
config: &ConfigRef,
pattern: &mut PatternRef,
Expand Down
12 changes: 4 additions & 8 deletions font/src/ft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,11 @@ impl FreeTypeRasterizer {
pattern.set_weight(weight.into_fontconfig_type());
pattern.set_slant(slant.into_fontconfig_type());

let fonts = fc::font_sort(fc::Config::get_current(), &mut pattern)
let font = fc::font_match(fc::Config::get_current(), &mut pattern)
.ok_or_else(|| Error::MissingFont(desc.to_owned()))?;

// Take first font that has a path
for font in &fonts {
if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
return Ok(self.library.new_face(path, index)?);
}
if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
return Ok(self.library.new_face(path, index)?);
}

Err(Error::MissingFont(desc.to_owned()))
Expand All @@ -167,9 +164,8 @@ impl FreeTypeRasterizer {
if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
println!("got font path={:?}", path);
return Ok(self.library.new_face(path, index)?);
} else {
Err(Error::MissingFont(desc.to_owned()))
}
Err(Error::MissingFont(desc.to_owned()))
}

fn get_rendered_glyph(&mut self, glyph_key: &GlyphKey, have_recursed: bool)
Expand Down

0 comments on commit 6ed7d99

Please sign in to comment.