config: Add default for font map

This commit is contained in:
Kenny Levinsen
2020-06-14 17:01:42 +02:00
parent 24ec63a178
commit 376a6f215b
+10 -6
View File
@@ -246,6 +246,13 @@ impl Default for OutputMode {
} }
} }
fn default_fonts() -> HashMap<String, String> {
let mut map = HashMap::with_capacity(2);
map.insert("mono".to_string(), "mono".to_string());
map.insert("sans".to_string(), "sans".to_string());
map
}
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Config { pub struct Config {
@@ -253,6 +260,8 @@ pub struct Config {
pub scale: u32, pub scale: u32,
pub background: Color, pub background: Color,
pub widget: Widget, pub widget: Widget,
#[serde(default = "default_fonts")]
pub fonts: HashMap<String, String>, pub fonts: HashMap<String, String>,
} }
@@ -324,12 +333,7 @@ impl Default for Config {
output_mode: Default::default(), output_mode: Default::default(),
scale: 1, scale: 1,
background: Color::new(0.0, 0.0, 0.0, 0.9), background: Color::new(0.0, 0.0, 0.0, 0.9),
fonts: { fonts: default_fonts(),
let mut map = HashMap::with_capacity(2);
map.insert("mono".to_string(), "mono".to_string());
map.insert("sans".to_string(), "sans".to_string());
map
},
} }
} }
} }