Skip to main content

gpui/text_system/
font_fallbacks.rs

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