acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
font_weight.h
1// Created by camilo on 2023-06-28 19:47 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5namespace write_text
6{
7
8
9 class font_weight
10 {
11 protected:
12
13
14 enum_font_weight m_efontweight;
17
18
19 public:
20
21
22 font_weight() :
23 m_efontweight(e_font_weight_normal),
24 m_iFontWeight(e_font_weight_normal)
25 {
26
27
28 }
29
30
31 font_weight(enum_font_weight efontweight) :
32 m_efontweight(efontweight),
33 m_iFontWeight(efontweight)
34 {
35
36 }
37
38
39 font_weight(::i32 iFontWeight)
40 {
41
42 set_font_weight(iFontWeight);
43
44 }
45
46
47 constexpr static enum_font_weight sink(::i32 iFontWeight)
48 {
49
50 if (iFontWeight <= 0)
51 {
52
53 return e_font_weight_dont_care;
54
55 }
56 else if (iFontWeight <= 150)
57 {
58
59 return e_font_weight_thin;
60
61 }
62 else if (iFontWeight <= 250)
63 {
64
65 return e_font_weight_extra_light;
66
67 }
68 else if (iFontWeight <= 325)
69 {
70
71 return e_font_weight_light;
72
73 }
74 else if (iFontWeight <= 375)
75 {
76
77 return e_font_weight_semi_light;
78
79 }
80 else if (iFontWeight <= 450)
81 {
82
83 return e_font_weight_normal;
84
85 }
86 else if (iFontWeight <= 550)
87 {
88
89 return e_font_weight_medium;
90
91 }
92 else if (iFontWeight <= 650)
93 {
94
95 return e_font_weight_semibold;
96
97 }
98 else if (iFontWeight <= 750)
99 {
100
101 return e_font_weight_bold;
102
103 }
104 else if (iFontWeight <= 850)
105 {
106
107 return e_font_weight_extra_bold;
108
109 }
110 else if (iFontWeight <= 925)
111 {
112
113 return e_font_weight_heavy;
114
115 }
116 else
117 {
118
119 return e_font_weight_ultra_black;
120
121 }
122
123 }
124
125
126 constexpr enum_font_weight efontweight() const { return m_efontweight; }
127 constexpr ::i32 as_i32() const { return m_iFontWeight; }
128
129
130 constexpr operator enum_font_weight() const { return efontweight(); }
131 constexpr operator ::i32() const { return as_i32(); }
132
133
134 constexpr ::std::weak_ordering operator <=>(const enum_font_weight efontweight) const
135 {
136
137 if (m_iFontWeight > 0)
138 {
139
140 return sink(m_iFontWeight) <=> efontweight;
141
142 }
143 else
144 {
145
146 return m_efontweight <=> efontweight;
147
148 }
149
150 }
151
152
153 template < prototype_integral INTEGRAL >
154 constexpr ::std::strong_ordering operator <=>(const INTEGRAL iFontWeight) const
155 {
156
157 return m_iFontWeight <=> iFontWeight;
158
159 }
160
161
162 template < prototype_integral INTEGRAL >
163 void set_font_weight(INTEGRAL iFontWeight)
164 {
165
166 m_efontweight = sink(iFontWeight);
167 m_iFontWeight = maximum(minimum(I16_MAXIMUM, iFontWeight), -1);
168
169 }
170
171
172 font_weight & operator = (enum_font_weight efontweight)
173 {
174
175 m_efontweight = efontweight;
176 m_iFontWeight = efontweight;
177
178 return *this;
179
180 }
181
182
183 template < prototype_integral INTEGRAL >
184 font_weight & operator = (INTEGRAL iFontWeight)
185 {
186
187 set_font_weight(iFontWeight);
188
189 return *this;
190
191 }
192
193 };
194
195
196} // namespace write_text
197
198
199
Definition font_weight.h:10
::i16 m_iFontWeight
m_iFontWeight maybe "fraction" of a font weight
Definition font_weight.h:16