Skip to content

Commit f0a33ad

Browse files
committed
cleanup font
1 parent 1910b9c commit f0a33ad

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed

ui/numeric_popup.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace menu {
142142
klib::vector2i{
143143
(240 / 2) -
144144
static_cast<int32_t>(
145-
(klib::string::strlen(str) * screen_base::large_font::width) / 2
145+
(klib::string::strlen(str) * screen_base::large_text::font::width) / 2
146146
), 2
147147
} - offset.cast<int32_t>(),
148148
klib::graphics::white
@@ -155,8 +155,8 @@ namespace menu {
155155
klib::vector2i{
156156
(240 / 2) -
157157
static_cast<int32_t>(
158-
(klib::string::strlen(buffer) * screen_base::large_font::width) / 2
159-
), (134 / 2) - (screen_base::large_font::height / 2)
158+
(klib::string::strlen(buffer) * screen_base::large_text::font::width) / 2
159+
), (134 / 2) - (screen_base::large_text::font::height / 2)
160160
} - offset.cast<int32_t>(),
161161
klib::graphics::white
162162
);

ui/screen.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,19 @@ namespace menu {
7676
*/
7777
template <typename FrameBuffer>
7878
class screen {
79+
private:
80+
// fonts used in the string functions
81+
using small_font = klib::graphics::ascii_font_8x8;
82+
using large_font = klib::graphics::ascii_font_16x16;
83+
7984
protected:
8085
// Screen queue. Allows up for 8 screens deep
8186
static inline screen_buffer<8> buffer = {};
8287

8388
// small text for in the screens
84-
using small_font = klib::graphics::ascii_font_8x8;
8589
using small_text = klib::graphics::string<small_font>;
8690

8791
// large text for in the screens
88-
using large_font = klib::graphics::ascii_font_16x16;
8992
using large_text = klib::graphics::string<large_font>;
9093

9194
/**

ui/splash.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,17 @@ namespace menu {
112112
klib::vector2i{95, 34} - offset.cast<int32_t>()
113113
);
114114

115+
// url to show
116+
constexpr static char url[] = "koon.io";
117+
115118
// draw using the small font
116119
screen_base::small_text::template draw<FrameBuffer>(
117-
frame_buffer,
118-
"koon.io",
119-
klib::vector2i{240 - (7 * screen_base::small_font::width), 120} - offset.cast<int32_t>(),
120+
frame_buffer, url,
121+
klib::vector2i{
122+
240 - (
123+
klib::string::strlen(url) * screen_base::small_text::font::width
124+
), 120
125+
} - offset.cast<int32_t>(),
120126
klib::graphics::white
121127
);
122128
}

ui/totp.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,56 +203,56 @@ namespace menu {
203203
// draw the entry text with a small font above the token if we have any
204204
if (klib::string::strlen(entries[current].str)) {
205205
// draw the current token using the large font
206-
screen<FrameBuffer>::small_text::template draw<FrameBuffer>(
206+
screen_base::small_text::template draw<FrameBuffer>(
207207
frame_buffer,
208208
"profile",
209209
klib::vector2i{3, 3} - offset.cast<int32_t>(),
210210
klib::graphics::white
211211
);
212212

213213
// draw the current token using the large font
214-
screen<FrameBuffer>::large_text::template draw<FrameBuffer>(
214+
screen_base::large_text::template draw<FrameBuffer>(
215215
frame_buffer,
216216
entries[current].str,
217-
klib::vector2i{6, 9 + screen<FrameBuffer>::small_font::height} - offset.cast<int32_t>(),
217+
klib::vector2i{6, 9 + screen_base::small_text::font::height} - offset.cast<int32_t>(),
218218
klib::graphics::white
219219
);
220220
}
221221

222222
// draw the current token using the large font
223-
screen<FrameBuffer>::large_text::template draw<FrameBuffer>(
223+
screen_base::large_text::template draw<FrameBuffer>(
224224
frame_buffer,
225225
current_token_buf,
226226
klib::vector2i{60, 60} - offset.cast<int32_t>(),
227227
klib::graphics::white
228228
);
229229

230230
// draw the next token using the small font
231-
screen<FrameBuffer>::small_text::template draw<FrameBuffer>(
231+
screen_base::small_text::template draw<FrameBuffer>(
232232
frame_buffer,
233233
next_token_buf,
234234
klib::vector2i{108, 78} - offset.cast<int32_t>(),
235235
klib::graphics::white
236236
);
237237

238238
// draw the epoch time using the small font
239-
screen<FrameBuffer>::small_text::template draw<FrameBuffer>(
239+
screen_base::small_text::template draw<FrameBuffer>(
240240
frame_buffer,
241241
epoch_buf,
242242
klib::vector2i{
243243
(240 - 1) - static_cast<int32_t>(
244-
klib::string::strlen(epoch_buf) * screen<FrameBuffer>::small_font::width
244+
klib::string::strlen(epoch_buf) * screen_base::small_text::font::width
245245
),
246-
(135 - 1 - screen<FrameBuffer>::small_font::height)
246+
(135 - 1 - screen_base::small_text::font::height)
247247
} - offset.cast<int32_t>(),
248248
klib::graphics::white
249249
);
250250

251251
// draw using the large font
252-
screen<FrameBuffer>::small_text::template draw<FrameBuffer>(
252+
screen_base::small_text::template draw<FrameBuffer>(
253253
frame_buffer,
254254
delta_buf,
255-
klib::vector2i{1, (135 - 1 - screen<FrameBuffer>::small_font::height)} - offset.cast<int32_t>(),
255+
klib::vector2i{1, (135 - 1 - screen_base::small_text::font::height)} - offset.cast<int32_t>(),
256256
klib::graphics::white
257257
);
258258

@@ -271,11 +271,11 @@ namespace menu {
271271
}
272272

273273
// draw the time left in seconds in the circle
274-
screen<FrameBuffer>::small_text::template draw<FrameBuffer>(
274+
screen_base::small_text::template draw<FrameBuffer>(
275275
frame_buffer, seconds_left_buf,
276276
klib::vector2i{
277-
(204 + 1) - static_cast<int32_t>((klib::string::strlen(seconds_left_buf) * screen<FrameBuffer>::small_font::width) / 2),
278-
(68 + 1) - (screen<FrameBuffer>::small_font::height / 2)
277+
(204 + 1) - static_cast<int32_t>((klib::string::strlen(seconds_left_buf) * screen_base::small_text::font::width) / 2),
278+
(68 + 1) - (screen_base::small_text::font::height / 2)
279279
} - offset.cast<int32_t>(),
280280
klib::graphics::white
281281
);

0 commit comments

Comments
 (0)