1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
use std::fmt::{self, Debug, Display, Formatter};
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Properties {
pub style: Style,
pub weight: Weight,
pub stretch: Stretch,
}
impl Properties {
#[inline]
pub fn new() -> Properties {
Properties::default()
}
#[inline]
pub fn style(&mut self, style: Style) -> &mut Properties {
self.style = style;
self
}
#[inline]
pub fn weight(&mut self, weight: Weight) -> &mut Properties {
self.weight = weight;
self
}
#[inline]
pub fn stretch(&mut self, stretch: Stretch) -> &mut Properties {
self.stretch = stretch;
self
}
}
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Style {
Normal,
Italic,
Oblique,
}
impl Default for Style {
fn default() -> Style {
Style::Normal
}
}
impl Display for Style {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
Debug::fmt(self, f)
}
}
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
pub struct Weight(pub f32);
impl Default for Weight {
#[inline]
fn default() -> Weight {
Weight::NORMAL
}
}
impl Weight {
pub const THIN: Weight = Weight(100.0);
pub const EXTRA_LIGHT: Weight = Weight(200.0);
pub const LIGHT: Weight = Weight(300.0);
pub const NORMAL: Weight = Weight(400.0);
pub const MEDIUM: Weight = Weight(500.0);
pub const SEMIBOLD: Weight = Weight(600.0);
pub const BOLD: Weight = Weight(700.0);
pub const EXTRA_BOLD: Weight = Weight(800.0);
pub const BLACK: Weight = Weight(900.0);
}
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
pub struct Stretch(pub f32);
impl Default for Stretch {
#[inline]
fn default() -> Stretch {
Stretch::NORMAL
}
}
impl Stretch {
pub const ULTRA_CONDENSED: Stretch = Stretch(0.5);
pub const EXTRA_CONDENSED: Stretch = Stretch(0.625);
pub const CONDENSED: Stretch = Stretch(0.75);
pub const SEMI_CONDENSED: Stretch = Stretch(0.875);
pub const NORMAL: Stretch = Stretch(1.0);
pub const SEMI_EXPANDED: Stretch = Stretch(1.125);
pub const EXPANDED: Stretch = Stretch(1.25);
pub const EXTRA_EXPANDED: Stretch = Stretch(1.5);
pub const ULTRA_EXPANDED: Stretch = Stretch(2.0);
pub(crate) const MAPPING: [f32; 9] = [
Stretch::ULTRA_CONDENSED.0,
Stretch::EXTRA_CONDENSED.0,
Stretch::CONDENSED.0,
Stretch::SEMI_CONDENSED.0,
Stretch::NORMAL.0,
Stretch::SEMI_EXPANDED.0,
Stretch::EXPANDED.0,
Stretch::EXTRA_EXPANDED.0,
Stretch::ULTRA_EXPANDED.0,
];
}