summaryrefslogtreecommitdiff
path: root/userspace/fonts/bdf.c
blob: ce717c5ee39afae834d23f6bca2885cbfe02a32c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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");
        }

    }



}