summaryrefslogtreecommitdiffstats
path: root/font
diff options
context:
space:
mode:
authorHarlan Lieberman-Berg <hlieberman@setec.io>2017-02-28 22:20:43 -0500
committerJoe Wilm <jwilm@users.noreply.github.com>2017-03-01 22:07:14 -0800
commit7bb89e50dfc473bd318907be6ba89a98fbe27303 (patch)
tree96eeccdd64dae652bfcf7d7a811423dc54720c3d /font
parentd5342a78cdec733451af7970fb6f2ae3106b1884 (diff)
font::ft: misc style cleanup.
Diffstat (limited to 'font')
-rw-r--r--font/src/ft/mod.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index b751cdcf..a199f1cb 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -163,9 +163,11 @@ impl FreeTypeRasterizer {
.ok_or_else(|| Error::MissingFont(desc.to_owned()))?;
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)?);
+ 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)
@@ -235,29 +237,28 @@ impl FreeTypeRasterizer {
match fc::font_match(config, &mut pattern) {
Some(font) => {
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
// load it again.
Some(&key) => {
debug!("Hit for font {:?}", path);
- return Ok(key)
+ Ok(key)
},
None => {
debug!("Miss for font {:?}", path);
- let pathbuf = path.to_path_buf();
- let face = self.library.new_face(path, index)?;
+ let face = self.library.new_face(path.clone(), index)?;
let key = FontKey::next();
- self.keys.insert(pathbuf, key);
self.faces.insert(key, face);
- return Ok(key)
+ self.keys.insert(path, key);
+ Ok(key)
}
}
}
-
+ else {
Err(Error::MissingFont(
- FontDesc::new("fallback-without-path", Style::Specific(glyph.to_string()))
- ))
+ FontDesc::new("fallback-without-path", Style::Specific(glyph.to_string()))))
+ }
},
None => {
Err(Error::MissingFont(