font_fallbacks.rs

 1use std::sync::Arc;
 2
 3use schemars::JsonSchema;
 4use serde::{Deserialize, Serialize};
 5
 6/// The fallback fonts that can be configured for a given font.
 7/// Fallback fonts family names are stored here.
 8#[derive(Default, Clone, Eq, PartialEq, Hash, Debug, Deserialize, Serialize, JsonSchema)]
 9pub struct FontFallbacks(pub Arc<Vec<String>>);
10
11impl FontFallbacks {
12    /// Get the fallback fonts family names
13    pub fn fallback_list(&self) -> &[String] {
14        self.0.as_slice()
15    }
16
17    /// Create a font fallback from a list of strings
18    pub fn from_fonts(fonts: Vec<String>) -> Self {
19        FontFallbacks(Arc::new(fonts))
20    }
21}