Mirai's Miscellaneous Misadventures
M19 / core / fonts.c
1
2
3
4#include <mimimi/fonts.h>
5#include <mimimi/assets.h>
6
7int mimimi_font_image_count = 96;
8int mimimi_font_image_color_count = 16 * 9;
9int mimimi_font_color_count = 96 * 16 * 9;
10
11void mimimi_glyphs(struct mimimi_image *images, struct mimimi_font *font, unsigned char color)
12{
13 for (int i = 0 ; i < mimimi_font_image_count ; i++)
14 {
15 images[i].width = 0;
16 images[i].height = 16;
17
18 for (int x = 0 ; x < 8 ; x++)
19 for (int y = 0 ; y < 16 ; y++)
20 if ((font->glyphs[i].rows[y] >> (8 - x) & 1) != 0)
21 images[i].width = x + 2;
22
23 for (int x = 0 ; x < images[i].width ; x++)
24 for (int y = 0 ; y < 16 ; y++)
25 images[i].colors[x + y * images[i].width] = (font->glyphs[i].rows[y] >> (8 - x) & 1) == 0 ? 0 : color;
26 }
27}