Mirai's Miscellaneous Misadventures

M21 / core / fonts.c

// copyright 2022 zamfofex
// license: AGPLv3 or later

#include <mimimi/fonts.h>
#include <mimimi/assets.h>

int mimimi_font_image_count = 96;
int mimimi_font_image_color_count = 16 * 9;
int mimimi_font_color_count = 96 * 16 * 9;

void mimimi_glyphs(struct mimimi_image *images, struct mimimi_font *font, unsigned char color)
{
	for (int i = 0 ; i < mimimi_font_image_count ; i++)
	{
		images[i].width = 0;
		images[i].height = 16;
		
		for (int x = 0 ; x < 8 ; x++)
		for (int y = 0 ; y < 16 ; y++)
			if ((font->glyphs[i].rows[y] >> (8 - x) & 1) != 0)
				images[i].width = x + 2;
		
		for (int x = 0 ; x < images[i].width ; x++)
		for (int y = 0 ; y < 16 ; y++)
			images[i].colors[x + y * images[i].width] = (font->glyphs[i].rows[y] >> (8 - x) & 1) == 0 ? 0 : color;
	}
}