freya_core/style/
font_width.rs

1use freya_engine::prelude::Width as SkWidth;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
5pub struct FontWidth(i32);
6
7impl Default for FontWidth {
8    fn default() -> Self {
9        Self::NORMAL
10    }
11}
12
13impl FontWidth {
14    pub const ULTRA_CONDENSED: Self = Self(1);
15    pub const EXTRA_CONDENSED: Self = Self(2);
16    pub const CONDENSED: Self = Self(3);
17    pub const SEMI_CONDENSED: Self = Self(4);
18    pub const NORMAL: Self = Self(5);
19    pub const SEMI_EXPANDED: Self = Self(6);
20    pub const EXPANDED: Self = Self(7);
21    pub const EXTRA_EXPANDED: Self = Self(8);
22    pub const ULTRA_EXPANDED: Self = Self(9);
23}
24
25impl From<i32> for FontWidth {
26    fn from(weight: i32) -> Self {
27        FontWidth(weight)
28    }
29}
30
31impl From<FontWidth> for SkWidth {
32    fn from(value: FontWidth) -> Self {
33        value.0.into()
34    }
35}