freya_core/style/
font_width.rs1use 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 pub fn get(self) -> i32 {
25 self.0
26 }
27}
28
29impl From<i32> for FontWidth {
30 fn from(width: i32) -> Self {
31 FontWidth(width)
32 }
33}
34
35impl From<FontWidth> for i32 {
36 fn from(width: FontWidth) -> i32 {
37 width.0
38 }
39}
40
41impl From<FontWidth> for f32 {
42 fn from(width: FontWidth) -> f32 {
43 width.0 as f32
44 }
45}
46
47impl From<FontWidth> for SkWidth {
48 fn from(value: FontWidth) -> Self {
49 value.0.into()
50 }
51}