Update some UI components to polish the frontend

This commit is contained in:
Keavon Chambers 2025-02-16 02:03:08 -08:00
parent 0004bbb14b
commit 2c88bee0ee
12 changed files with 40 additions and 23 deletions

View file

@ -6,4 +6,4 @@ pub const LAYER_OUTLINE_STROKE_WEIGHT: f64 = 1.;
// Fonts
pub const DEFAULT_FONT_FAMILY: &str = "Cabin";
pub const DEFAULT_FONT_STYLE: &str = "Normal (400)";
pub const DEFAULT_FONT_STYLE: &str = "Regular (400)";

View file

@ -7,7 +7,7 @@ use std::collections::HashMap;
pub struct Font {
#[serde(rename = "fontFamily")]
pub font_family: String,
#[serde(rename = "fontStyle")]
#[serde(rename = "fontStyle", deserialize_with = "migrate_font_style")]
pub font_style: String,
}
impl Font {
@ -73,3 +73,9 @@ impl core::hash::Hash for FontCache {
self.font_file_data.keys().for_each(|font| font.hash(state));
}
}
// TODO: Eventually remove this migration document upgrade code
fn migrate_font_style<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<String, D::Error> {
use serde::Deserialize;
String::deserialize(deserializer).map(|name| if name == "Normal (400)" { "Regular (400)".to_string() } else { name })
}