-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfont.c
41 lines (32 loc) · 804 Bytes
/
font.c
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
#include <stdio.h>
#define INPUT_FILE "font.hex"
#define OUTPUT_FILE "font.bin"
#define CHARACTERS 95
#define CHAR_HEIGHT 16
int main(void) {
FILE *fin;
FILE *fout;
int i;
fin = fopen(INPUT_FILE, "r");
fout = fopen(OUTPUT_FILE, "wb");
for (i = 0; i < CHARACTERS; i++) {
int c;
int scanline;
printf("%d\n", i);
/* skip to ':' */
while ((c = fgetc(fin)) != ':') {
/* read until hits ':' */
}
for (scanline = 0; scanline < CHAR_HEIGHT; scanline++) {
int b;
fscanf(fin, "%02x", &b);
fputc(b, fout);
}
/* skip endline */
while ((c = fgetc(fin)) != '\n') {
/* read until hits '\n' */
}
}
fclose(fin);
fclose(fout);
}