143 int important_colors;
163 unsigned char inchar;
169 unsigned char thischar1[16], thischar2[16];
170 unsigned char thischar0[16], thischar3[16];
174 unsigned next_pixels;
175 unsigned color_mask = 0x00;
177 unsigned char bitmap[17*32][18*32/8];
183 char wide[0x200000]={0x200000 * 0};
185 char *infile=
"", *outfile=
"";
189 for (i = 1; i < argc; i++) {
190 if (argv[i][0] ==
'-') {
191 switch (argv[i][1]) {
193 infile = &argv[i][2];
196 outfile = &argv[i][2];
199 sscanf (&argv[i][2],
"%x", &
uniplane);
206 fprintf (stderr,
"\nSyntax:\n\n");
207 fprintf (stderr,
" %s -p<Unicode_Page> ", argv[0]);
208 fprintf (stderr,
"-i<Input_File> -o<Output_File> -w\n\n");
209 fprintf (stderr,
" -w specifies .wbmp output instead of ");
210 fprintf (stderr,
"default Windows .bmp output.\n\n");
211 fprintf (stderr,
" -p is followed by 1 to 6 ");
212 fprintf (stderr,
"Unicode plane hex digits ");
213 fprintf (stderr,
"(default is Page 0).\n\n");
214 fprintf (stderr,
"\nExample:\n\n");
215 fprintf (stderr,
" %s -p83 -iunifont.hex -ou83.bmp\n\n\n",
226 if (strlen (infile) > 0) {
227 if ((infp = fopen (infile,
"r")) == NULL) {
228 fprintf (stderr,
"Error: can't open %s for input.\n", infile);
235 if (strlen (outfile) > 0) {
236 if ((outfp = fopen (outfile,
"w")) == NULL) {
237 fprintf (stderr,
"Error: can't open %s for output.\n", outfile);
253 for (i = 0x0700; i <= 0x074F; i++) wide[i] = 1;
254 for (i = 0x0800; i <= 0x083F; i++) wide[i] = 1;
255 for (i = 0x0900; i <= 0x0DFF; i++) wide[i] = 1;
256 for (i = 0x1000; i <= 0x109F; i++) wide[i] = 1;
257 for (i = 0x1100; i <= 0x11FF; i++) wide[i] = 1;
258 for (i = 0x1400; i <= 0x167F; i++) wide[i] = 1;
259 for (i = 0x1700; i <= 0x171F; i++) wide[i] = 1;
260 for (i = 0x1720; i <= 0x173F; i++) wide[i] = 1;
261 for (i = 0x1740; i <= 0x175F; i++) wide[i] = 1;
262 for (i = 0x1760; i <= 0x177F; i++) wide[i] = 1;
263 for (i = 0x1780; i <= 0x17FF; i++) wide[i] = 1;
264 for (i = 0x18B0; i <= 0x18FF; i++) wide[i] = 1;
265 for (i = 0x1800; i <= 0x18AF; i++) wide[i] = 1;
266 for (i = 0x1900; i <= 0x194F; i++) wide[i] = 1;
268 for (i = 0x1A00; i <= 0x1A1F; i++) wide[i] = 1;
269 for (i = 0x1A20; i <= 0x1AAF; i++) wide[i] = 1;
270 for (i = 0x1B00; i <= 0x1B7F; i++) wide[i] = 1;
271 for (i = 0x1B80; i <= 0x1BBF; i++) wide[i] = 1;
272 for (i = 0x1BC0; i <= 0x1BFF; i++) wide[i] = 1;
273 for (i = 0x1C00; i <= 0x1C4F; i++) wide[i] = 1;
274 for (i = 0x1CC0; i <= 0x1CCF; i++) wide[i] = 1;
275 for (i = 0x1CD0; i <= 0x1CFF; i++) wide[i] = 1;
276 wide[0x2329] = wide[0x232A] = 1;
277 for (i = 0x2E80; i <= 0xA4CF; i++) wide[i] = 1;
279 for (i = 0xA900; i <= 0xA92F; i++) wide[i] = 1;
280 for (i = 0xA930; i <= 0xA95F; i++) wide[i] = 1;
281 for (i = 0xA960; i <= 0xA97F; i++) wide[i] = 1;
282 for (i = 0xA980; i <= 0xA9DF; i++) wide[i] = 1;
283 for (i = 0xAA00; i <= 0xAA5F; i++) wide[i] = 1;
284 for (i = 0xA9E0; i <= 0xA9FF; i++) wide[i] = 1;
285 for (i = 0xAA00; i <= 0xAA5F; i++) wide[i] = 1;
286 for (i = 0xAA60; i <= 0xAA7F; i++) wide[i] = 1;
287 for (i = 0xAAE0; i <= 0xAAFF; i++) wide[i] = 1;
288 for (i = 0xABC0; i <= 0xABFF; i++) wide[i] = 1;
289 for (i = 0xAC00; i <= 0xD7AF; i++) wide[i] = 1;
290 for (i = 0xD7B0; i <= 0xD7FF; i++) wide[i] = 1;
291 for (i = 0xF900; i <= 0xFAFF; i++) wide[i] = 1;
292 for (i = 0xFE10; i <= 0xFE1F; i++) wide[i] = 1;
293 for (i = 0xFE30; i <= 0xFE60; i++) wide[i] = 1;
294 for (i = 0xFFE0; i <= 0xFFE6; i++) wide[i] = 1;
299 for (i = 0x0105C0; i <= 0x0105FF; i++) wide[i] = 1;
300 for (i = 0x010A00; i <= 0x010A5F; i++) wide[i] = 1;
301 for (i = 0x011000; i <= 0x01107F; i++) wide[i] = 1;
302 for (i = 0x011080; i <= 0x0110CF; i++) wide[i] = 1;
303 for (i = 0x011100; i <= 0x01114F; i++) wide[i] = 1;
304 for (i = 0x011180; i <= 0x0111DF; i++) wide[i] = 1;
305 for (i = 0x011200; i <= 0x01124F; i++) wide[i] = 1;
306 for (i = 0x0112B0; i <= 0x0112FF; i++) wide[i] = 1;
307 for (i = 0x011300; i <= 0x01137F; i++) wide[i] = 1;
308 for (i = 0x011380; i <= 0x0113FF; i++) wide[i] = 1;
309 for (i = 0x011400; i <= 0x01147F; i++) wide[i] = 1;
310 for (i = 0x011480; i <= 0x0114DF; i++) wide[i] = 1;
311 for (i = 0x011580; i <= 0x0115FF; i++) wide[i] = 1;
312 for (i = 0x011600; i <= 0x01165F; i++) wide[i] = 1;
313 for (i = 0x011660; i <= 0x01167F; i++) wide[i] = 1;
314 for (i = 0x011680; i <= 0x0116CF; i++) wide[i] = 1;
315 for (i = 0x0116D0; i <= 0x0116FF; i++) wide[i] = 1;
316 for (i = 0x011700; i <= 0x01173F; i++) wide[i] = 1;
317 for (i = 0x011800; i <= 0x01184F; i++) wide[i] = 1;
318 for (i = 0x011900; i <= 0x01195F; i++) wide[i] = 1;
319 for (i = 0x0119A0; i <= 0x0119FF; i++) wide[i] = 1;
320 for (i = 0x011A00; i <= 0x011A4F; i++) wide[i] = 1;
321 for (i = 0x011A50; i <= 0x011AAF; i++) wide[i] = 1;
322 for (i = 0x011B00; i <= 0x011B5F; i++) wide[i] = 1;
323 for (i = 0x011F00; i <= 0x011F5F; i++) wide[i] = 1;
324 for (i = 0x011C00; i <= 0x011C6F; i++) wide[i] = 1;
325 for (i = 0x011C70; i <= 0x011CBF; i++) wide[i] = 1;
326 for (i = 0x011D00; i <= 0x011D5F; i++) wide[i] = 1;
327 for (i = 0x011EE0; i <= 0x011EFF; i++) wide[i] = 1;
328 for (i = 0x011F00; i <= 0x011F5F; i++) wide[i] = 1;
329 for (i = 0x012F90; i <= 0x012FFF; i++) wide[i] = 1;
331 for (i = 0x016100; i <= 0x01613F; i++) wide[i] = 1;
332 for (i = 0x016AD0; i <= 0x016AFF; i++) wide[i] = 1;
333 for (i = 0x016B00; i <= 0x016B8F; i++) wide[i] = 1;
334 for (i = 0x016D40; i <= 0x016D7F; i++) wide[i] = 1;
335 for (i = 0x016F00; i <= 0x016F9F; i++) wide[i] = 1;
336 for (i = 0x016FE0; i <= 0x016FFF; i++) wide[i] = 1;
337 for (i = 0x017000; i <= 0x0187FF; i++) wide[i] = 1;
338 for (i = 0x018800; i <= 0x018AFF; i++) wide[i] = 1;
339 for (i = 0x018B00; i <= 0x018CFF; i++) wide[i] = 1;
340 for (i = 0x01AFF0; i <= 0x01AFFF; i++) wide[i] = 1;
341 for (i = 0x01B000; i <= 0x01B0FF; i++) wide[i] = 1;
342 for (i = 0x01B100; i <= 0x01B12F; i++) wide[i] = 1;
343 for (i = 0x01B170; i <= 0x01B2FF; i++) wide[i] = 1;
344 for (i = 0x01CF00; i <= 0x01CFCF; i++) wide[i] = 1;
345 for (i = 0x01D100; i <= 0x01D1FF; i++) wide[i] = 1;
346 for (i = 0x01D800; i <= 0x01DAAF; i++) wide[i] = 1;
347 for (i = 0x01E2C0; i <= 0x01E2FF; i++) wide[i] = 1;
348 for (i = 0x01E500; i <= 0x01E5FF; i++) wide[i] = 1;
349 for (i = 0x01E800; i <= 0x01E8DF; i++) wide[i] = 1;
350 for (i = 0x01F200; i <= 0x01F2FF; i++) wide[i] = 1;
363 if ((header[0] = fgetc (infp)) != EOF) {
364 if ((header[1] = fgetc (infp)) != EOF) {
365 if (header[0] ==
'B' && header[1] ==
'M') {
379 fprintf (stderr,
"Fatal error; end of input file.\n\n");
388 header[i] = fgetc (infp);
392 for (i=0; i < 32*17; i++) {
393 for (j=0; j < 32*18/8; j++) {
394 inchar = fgetc (infp);
395 bitmap[i][j] = ~inchar;
407 for (i = 2; i < 54; i++)
408 header[i] = fgetc (infp);
414 (header[2] & 0xFF) | ((header[3] & 0xFF) << 8) |
415 ((header[4] & 0xFF) << 16) | ((header[5] & 0xFF) << 24);
420 (header[10] & 0xFF) | ((header[11] & 0xFF) << 8) |
421 ((header[12] & 0xFF) << 16) | ((header[13] & 0xFF) << 24);
424 (header[14] & 0xFF) | ((header[15] & 0xFF) << 8) |
425 ((header[16] & 0xFF) << 16) | ((header[17] & 0xFF) << 24);
428 (header[18] & 0xFF) | ((header[19] & 0xFF) << 8) |
429 ((header[20] & 0xFF) << 16) | ((header[21] & 0xFF) << 24);
432 (header[22] & 0xFF) | ((header[23] & 0xFF) << 8) |
433 ((header[24] & 0xFF) << 16) | ((header[25] & 0xFF) << 24);
436 (header[26] & 0xFF) | ((header[27] & 0xFF) << 8);
439 (header[28] & 0xFF) | ((header[29] & 0xFF) << 8);
442 (header[30] & 0xFF) | ((header[31] & 0xFF) << 8) |
443 ((header[32] & 0xFF) << 16) | ((header[33] & 0xFF) << 24);
446 (header[34] & 0xFF) | ((header[35] & 0xFF) << 8) |
447 ((header[36] & 0xFF) << 16) | ((header[37] & 0xFF) << 24);
450 (header[38] & 0xFF) | ((header[39] & 0xFF) << 8) |
451 ((header[40] & 0xFF) << 16) | ((header[41] & 0xFF) << 24);
454 (header[42] & 0xFF) | ((header[43] & 0xFF) << 8) |
455 ((header[44] & 0xFF) << 16) | ((header[45] & 0xFF) << 24);
458 (header[46] & 0xFF) | ((header[47] & 0xFF) << 8) |
459 ((header[48] & 0xFF) << 16) | ((header[49] & 0xFF) << 24);
462 (header[50] & 0xFF) | ((header[51] & 0xFF) << 8) |
463 ((header[52] & 0xFF) << 16) | ((header[53] & 0xFF) << 24);
493 fprintf (stderr,
"Filetype: '%c%c'\n",
495 fprintf (stderr,
"File Size: %d\n",
bmp_header.file_size);
496 fprintf (stderr,
"Image Offset: %d\n",
bmp_header.image_offset);
497 fprintf (stderr,
"Info Header Size: %d\n",
bmp_header.info_size);
498 fprintf (stderr,
"Image Width: %d\n",
bmp_header.width);
499 fprintf (stderr,
"Image Height: %d\n",
bmp_header.height);
500 fprintf (stderr,
"Number of Planes: %d\n",
bmp_header.nplanes);
501 fprintf (stderr,
"Bits per Pixel: %d\n",
bmp_header.bits_per_pixel);
502 fprintf (stderr,
"Compression Method: %d\n",
bmp_header.compression);
503 fprintf (stderr,
"Image Size: %d\n",
bmp_header.image_size);
504 fprintf (stderr,
"X Pixels per Meter: %d\n",
bmp_header.x_ppm);
505 fprintf (stderr,
"Y Pixels per Meter: %d\n",
bmp_header.y_ppm);
506 fprintf (stderr,
"Number of Colors: %d\n",
bmp_header.ncolors);
507 fprintf (stderr,
"Important Colors: %d\n",
bmp_header.important_colors);
514 for (i = 32*17-1; i >= 0; i--) {
515 for (j=0; j < 32*18/8; j++) {
519 next_pixels = fgetc (infp);
525 for (k = 0; k < 8; k++) {
526 this_pixel = (fgetc (infp) & 0xFF) +
527 (fgetc (infp) & 0xFF) +
528 (fgetc (infp) & 0xFF);
535 if (this_pixel >= (128 * 3))
541 next_pixels = (next_pixels << 1) | this_pixel;
545 bitmap [(32*17-1) - i] [j] = next_pixels;
548 bitmap [i][j] = next_pixels;
557 if (color_mask != 0x00) {
558 for (i = 32*17-1; i >= 0; i--) {
559 for (j=0; j < 32*18/8; j++) {
560 bitmap [i][j] ^= color_mask;
583 for (i = 0x0; i <= 0xF; i++) {
584 for (j = 0; j < 4; j++) {
586 ((unsigned)bitmap[32 * (i+1) + 4 * j + 8 ][6] << 24 ) |
587 ((
unsigned)bitmap[32 * (i+1) + 4 * j + 8 + 1][6] << 16 ) |
588 ((unsigned)bitmap[32 * (i+1) + 4 * j + 8 + 2][6] << 8 ) |
589 ((
unsigned)bitmap[32 * (i+1) + 4 * j + 8 + 3][6] );
596 for (i = 0; i < 4; i++) {
597 for (j = 0; j < 4; j++) {
599 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 1][i + 3] << 24 ) |
600 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 2][i + 3] << 16 ) |
601 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 3][i + 3] << 8 ) |
602 ((unsigned)bitmap[32 * 0 + 4 * j + 8 + 4][i + 3] );
607 for (i = 4; i < 6; i++) {
608 for (j = 0; j < 4; j++) {
610 ((unsigned)bitmap[32 * 1 + 4 * j + 8 ][i] << 24 ) |
611 ((unsigned)bitmap[32 * 1 + 4 * j + 8 + 1][i] << 16 ) |
612 ((unsigned)bitmap[32 * 1 + 4 * j + 8 + 2][i] << 8 ) |
613 ((unsigned)bitmap[32 * 1 + 4 * j + 8 + 3][i] );
624 for (i = 0x08; i < 0x18; i++) {
625 bitmap[i][7] = (bitmap[i][8] << 4) | ((bitmap[i][ 9] >> 4) & 0xf);
626 bitmap[i][8] = (bitmap[i][9] << 4) | ((bitmap[i][10] >> 4) & 0xf);
628 for (i = 4; i < 6; i++) {
629 for (j = 0; j < 4; j++) {
631 ((unsigned)bitmap[4 * j + 8 + 1][i + 3] << 24 ) |
632 ((unsigned)bitmap[4 * j + 8 + 2][i + 3] << 16 ) |
633 ((unsigned)bitmap[4 * j + 8 + 3][i + 3] << 8 ) |
634 ((unsigned)bitmap[4 * j + 8 + 4][i + 3] );
644 for (i=0; i<6; i++) {
646 for (j = 0x0; !match && j <= 0xF; j++) {
662 for (i = 0x0; i <= 0xf; i++) {
663 for (j = 0x0; j <= 0xf; j++) {
664 for (k = 0; k < 16; k++) {
666 thischar0[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) ];
667 thischar1[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) + 1];
668 thischar2[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) + 2];
669 thischar3[k] = bitmap[32*(j+1) + k + 7][4 * (i+2) + 3];
672 thischar0[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) ];
673 thischar1[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) + 1];
674 thischar2[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) + 2];
675 thischar3[k] = bitmap[32*(i+1) + k + 7][4 * (j+2) + 3];
683 for (k=0; (empty1 || empty2) && k < 16; k++) {
684 if (thischar1[k] != 0) empty1 = 0;
685 if (thischar2[k] != 0) empty2 = 0;
690 if (!empty1 || !empty2) {
706 fprintf (outfp,
"%04X%X%X:",
uniplane, i, j);
708 fprintf (outfp,
"%02X%X%X:",
uniplane, i, j);
709 for (thisrow=0; thisrow<16; thisrow++) {
715 empty2 && !wide[(
uniplane << 8) | (i << 4) | j]) {
720 else if (wide[(
uniplane << 8) | (i << 4) | j] == 4) {
724 thischar0[thisrow], thischar1[thisrow],
725 thischar2[thisrow], thischar3[thisrow] & 0xFE);
730 thischar1[thisrow], thischar2[thisrow]);
733 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