More better

This commit is contained in:
Kenny Levinsen
2023-02-08 22:53:41 +01:00
parent 3c69a31030
commit 6e90b1f0e8
19 changed files with 681 additions and 511 deletions
+9 -11
View File
@@ -3,15 +3,7 @@
use crate::draw;
use rusttype::Font;
use std::{
cell::RefCell,
collections::HashMap,
fs::File,
hash,
io::Read,
mem,
path::Path,
rc::Rc,
thread,
cell::RefCell, collections::HashMap, fs::File, hash, io::Read, mem, path::Path, rc::Rc, thread,
};
/// FontRef is used to store Fonts on widgets.
@@ -24,7 +16,12 @@ mod fc {
/// Given a string, it matches it to a font file and returns its path.
pub(crate) fn from_string(name: &str) -> String {
let fc = FontConfig::new().unwrap();
fc.find(name, None).unwrap().path.to_str().unwrap().to_string()
fc.find(name, None)
.unwrap()
.path
.to_str()
.unwrap()
.to_string()
}
}
@@ -98,7 +95,8 @@ impl FontMap {
match self.required_fonts.get_mut(font_name) {
Some(v) => v.1.push((size, preload)),
None => {
self.required_fonts.insert(font_name, (font_name, vec![(size, preload)]));
self.required_fonts
.insert(font_name, (font_name, vec![(size, preload)]));
}
}
}