summaryrefslogtreecommitdiffstats
path: root/core/src/text.rs
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2022-12-22 12:19:59 +0100
committerMinijackson <minijackson@riseup.net>2022-12-22 12:19:59 +0100
commit92a02c34628343153b33602eae00cef46e28d191 (patch)
tree8622ec528d24e456be22d984d93aa9bcafc97399 /core/src/text.rs
downloaddiaphragm-92a02c34628343153b33602eae00cef46e28d191.tar.gz
diaphragm-92a02c34628343153b33602eae00cef46e28d191.zip
WIP
Diffstat (limited to 'core/src/text.rs')
-rw-r--r--core/src/text.rs81
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 @@
1use super::types::Float;
2
3#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
4#[non_exhaustive]
5pub enum FontStyle {
6 Normal,
7 Oblique,
8 Italic,
9}
10
11impl 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]
19pub enum FontVariant {
20 Normal,
21 SmallCaps,
22}
23
24impl 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]
32pub 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
47impl Default for FontWeight {
48 fn default() -> Self {
49 Self::Normal
50 }
51}
52
53#[derive(Clone, Debug)]
54pub 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)]
64pub struct DefinedFontDescription {
65 pub family: String,
66 pub style: FontStyle,
67 pub weight: FontWeight,
68 pub size: f64,
69}
70
71#[derive(Clone, Debug)]
72pub struct Text {
73 pub content: String,
74 pub font: FontDescription,
75}
76
77#[derive(Clone, Debug)]
78pub struct DefinedText {
79 pub content: String,
80 pub font: DefinedFontDescription,
81}