freya_core/style/
font_width.rs1use freya_engine::prelude::Width as SkWidth;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
13pub struct FontWidth(i32);
14
15impl Default for FontWidth {
16 fn default() -> Self {
17 Self::NORMAL
18 }
19}
20
21impl FontWidth {
22 pub const ULTRA_CONDENSED: Self = Self(1);
23 pub const EXTRA_CONDENSED: Self = Self(2);
24 pub const CONDENSED: Self = Self(3);
25 pub const SEMI_CONDENSED: Self = Self(4);
26 pub const NORMAL: Self = Self(5);
27 pub const SEMI_EXPANDED: Self = Self(6);
28 pub const EXPANDED: Self = Self(7);
29 pub const EXTRA_EXPANDED: Self = Self(8);
30 pub const ULTRA_EXPANDED: Self = Self(9);
31
32 pub fn get(self) -> i32 {
33 self.0
34 }
35}
36
37impl From<i32> for FontWidth {
38 fn from(width: i32) -> Self {
39 FontWidth(width)
40 }
41}
42
43impl From<FontWidth> for i32 {
44 fn from(width: FontWidth) -> i32 {
45 width.0
46 }
47}
48
49impl From<FontWidth> for f32 {
50 fn from(width: FontWidth) -> f32 {
51 width.0 as f32
52 }
53}
54
55impl From<FontWidth> for SkWidth {
56 fn from(value: FontWidth) -> Self {
57 value.0.into()
58 }
59}