summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-01-12 03:45:33 +0100
committerMitya Selivanov <automainint@guattari.tech>2024-01-12 03:45:33 +0100
commit9417f59a071174424f88a206f7789c863d9eb718 (patch)
tree4a189254d5436d87fcb23ace6dee256d463043e9 /source
parentae69ac2aa9aa1dce53849bb6728daea017fe96ff (diff)
downloadsaw-9417f59a071174424f88a206f7789c863d9eb718.zip
Move font and codegen to the source folder
Diffstat (limited to 'source')
-rw-r--r--source/saw/_gen.c48
-rw-r--r--source/saw/domitian_roman.ttfbin0 -> 198512 bytes
2 files changed, 48 insertions, 0 deletions
diff --git a/source/saw/_gen.c b/source/saw/_gen.c
new file mode 100644
index 0000000..0c4e4a6
--- /dev/null
+++ b/source/saw/_gen.c
@@ -0,0 +1,48 @@
+#if 0
+gcc -fsanitize=undefined,address,leak -o _gen _gen.c && ./_gen && rm _gen
+exit
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+
+int main(int argc, char **argv) {
+ FILE *in = fopen("domitian_roman.ttf", "rb");
+ FILE *out = fopen("font.inl.h", "wb");
+ assert(in != NULL);
+ 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, "#include \"../kit/types.h\"\n\n");
+ fprintf(out, "static u8 saw_font_ttf[] = {");
+
+ long long n = 0, k = 0;
+ unsigned char buf[128];
+
+ 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_FONT_TTF_SIZE = %lld };\n\n", n);
+ fprintf(out, "#endif\n");
+
+ fclose(in);
+ return 0;
+}
diff --git a/source/saw/domitian_roman.ttf b/source/saw/domitian_roman.ttf
new file mode 100644
index 0000000..01c0ee6
--- /dev/null
+++ b/source/saw/domitian_roman.ttf
Binary files differ