133 int important_colors;
153 unsigned char inchar;
159 unsigned char thischar1[16], thischar2[16];
160 unsigned char thischar0[16], thischar3[16];
164 unsigned next_pixels;
165 unsigned color_mask = 0x00;
167 unsigned char bitmap[17*32][18*32/8];
173 char wide[0x200000]={0x200000 * 0};
175 char *infile=
"", *outfile=
"";
179 for (i = 1; i < argc; i++) {
180 if (argv[i][0] ==
'-') {
181 switch (argv[i][1]) {
183 infile = &argv[i][2];
186 outfile = &argv[i][2];
189 sscanf (&argv[i][2],
"%x", &
uniplane);
196 fprintf (stderr,
"\nSyntax:\n\n");
197 fprintf (stderr,
" %s -p<Unicode_Page> ", argv[0]);
198 fprintf (stderr,
"-i<Input_File> -o<Output_File> -w\n\n");
199 fprintf (stderr,
" -w specifies .wbmp output instead of ");
200 fprintf (stderr,
"default Windows .bmp output.\n\n");
201 fprintf (stderr,
" -p is followed by 1 to 6 ");
202 fprintf (stderr,
"Unicode plane hex digits ");
203 fprintf (stderr,
"(default is Page 0).\n\n");
204 fprintf (stderr,
"\nExample:\n\n");
205 fprintf (stderr,
" %s -p83 -iunifont.hex -ou83.bmp\n\n\n",
216 if (strlen (infile) > 0) {
217 if ((infp = fopen (infile,
"r")) == NULL) {
218 fprintf (stderr,
"Error: can't open %s for input.\n", infile);
225 if (strlen (outfile) > 0) {
226 if ((outfp = fopen (outfile,
"w")) == NULL) {
227 fprintf (stderr,
"Error: can't open %s for output.\n", outfile);
243 for (i = 0x0700; i <= 0x074F; i++) wide[i] = 1;
244 for (i = 0x0800; i <= 0x083F; i++) wide[i] = 1;
245 for (i = 0x0900; i <= 0x0DFF; i++) wide[i] = 1;
246 for (i = 0x1000; i <= 0x109F; i++) wide[i] = 1;
247 for (i = 0x1100; i <= 0x11FF; i++) wide[i] = 1;
248 for (i = 0x1400; i <= 0x167F; i++) wide[i] = 1;
249 for (i = 0x1700; i <= 0x171F; i++) wide[i] = 1;
250 for (i = 0x1720; i <= 0x173F; i++) wide[i] = 1;
251 for (i = 0x1740; i <= 0x175F; i++) wide[i] = 1;
252 for (i = 0x1760; i <= 0x177F; i++) wide[i] = 1;
253 for (i = 0x1780; i <= 0x17FF; i++) wide[i] = 1;
254 for (i = 0x18B0; i <= 0x18FF; i++) wide[i] = 1;
255 for (i = 0x1800; i <= 0x18AF; i++) wide[i] = 1;
256 for (i = 0x1900; i <= 0x194F; i++) wide[i] = 1;
258 for (i = 0x1A00; i <= 0x1A1F; i++) wide[i] = 1;
259 for (i = 0x1A20; i <= 0x1AAF; i++) wide[i] = 1;
260 for (i = 0x1B00; i <= 0x1B7F; i++) wide[i] = 1;
261 for (i = 0x1B80; i <= 0x1BBF; i++) wide[i] = 1;
262 for (i = 0x1BC0; i <= 0x1BFF; i++) wide[i] = 1;
263 for (i = 0x1C00; i <= 0x1C4F; i++) wide[i] = 1;
264 for (i = 0x1CC0; i <= 0x1CCF; i++) wide[i] = 1;
265 for (i = 0x1CD0; i <= 0x1CFF; i++) wide[i] = 1;
266 wide[0x2329] = wide[0x232A] = 1;
267 for (i = 0x2E80; i <= 0xA4CF; i++) wide[i] = 1;
269 for (i = 0xA900; i <= 0xA92F; i++) wide[i] = 1;
270 for (i = 0xA930; i <= 0xA95F; i++) wide[i] = 1;
271 for (i = 0xA960; i <= 0xA97F; i++) wide[i] = 1;
272 for (i = 0xA980; i <= 0xA9DF; i++) wide[i] = 1;
273 for (i = 0xAA00; i <= 0xAA5F; i++) wide[i] = 1;
274 for (i = 0xA9E0; i <= 0xA9FF; i++) wide[i] = 1;
275 for (i = 0xAA00; i <= 0xAA5F; i++) wide[i] = 1;
276 for (i = 0xAA60; i <= 0xAA7F; i++) wide[i] = 1;
277 for (i = 0xAAE0; i <= 0xAAFF; i++) wide[i] = 1;
278 for (i = 0xABC0; i <= 0xABFF; i++) wide[i] = 1;
279 for (i = 0xAC00; i <= 0xD7AF; i++) wide[i] = 1;
280 for (i = 0xD7B0; i <= 0xD7FF; i++) wide[i] = 1;
281 for (i = 0xF900; i <= 0xFAFF; i++) wide[i] = 1;
282 for (i = 0xFE10; i <= 0xFE1F; i++) wide[i] = 1;
283 for (i = 0xFE30; i <= 0xFE60; i++) wide[i] = 1;
284 for (i = 0xFFE0; i <= 0xFFE6; i++) wide[i] = 1;
289 for (i = 0x010A00; i <= 0x010A5F; i++) wide[i] = 1;
290 for (i = 0x011000; i <= 0x01107F; i++) wide[i] = 1;
291 for (i = 0x011080; i <= 0x0110CF; i++) wide[i] = 1;
292 for (i = 0x011100; i <= 0x01114F; i++) wide[i] = 1;
293 for (i = 0x011180; i <= 0x0111DF; i++) wide[i] = 1;
294 for (i = 0x011200; i <= 0x01124F; i++) wide[i] = 1;
295 for (i = 0x0112B0; i <= 0x0112FF; i++) wide[i] = 1;
296 for (i = 0x011300; i <= 0x01137F; i++) wide[i] = 1;
297 for (i = 0x011400; i <= 0x01147F; i++) wide[i] = 1;
298 for (i = 0x011480; i <= 0x0114DF; i++) wide[i] = 1;
299 for (i = 0x011580; i <= 0x0115FF; i++) wide[i] = 1;
300 for (i = 0x011600; i <= 0x01165F; i++) wide[i] = 1;
301 for (i = 0x011660; i <= 0x01167F; i++) wide[i] = 1;
302 for (i = 0x011680; i <= 0x0116CF; i++) wide[i] = 1;
303 for (i = 0x011700; i <= 0x01173F; i++) wide[i] = 1;
304 for (i = 0x011800; i <= 0x01184F; i++) wide[i] = 1;
305 for (i = 0x011900; i <= 0x01195F; i++) wide[i] = 1;
306 for (i = 0x0119A0; i <= 0x0119FF; i++) wide[i] = 1;
307 for (i = 0x011A00; i <= 0x011A4F; i++) wide[i] = 1;
308 for (i = 0x011A50; i <= 0x011AAF; i++) wide[i] = 1;
309 for (i = 0x011B00; i <= 0x011B5F; i++) wide[i] = 1;
310 for (i = 0x011F00; i <= 0x011F5F; i++) wide[i] = 1;
311 for (i = 0x011C00; i <= 0x011C6F; i++) wide[i] = 1;
312 for (i = 0x011C70; i <= 0x011CBF; i++) wide[i] = 1;
313 for (i = 0x011D00; i <= 0x011D5F; i++) wide[i] = 1;
314 for (i = 0x011EE0; i <= 0x011EFF; i++) wide[i] = 1;
315 for (i = 0x012F90; i <= 0x012FFF; i++) wide[i] = 1;
317 for (i = 0x016AD0; i <= 0x016AFF; i++) wide[i] = 1;
318 for (i = 0x016B00; i <= 0x016B8F; i++) wide[i] = 1;
319 for (i = 0x016F00; i <= 0x016F9F; i++) wide[i] = 1;
320 for (i = 0x016FE0; i <= 0x016FFF; i++) wide[i] = 1;
321 for (i = 0x017000; i <= 0x0187FF; i++) wide[i] = 1;
322 for (i = 0x018800; i <= 0x018AFF; i++) wide[i] = 1;
323 for (i = 0x01AFF0; i <= 0x01AFFF; i++) wide[i] = 1;
324 for (i = 0x01B000; i <= 0x01B0FF; i++) wide[i] = 1;
325 for (i = 0x01B100; i <= 0x01B12F; i++) wide[i] = 1;
326 for (i = 0x01B170; i <= 0x01B2FF; i++) wide[i] = 1;
327 for (i = 0x01CF00; i <= 0x01CFCF; i++) wide[i] = 1;
328 for (i = 0x01D100; i <= 0x01D1FF; i++) wide[i] = 1;
329 for (i = 0x01D800; i <= 0x01DAAF; i++) wide[i] = 1;
330 for (i = 0x01E2C0; i <= 0x01E2FF; i++) wide[i] = 1;
331 for (i = 0x01E800; i <= 0x01E8DF; i++) wide[i] = 1;
332 for (i = 0x01F200; i <= 0x01F2FF; i++) wide[i] = 1;
345 if ((header[0] = fgetc (infp)) != EOF) {
346 if ((header[1] = fgetc (infp)) != EOF) {
347 if (header[0] ==
'B' && header[1] ==
'M') {
361 fprintf (stderr,
"Fatal error; end of input file.\n\n");
370 header[i] = fgetc (infp);
374 for (i=0; i < 32*17; i++) {
375 for (j=0; j < 32*18/8; j++) {
376 inchar = fgetc (infp);
377 bitmap[i][j] = ~inchar;
389 for (i = 2; i < 54; i++)
390 header[i] = fgetc (infp);
396 (header[2] & 0xFF) | ((header[3] & 0xFF) << 8) |
397 ((header[4] & 0xFF) << 16) | ((header[5] & 0xFF) << 24);
402 (header[10] & 0xFF) | ((header[11] & 0xFF) << 8) |
403 ((header[12] & 0xFF) << 16) | ((header[13] & 0xFF) << 24);
406 (header[14] & 0xFF) | ((header[15] & 0xFF) << 8) |
407 ((header[16] & 0xFF) << 16) | ((header[17] & 0xFF) << 24);
410 (header[18] & 0xFF) | ((header[19] & 0xFF) << 8) |
411 ((header[20] & 0xFF) << 16) | ((header[21] & 0xFF) << 24);
414 (header[22] & 0xFF) | ((header[23] & 0xFF) << 8) |
415 ((header[24] & 0xFF) << 16) | ((header[25] & 0xFF) << 24);
418 (header[26] & 0xFF) | ((header[27] & 0xFF) << 8);
421 (header[28] & 0xFF) | ((header[29] & 0xFF) << 8);
424 (header[30] & 0xFF) | ((header[31] & 0xFF) << 8) |
425 ((header[32] & 0xFF) << 16) | ((header[33] & 0xFF) << 24);
428 (header[34] & 0xFF) | ((header[35] & 0xFF) << 8) |
429 ((header[36] & 0xFF) << 16) | ((header[37] & 0xFF) << 24);
432 (header[38] & 0xFF) | ((header[39] & 0xFF) << 8) |
433 ((header[40] & 0xFF) << 16) | ((header[41] & 0xFF) << 24);
436 (header[42] & 0xFF) | ((header[43] & 0xFF) << 8) |
437 ((header[44] & 0xFF) << 16) | ((header[45] & 0xFF) << 24);
440 (header[46] & 0xFF) | ((header[47] & 0xFF) << 8) |
441 ((header[48] & 0xFF) << 16) | ((header[49] & 0xFF) << 24);
444 (header[50] & 0xFF) | ((header[51] & 0xFF) << 8) |
445 ((header[52] & 0xFF) << 16) | ((header[53] & 0xFF) << 24);
475 fprintf (stderr,
"Filetype: '%c%c'\n",
477 fprintf (stderr,
"File Size: %d\n",
bmp_header.file_size);
478 fprintf (stderr,
"Image Offset: %d\n",
bmp_header.image_offset);
479 fprintf (stderr,
"Info Header Size: %d\n",
bmp_header.info_size);
480 fprintf (stderr,
"Image Width: %d\n",
bmp_header.width);
481 fprintf (stderr,
"Image Height: %d\n",
bmp_header.height);
482 fprintf (stderr,
"Number of Planes: %d\n",
bmp_header.nplanes);
483 fprintf (stderr,
"Bits per Pixel: %d\n",
bmp_header.bits_per_pixel);
484 fprintf (stderr,
"Compression Method: %d\n",
bmp_header.compression);
485 fprintf (stderr,
"Image Size: %d\n",
bmp_header.image_size);
486 fprintf (stderr,
"X Pixels per Meter: %d\n",
bmp_header.x_ppm);
487 fprintf (stderr,
"Y Pixels per Meter: %d\n",
bmp_header.y_ppm);
488 fprintf (stderr,
"Number of Colors: %d\n",
bmp_header.ncolors);
489 fprintf (stderr,
"Important Colors: %d\n",
bmp_header.important_colors);
496 for (i = 32*17-1; i >= 0; i--) {
497 for (j=0; j < 32*18/8; j++) {
501 next_pixels = fgetc (infp);
507 for (k = 0; k < 8; k++) {
508 this_pixel = (fgetc (infp) & 0xFF) +
509 (fgetc (infp) & 0xFF) +
510 (fgetc (infp) & 0xFF);
517 if (this_pixel >= (128 * 3))
523 next_pixels = (next_pixels << 1) | this_pixel;
527 bitmap [(32*17-1) - i] [j] = next_pixels;
530 bitmap [i][j] = next_pixels;
539 if (color_mask != 0x00) {
540 for (i = 32*17-1; i >= 0; i--) {
541 for (j=0; j < 32*18/8; j++) {
542 bitmap [i][j] ^= color_mask;
565 for (i = 0x0; i <= 0xF; i++) {
566 for (j = 0; j < 4; j++) {
568 ((unsigned)bitmap[32 * (i+1) + 4 * j + 8 ][6] << 24 ) |
569 ((
unsigned)bitmap[32 * (i+1) + 4 * j + 8 + 1][6] << 16 ) |
570 ((unsigned)bitmap[32 * (i+1) + 4 * j + 8 + 2][6] << 8 ) |
571 ((
unsigned)bitmap[32 * (i+1) + 4 * j + 8 + 3][6] );
578 for (i = 0; i < 4; i++) {
579 for (j = 0; j < 4; j++) {
581 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 1][i + 3] << 24 ) |
582 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 2][i + 3] << 16 ) |
583 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 3][i + 3] << 8 ) |
584 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 4][i + 3] );
589 for (i = 4; i < 6; i++) {
590 for (j = 0; j < 4; j++) {
592 ((unsigned)bitmap[32 * 1 + 4 * j + 8 ][i] << 24 ) |
593 ((unsigned)bitmap[32 * 1 + 4 * j + 8 + 1][i] << 16 ) |
594 ((unsigned)bitmap[32 * 1 + 4 * j + 8 + 2][i] << 8 ) |
595 ((unsigned)bitmap[32 * 1 + 4 * j + 8 + 3][i] );
606 for (i = 0x08; i < 0x18; i++) {
607 bitmap[i][7] = (bitmap[i][8] << 4) | ((bitmap[i][ 9] >> 4) & 0xf);
608 bitmap[i][8] = (bitmap[i][9] << 4) | ((bitmap[i][10] >> 4) & 0xf);
610 for (i = 4; i < 6; i++) {
611 for (j = 0; j < 4; j++) {
613 ((unsigned)bitmap[4 * j + 8 + 1][i + 3] << 24 ) |
614 ((unsigned)bitmap[4 * j + 8 + 2][i + 3] << 16 ) |
615 ((unsigned)bitmap[4 * j + 8 + 3][i + 3] << 8 ) |
616 ((unsigned)bitmap[4 * j + 8 + 4][i + 3] );
626 for (i=0; i<6; i++) {
628 for (j = 0x0; !match && j <= 0xF; j++) {
644 for (i = 0x0; i <= 0xf; i++) {
645 for (j = 0x0; j <= 0xf; j++) {
646 for (k = 0; k < 16; k++) {
648 thischar0[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) ];
649 thischar1[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) + 1];
650 thischar2[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) + 2];
651 thischar3[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) + 3];
654 thischar0[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) ];
655 thischar1[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) + 1];
656 thischar2[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) + 2];
657 thischar3[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) + 3];
665 for (k=0; (empty1 || empty2) && k < 16; k++) {
666 if (thischar1[k] != 0) empty1 = 0;
667 if (thischar2[k] != 0) empty2 = 0;
672 if (!empty1 || !empty2) {
688 fprintf (outfp,
"%04X%X%X:",
uniplane, i, j);
690 fprintf (outfp,
"%02X%X%X:",
uniplane, i, j);
691 for (thisrow=0; thisrow<16; thisrow++) {
697 empty2 && !wide[(
uniplane << 8) | (i << 4) | j]) {
702 else if (wide[(
uniplane << 8) | (i << 4) | j] == 4) {
706 thischar0[thisrow], thischar1[thisrow],
707 thischar2[thisrow], thischar3[thisrow] & 0xFE);
712 thischar1[thisrow], thischar2[thisrow]);
715 fprintf (outfp,
"\n");
int main(int argc, char *argv[])
The main function.
unsigned planeset
=1: use plane specified with -p parameter
unsigned uniplane
Unicode plane number, 0..0xff ff ff.
unsigned forcewide
=1 to set each glyph to 16 pixels wide
unsigned hexdigit[16][4]
32 bit representation of 16x8 0..F bitmap
unsigned char color_table[256][4]
#define MAXBUF
Maximum input file line length - 1.
unsigned flip
=1 if we're transposing glyph matrix