summaryrefslogtreecommitdiff
path: root/userspace/fonts/bdf.c
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/fonts/bdf.c')
-rw-r--r--userspace/fonts/bdf.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/userspace/fonts/bdf.c b/userspace/fonts/bdf.c
new file mode 100644
index 0000000..ce717c5
--- /dev/null
+++ b/userspace/fonts/bdf.c
@@ -0,0 +1,59 @@
+// https://github.com/Tecate/bitmap-fonts
+// https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format
+//
+
+//
+// simple converted of bdf to foolfont binary format
+// limited functionality
+// works only for monospace with identical bounding boxes..
+// for now width = 7 /height=13 is hardcoded!
+//
+
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+int main(int argc, char **argv)
+{
+ char buf[256];
+
+ FILE *f=fopen(argv[1],"r");
+
+ bool bitmap=false;
+
+ printf("7\n");
+ printf("13\n");
+
+ while(fgets(buf,256,f))
+ {
+ buf[strlen(buf)-1]=0;
+
+ //printf("[%s]\n",buf);
+
+ if(!strcmp(buf,"BITMAP"))
+ {
+ printf("//reading bitmap\n");
+ bitmap=true;
+ continue;
+ }
+ if(!strcmp(buf,"ENDCHAR"))bitmap=false;
+
+ if(bitmap)
+ {
+ //int l=atoi(buf);
+ int l=strtol(buf,NULL,16);
+
+ for(int i=0;i<7;i++)
+ {
+ if(l&(1<<(6-i)))printf("X");
+ else printf("_");
+ }
+
+ printf("\n");
+ }
+
+ }
+
+
+
+}