freya_core/style/
font_weight.rs1use freya_engine::prelude::Weight as SkWeight;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd)]
5pub struct FontWeight(i32);
6
7impl Default for FontWeight {
8 fn default() -> Self {
9 FontWeight::NORMAL
10 }
11}
12
13impl FontWeight {
14 pub const INVISIBLE: Self = Self(0);
15 pub const THIN: Self = Self(100);
16 pub const EXTRA_LIGHT: Self = Self(200);
17 pub const LIGHT: Self = Self(300);
18 pub const NORMAL: Self = Self(400);
19 pub const MEDIUM: Self = Self(500);
20 pub const SEMI_BOLD: Self = Self(600);
21 pub const BOLD: Self = Self(700);
22 pub const EXTRA_BOLD: Self = Self(800);
23 pub const BLACK: Self = Self(900);
24 pub const EXTRA_BLACK: Self = Self(1000);
25}
26
27impl From<i32> for FontWeight {
28 fn from(weight: i32) -> Self {
29 FontWeight(weight)
30 }
31}
32
33impl From<FontWeight> for SkWeight {
34 fn from(value: FontWeight) -> Self {
35 value.0.into()
36 }
37}