diff options
Diffstat (limited to 'core/src/text.rs')
-rw-r--r-- | core/src/text.rs | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/core/src/text.rs b/core/src/text.rs new file mode 100644 index 0000000..3110030 --- /dev/null +++ b/core/src/text.rs | |||
@@ -0,0 +1,81 @@ | |||
1 | use super::types::Float; | ||
2 | |||
3 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] | ||
4 | #[non_exhaustive] | ||
5 | pub enum FontStyle { | ||
6 | Normal, | ||
7 | Oblique, | ||
8 | Italic, | ||
9 | } | ||
10 | |||
11 | impl Default for FontStyle { | ||
12 | fn default() -> Self { | ||
13 | Self::Normal | ||
14 | } | ||
15 | } | ||
16 | |||
17 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] | ||
18 | #[non_exhaustive] | ||
19 | pub enum FontVariant { | ||
20 | Normal, | ||
21 | SmallCaps, | ||
22 | } | ||
23 | |||
24 | impl Default for FontVariant { | ||
25 | fn default() -> Self { | ||
26 | Self::Normal | ||
27 | } | ||
28 | } | ||
29 | |||
30 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] | ||
31 | #[non_exhaustive] | ||
32 | pub enum FontWeight { | ||
33 | Thin, | ||
34 | Ultralight, | ||
35 | Light, | ||
36 | Semilight, | ||
37 | Book, | ||
38 | Normal, | ||
39 | Medium, | ||
40 | Semibold, | ||
41 | Bold, | ||
42 | Ultrabold, | ||
43 | Heavy, | ||
44 | Ultraheavy, | ||
45 | } | ||
46 | |||
47 | impl Default for FontWeight { | ||
48 | fn default() -> Self { | ||
49 | Self::Normal | ||
50 | } | ||
51 | } | ||
52 | |||
53 | #[derive(Clone, Debug)] | ||
54 | pub struct FontDescription { | ||
55 | pub family: String, | ||
56 | pub style: FontStyle, | ||
57 | pub weight: FontWeight, | ||
58 | // TODO: handles weirdly with bounds that specifies both top and bottom | ||
59 | pub size: Float, | ||
60 | } | ||
61 | |||
62 | // TODO: automate creation of Defined* structs | ||
63 | #[derive(Clone, Debug)] | ||
64 | pub struct DefinedFontDescription { | ||
65 | pub family: String, | ||
66 | pub style: FontStyle, | ||
67 | pub weight: FontWeight, | ||
68 | pub size: f64, | ||
69 | } | ||
70 | |||
71 | #[derive(Clone, Debug)] | ||
72 | pub struct Text { | ||
73 | pub content: String, | ||
74 | pub font: FontDescription, | ||
75 | } | ||
76 | |||
77 | #[derive(Clone, Debug)] | ||
78 | pub struct DefinedText { | ||
79 | pub content: String, | ||
80 | pub font: DefinedFontDescription, | ||
81 | } | ||