feat: start fonts ingesting

This commit is contained in:
Nathan
2025-06-05 17:44:29 -06:00
parent eb59c1b50a
commit a574def706
6 changed files with 395 additions and 15 deletions

View File

@@ -0,0 +1,31 @@
const FONT_5x7_JSON: &str = include_str!("../../assets/fonts/5x7.json");
pub struct Font {
pub name: String,
pub size: f64,
pub font_json: String,
}
/// Return the embedded font JSON by string key
pub fn get_font_json(name: &str) -> Option<&'static str> {
match name {
"5x7" => Some(FONT_5x7_JSON),
_ => None,
}
}
impl Font {
pub fn new(name: &str, size: f64) -> Self {
Self {
font_json: get_font_json(name)
.unwrap_or_else(|| panic!("Unknown font: {}", name))
.to_string(),
name: name.to_string(),
size,
}
}
pub fn description(&self) -> String {
format!("{} {}", self.name, self.size)
}
}