1 /* $NetBSD: fontconv.c,v 1.2 2001/06/04 18:59:31 uch Exp $ */
4 __KERNEL_RCSID(0, "$NetBSD$");
9 int width
, height
, ascent
;
15 void fc_rcons(int ac
, char* av
[]);
16 void fc_rasops(int ac
, char* av
[]);
19 main(int ac
, char* av
[])
36 fc_rasops(int ac
, char* av
[])
40 long code_min
= 0x10000;
43 width_in_bytes
= (width
+ 7) / 8;
46 fprintf(ofp
, "static u_char %s%dx%d_data[] = {\n",
47 fontname
, width
, height
, code
);
51 unsigned char buf
[200];
53 n
= fread(buf
, width_in_bytes
, height
, ifp
);
64 fprintf(ofp
, " /* code %d */\n", code
);
65 for (i
= 0; i
< height
; i
++) {
66 unsigned long d
= 0, m
;
68 for (j
= 0; j
< width_in_bytes
; j
++) {
69 d
|= (((unsigned long)buf
[k
]) << (24 - 8*j
));
70 fprintf(ofp
, "0x%02x,", (buf
[k
] & 0xff));
74 for (m
= 0x80000000, j
= 0; j
< width
; j
++, m
>>= 1) {
75 printf((m
& d
) ? "##" : "..");
77 fprintf(ofp
, " */\n");
80 if (code
< code_min
) {
83 if (code_max
< code
) {
90 fprintf(ofp
, "struct wsdisplay_font %s%dx%d = {\n",
91 fontname
, width
, height
);
92 fprintf(ofp
, " \"%s\",\t\t\t/* typeface name */\n", fontname
);
93 fprintf(ofp
, " 0x%02x,\t\t\t/* firstchar */\n", code_min
);
94 fprintf(ofp
, " %d,\t\t\t/* numchars */\n", code_max
- code_min
+ 1);
95 fprintf(ofp
, " WSDISPLAY_FONTENC_ISO,\t/* encoding */\n");
96 fprintf(ofp
, " %d,\t\t\t\t/* width */\n", width
);
97 fprintf(ofp
, " %d,\t\t\t\t/* height */\n", height
);
98 fprintf(ofp
, " %d,\t\t\t\t/* stride */\n", width_in_bytes
);
99 fprintf(ofp
, " WSDISPLAY_FONTENC_L2R,\t/* bit order */\n");
100 fprintf(ofp
, " WSDISPLAY_FONTENC_L2R,\t/* byte order */\n");
101 fprintf(ofp
, " %s%dx%d_data\t\t/* data */\n",
102 fontname
, width
, height
);
103 fprintf(ofp
, "};\n");
108 fc_rcons(int ac
, char* av
[])
112 long code_min
= 0x10000;
115 width_in_bytes
= (width
+ 7) / 8;
121 unsigned char buf
[200];
123 n
= fread(buf
, width_in_bytes
, height
, ifp
);
133 fprintf(ofp
, "static u_int32_t %s%dx%d_%d_pix[] = {\n",
134 fontname
, width
, height
, code
);
137 for (i
= 0; i
< height
; i
++) {
138 unsigned long d
= 0, m
;
139 for (j
= 0; j
< width_in_bytes
; j
++) {
140 d
|= (((unsigned long)buf
[k
++]) << (24 - 8*j
));
142 fprintf(ofp
, " 0x%08x, /* ", d
);
143 for (m
= 0x80000000, j
= 0; j
< width
; j
++, m
>>= 1) {
144 printf((m
& d
) ? "##" : "..");
146 fprintf(ofp
, " */\n");
148 fprintf(ofp
, "};\n");
149 fprintf(ofp
, "static struct raster %s%dx%d_%d = {",
150 fontname
, width
, height
, code
);
151 fprintf(ofp
, " %d, %d, 1, 1, %s%dx%d_%d_pix, 0 };\n",
152 width
, height
, fontname
, width
, height
, code
);
153 if (code
< code_min
) {
156 if (code_max
< code
) {
162 fprintf(ofp
, "struct raster_font %s%dx%d = {\n",
163 fontname
, width
, height
);
164 fprintf(ofp
, " %d, %d, %d, ", width
, height
, ascent
);
165 fprintf(ofp
, "RASFONT_FIXEDWIDTH|RASFONT_NOVERTICALMOVEMENT,\n");
166 fprintf(ofp
, " {\n");
167 for (code
= code_min
; code
<= code_max
; code
++) {
168 fprintf(ofp
, " { &%s%dx%d_%d, ",
169 fontname
, width
, height
, code
);
170 fprintf(ofp
, "%d, %d, %d, %d },\n", 0, -ascent
, width
, 0);
172 fprintf(ofp
, " },\n");
173 fprintf(ofp
, "#ifdef COLORFONT_CACHE\n");
174 fprintf(ofp
, " (struct raster_fontcache*) -1\n");
175 fprintf(ofp
, "#endif /*COLORFONT_CACHE*/\n");
176 fprintf(ofp
, "};\n");