freya_core/style/
font_weight.rs1use freya_engine::prelude::Weight as SkWeight;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd)]
13pub struct FontWeight(i32);
14
15impl Default for FontWeight {
16 fn default() -> Self {
17 FontWeight::NORMAL
18 }
19}
20
21impl FontWeight {
22 pub const INVISIBLE: Self = Self(0);
23 pub const THIN: Self = Self(100);
24 pub const EXTRA_LIGHT: Self = Self(200);
25 pub const LIGHT: Self = Self(300);
26 pub const NORMAL: Self = Self(400);
27 pub const MEDIUM: Self = Self(500);
28 pub const SEMI_BOLD: Self = Self(600);
29 pub const BOLD: Self = Self(700);
30 pub const EXTRA_BOLD: Self = Self(800);
31 pub const BLACK: Self = Self(900);
32 pub const EXTRA_BLACK: Self = Self(1000);
33}
34
35impl From<i32> for FontWeight {
36 fn from(weight: i32) -> Self {
37 FontWeight(weight)
38 }
39}
40
41impl From<FontWeight> for i32 {
42 fn from(weight: FontWeight) -> i32 {
43 weight.0
44 }
45}
46
47impl From<FontWeight> for f32 {
48 fn from(weight: FontWeight) -> f32 {
49 weight.0 as f32
50 }
51}
52
53impl From<FontWeight> for SkWeight {
54 fn from(value: FontWeight) -> Self {
55 value.0.into()
56 }
57}