font::ft: misc style cleanup.

This commit is contained in:
Harlan Lieberman-Berg 2017-02-28 22:20:43 -05:00 committed by Joe Wilm
parent d5342a78cd
commit 7bb89e50df
1 changed files with 12 additions and 11 deletions

View File

@ -163,9 +163,11 @@ impl FreeTypeRasterizer {
.ok_or_else(|| Error::MissingFont(desc.to_owned()))?; .ok_or_else(|| Error::MissingFont(desc.to_owned()))?;
if let (Some(path), Some(index)) = (font.file(0), font.index(0)) { if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
println!("got font path={:?}", path); println!("got font path={:?}", path);
return Ok(self.library.new_face(path, index)?); 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) fn get_rendered_glyph(&mut self, glyph_key: &GlyphKey, have_recursed: bool)
@ -235,29 +237,28 @@ impl FreeTypeRasterizer {
match fc::font_match(config, &mut pattern) { match fc::font_match(config, &mut pattern) {
Some(font) => { Some(font) => {
if let (Some(path), Some(index)) = (font.file(0), font.index(0)) { if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
match self.keys.get(&path.to_path_buf()) { match self.keys.get(&path) {
// We've previously loaded this font, so don't // We've previously loaded this font, so don't
// load it again. // load it again.
Some(&key) => { Some(&key) => {
debug!("Hit for font {:?}", path); debug!("Hit for font {:?}", path);
return Ok(key) Ok(key)
}, },
None => { None => {
debug!("Miss for font {:?}", path); debug!("Miss for font {:?}", path);
let pathbuf = path.to_path_buf(); let face = self.library.new_face(path.clone(), index)?;
let face = self.library.new_face(path, index)?;
let key = FontKey::next(); let key = FontKey::next();
self.keys.insert(pathbuf, key);
self.faces.insert(key, face); self.faces.insert(key, face);
return Ok(key) self.keys.insert(path, key);
Ok(key)
} }
} }
} }
else {
Err(Error::MissingFont( Err(Error::MissingFont(
FontDesc::new("fallback-without-path", Style::Specific(glyph.to_string())) FontDesc::new("fallback-without-path", Style::Specific(glyph.to_string()))))
)) }
}, },
None => { None => {
Err(Error::MissingFont( Err(Error::MissingFont(