-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfont_setup.c
More file actions
122 lines (109 loc) · 4.47 KB
/
font_setup.c
File metadata and controls
122 lines (109 loc) · 4.47 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <stdint.h>
#include <stdio.h>
typedef int32_t i32;
void generate_font_incs(const i32 meta[][2], i32 meta_count,
const i32 points[][2], i32 points_count,
const char *meta_path,
const char *points_path)
{
FILE *fm = fopen(meta_path, "w");
FILE *fp = fopen(points_path, "w");
if (!fm || !fp) {
if (fm) fclose(fm);
if (fp) fclose(fp);
return;
}
fprintf(fm, "#ifndef GD_FONT_META_PUSHES\n");
fprintf(fm, "#define GD_FONT_META_PUSHES \\\n");
i32 total_meta_ints = meta_count * 2;
i32 meta_written = 0;
for (i32 i = meta_count - 1; i >= 0; --i) {
for (i32 j = 1; j >= 0; --j) {
++meta_written;
int last = (meta_written == total_meta_ints);
fprintf(fm, "\"pushl $%d\\n\"%s\n",
meta[i][j],
last ? "" : " \\");
}
}
fprintf(fm, "\n#endif\n");
fclose(fm);
fprintf(fp, "#ifndef GD_FONT_POINTS_PUSHES\n");
fprintf(fp, "#define GD_FONT_POINTS_PUSHES \\\n");
i32 total_points_ints = points_count * 2;
i32 points_written = 0;
for (i32 i = points_count - 1; i >= 0; --i) {
for (i32 j = 1; j >= 0; --j) {
++points_written;
int last = (points_written == total_points_ints);
fprintf(fp, "\"pushl $%d\\n\"%s\n",
points[i][j],
last ? "" : " \\");
}
}
fprintf(fp, "\n#endif\n");
fclose(fp);
}
int main(void) {
int gd_font_points[][2] = {
/* 'A' */ {1,4},{0,3},{2,3},{0,2},{1,2},{2,2},{0,1},{2,1},{0,0},{2,0},
/* 'B' */ {0,4},{1,4},{0,3},{2,3},{0,2},{1,2},{0,1},{2,1},{0,0},{1,0},
/* 'C' */ {1,4},{2,4},{0,3},{0,2},{0,1},{1,0},{2,0},
/* 'D' */ {0,4},{1,4},{0,3},{2,3},{0,2},{2,2},{0,1},{2,1},{0,0},{1,0},
/* 'E' */ {0,4},{1,4},{2,4},{0,3},{0,2},{1,2},{0,1},{0,0},{1,0},{2,0},
/* 'F' */ {0,4},{1,4},{2,4},{0,3},{0,2},{1,2},{0,1},{0,0},
/* 'G' */ {1,4},{2,4},{0,3},{0,2},{2,2},{0,1},{2,1},{1,0},{2,0},
/* 'H' */ {0,4},{2,4},{0,3},{2,3},{0,2},{1,2},{2,2},{0,1},{2,1},{0,0},{2,0},
/* 'I' */ {0,4},{1,4},{2,4},{1,3},{1,2},{1,1},{0,0},{1,0},{2,0},
/* 'J' */ {0,4},{1,4},{2,4},{2,3},{2,2},{0,1},{2,1},{1,0},
/* 'K' */ {0,4},{2,4},{0,3},{1,3},{0,2},{0,1},{1,1},{0,0},{2,0},
/* 'L' */ {0,4},{0,3},{0,2},{0,1},{0,0},{1,0},{2,0},
/* 'M' */ {0,4},{2,4},{0,3},{1,3},{2,3},{0,2},{2,2},{0,1},{2,1},{0,0},{2,0},
/* 'N' */ {0,4},{2,4},{0,3},{1,3},{2,3},{0,2},{1,2},{2,2},{0,1},{1,1},{2,1},{0,0},{2,0},
/* 'O' */ {0,4},{1,4},{2,4},{0,3},{2,3},{0,2},{2,2},{0,1},{2,1},{0,0},{1,0},{2,0},
/* 'P' */ {0,4},{1,4},{2,4},{0,3},{2,3},{0,2},{1,2},{2,2},{0,1},{0,0},
/* 'Q' */ {0,4},{1,4},{2,4},{0,3},{2,3},{0,2},{2,2},{0,1},{1,1},{2,1},{2,0},
/* 'R' */ {0,4},{1,4},{2,4},{0,3},{2,3},{0,2},{1,2},{2,2},{0,1},{1,1},{0,0},{2,0},
/* 'S' */ {1,4},{2,4},{0,3},{0,2},{1,2},{2,2},{2,1},{0,0},{1,0},
/* 'T' */ {0,4},{1,4},{2,4},{1,3},{1,2},{1,1},{1,0},
/* 'U' */ {0,4},{2,4},{0,3},{2,3},{0,2},{2,2},{0,1},{2,1},{0,0},{1,0},{2,0},
/* 'V' */ {0,4},{2,4},{0,3},{2,3},{0,2},{2,2},{0,1},{2,1},{1,0},
/* 'W' */ {0,4},{2,4},{0,3},{2,3},{0,2},{2,2},{0,1},{1,1},{2,1},{0,0},{2,0},
/* 'X' */ {0,4},{2,4},{0,3},{2,3},{1,2},{0,1},{2,1},{0,0},{2,0},
/* 'Y' */ {0,4},{2,4},{0,3},{2,3},{1,2},{1,1},{1,0},
/* 'Z' */ {0,4},{1,4},{2,4},{2,3},{1,2},{0,1},{0,0},{1,0},{2,0},
};
int gd_font_meta[26][2] = {
/* 'A' */ { 0, 10},
/* 'B' */ { 10, 10},
/* 'C' */ { 20, 7},
/* 'D' */ { 27, 10},
/* 'E' */ { 37, 10},
/* 'F' */ { 47, 8},
/* 'G' */ { 55, 9},
/* 'H' */ { 64, 11},
/* 'I' */ { 75, 9},
/* 'J' */ { 84, 8},
/* 'K' */ { 92, 9},
/* 'L' */ {101, 7},
/* 'M' */ {108, 11},
/* 'N' */ {119, 13},
/* 'O' */ {132, 12},
/* 'P' */ {144, 10},
/* 'Q' */ {154, 11},
/* 'R' */ {165, 12},
/* 'S' */ {177, 9},
/* 'T' */ {186, 7},
/* 'U' */ {193, 11},
/* 'V' */ {204, 9},
/* 'W' */ {213, 11},
/* 'X' */ {224, 9},
/* 'Y' */ {233, 7},
/* 'Z' */ {240, 9},
};
generate_font_incs(gd_font_meta, 26,
gd_font_points, 249,
"gd_font_meta.inc",
"gd_font_points.inc");
return 0;
}