-
Notifications
You must be signed in to change notification settings - Fork 28
/
unfont.c
58 lines (47 loc) · 806 Bytes
/
unfont.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include "font.h"
void copy(int s, int e, int idx) {
int r,i;
for(i=s;i<e;i++) {
for(r=0;r<50;r++) {
if(im[r][i]!=' ') goto findend;
}
}
findend: s=i;
for(i=e;i>s;i--) {
for(r=0;r<50;r++) {
if(im[r][i]!=' ') goto go;
}
}
go: e=i+1;
printf("static int8_t lt%u[]={",idx);
for(r=0;r<50;r++) {
int l=0;
for(i=s;i<e;i++) {
char c=im[r][i];
if(c==' ') { l++; }
else {
if(l) { printf("-%u,",l); l=0; }
printf("%u,",colors[c-'a']);
}
}
printf("-100,");
}
printf("-101};\n");
}
int main() {
int i,st=0,idx=0;
for(i=0;i<width;i++) {
if(im[0][i]=='a') {
copy(st+1,i-1,idx);
idx++;
st=i;
}
}
printf("static int8_t *lt[]={");
for(i=0;i<idx;i++) {
printf("lt%d,",(i==6||i==4)?0:i);
}
printf("};\n\n");
return 0;
}