diff options
Diffstat (limited to 'source/saw/_gen.c')
-rwxr-xr-x | source/saw/_gen.c | 89 |
1 files changed, 65 insertions, 24 deletions
diff --git a/source/saw/_gen.c b/source/saw/_gen.c index 420d822..b4cfdc8 100755 --- a/source/saw/_gen.c +++ b/source/saw/_gen.c @@ -7,42 +7,83 @@ exit #include <assert.h> int main(int argc, char **argv) { - FILE *in = fopen("fonts/domitian_roman.ttf", "rb"); - FILE *out = fopen("font.inl.h", "wb"); - assert(in != NULL); + FILE *out = fopen("fonts.inl.h", "wb"); assert(out != NULL); - fprintf(out, - "// \"Domitian-Roman\" by Daniel Benjamin Miller\n//\n\n"); - fprintf(out, "#ifndef SAW_FONT_INL_H\n"); - fprintf(out, "#define SAW_FONT_INL_H\n\n"); + fprintf(out, "#ifndef SAW_FONTS_INL_H\n"); + fprintf(out, "#define SAW_FONTS_INL_H\n\n"); fprintf(out, "#include \"../kit/types.h\"\n\n"); - fprintf(out, "static u8 saw_font_ttf[] = {"); - long long n = 0, k = 0; - unsigned char buf[128]; + // Write Domitian Roman + // + { + FILE *in = fopen("fonts/domitian_roman.ttf", "rb"); + assert(in != NULL); - while (!feof(in)) { - k = fread(buf, 1, 128, in); - if (k <= 0) - break; + long long n = 0, k = 0; + unsigned char buf[128]; - for (long long i = 0; i < k; ++i) { - if (n > 0) - fprintf(out, ","); - if ((n % 20) == 0) - fprintf(out, "\n "); + fprintf(out, "static u8 saw_ttf_text[] = {"); - fprintf(out, "%4d", (unsigned) buf[i]); + while (!feof(in)) { + k = fread(buf, 1, 128, in); + if (k <= 0) + break; - ++n; + for (long long i = 0; i < k; ++i) { + if (n > 0) + fprintf(out, ","); + if ((n % 20) == 0) + fprintf(out, "\n "); + + fprintf(out, "%4d", (unsigned) buf[i]); + + ++n; + } } + + fprintf(out, "\n};\n\n"); + fprintf(out, "enum { SAW_TTF_TEXT_SIZE = %lld };\n\n", n); + + fclose(in); + } + + // Write Font Awesome + // + { + FILE *in = fopen("fonts/font_awesome_6_free_solid_900.ttf", "rb"); + assert(in != NULL); + + long long n = 0, k = 0; + unsigned char buf[128]; + + fprintf(out, "static u8 saw_ttf_icons[] = {"); + + while (!feof(in)) { + k = fread(buf, 1, 128, in); + if (k <= 0) + break; + + for (long long i = 0; i < k; ++i) { + if (n > 0) + fprintf(out, ","); + if ((n % 20) == 0) + fprintf(out, "\n "); + + fprintf(out, "%4d", (unsigned) buf[i]); + + ++n; + } + } + + fprintf(out, "\n};\n\n"); + fprintf(out, "enum { SAW_TTF_ICONS_SIZE = %lld };\n\n", n); + + fclose(in); } - fprintf(out, "\n};\n\n"); - fprintf(out, "enum { SAW_FONT_TTF_SIZE = %lld };\n\n", n); fprintf(out, "#endif\n"); + fclose(out); - fclose(in); return 0; } |