1use std::hash::Hash;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
6pub struct Font {
7 pub family: Family,
9 pub weight: Weight,
11 pub stretch: Stretch,
13 pub style: Style,
15}
16
17impl Font {
18 pub const DEFAULT: Font = Font {
20 family: Family::SansSerif,
21 weight: Weight::Normal,
22 stretch: Stretch::Normal,
23 style: Style::Normal,
24 };
25
26 pub const MONOSPACE: Font = Font {
28 family: Family::Monospace,
29 ..Self::DEFAULT
30 };
31
32 pub const fn with_name(name: &'static str) -> Self {
35 Font {
36 family: Family::Name(name),
37 ..Self::DEFAULT
38 }
39 }
40}
41
42#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
44pub enum Family {
45 Name(&'static str),
47
48 Serif,
50
51 #[default]
55 SansSerif,
56
57 Cursive,
61
62 Fantasy,
65
66 Monospace,
69}
70
71#[allow(missing_docs)]
73#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
74#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
75pub enum Weight {
76 Thin,
77 ExtraLight,
78 Light,
79 #[default]
80 Normal,
81 Medium,
82 Semibold,
83 Bold,
84 ExtraBold,
85 Black,
86}
87
88#[allow(missing_docs)]
90#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
91#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
92pub enum Stretch {
93 UltraCondensed,
94 ExtraCondensed,
95 Condensed,
96 SemiCondensed,
97 #[default]
98 Normal,
99 SemiExpanded,
100 Expanded,
101 ExtraExpanded,
102 UltraExpanded,
103}
104
105#[allow(missing_docs)]
107#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
108#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
109pub enum Style {
110 #[default]
111 Normal,
112 Italic,
113 Oblique,
114}