freya_core/style/
font_size.rs

1use std::ops::Deref;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Hash, Debug, PartialEq, Clone, Copy)]
5pub struct FontSize(i32);
6
7impl Default for FontSize {
8    fn default() -> Self {
9        FontSize(16)
10    }
11}
12
13impl From<i32> for FontSize {
14    fn from(value: i32) -> Self {
15        FontSize(value)
16    }
17}
18
19impl From<f32> for FontSize {
20    fn from(value: f32) -> Self {
21        FontSize(value as i32)
22    }
23}
24
25impl From<FontSize> for f32 {
26    fn from(value: FontSize) -> Self {
27        value.0 as f32
28    }
29}
30
31impl Deref for FontSize {
32    type Target = i32;
33    fn deref(&self) -> &Self::Target {
34        &self.0
35    }
36}