X-Git-Url: http://git.shiar.nl/unifont.git/blobdiff_plain/119a78c606ce7e90f07f84f5307628fd5a0837f7..404d6c3d64725519709f0db5a46bb9a183a38f49:/src/unibmp2hex.c diff --git a/src/unibmp2hex.c b/src/unibmp2hex.c index 10dc5bc..3575170 100644 --- a/src/unibmp2hex.c +++ b/src/unibmp2hex.c @@ -45,7 +45,9 @@ unsigned unidigit[6][4]; -int main(int argc, char *argv[]) { +int +main (int argc, char *argv[]) +{ int i, j, k; /* loop variables */ unsigned char inchar; /* temporary input character */ @@ -59,7 +61,7 @@ int main(int argc, char *argv[]) { int tmpsum; /* temporary sum to see if a character is blank */ unsigned char bitmap[17*32][18*32/8]; /* final bitmap */ - char wide[65536]={65536 * 0}; /* 1 = force double width code point */ + char wide[0x200000]={0x200000 * 0}; /* 1 = force double width code point */ char *infile="", *outfile=""; /* names of input and output files */ FILE *infp, *outfp; /* file pointers of input and output files */ @@ -75,25 +77,25 @@ int main(int argc, char *argv[]) { outfile = &argv[i][2]; break; case 'p': /* specify a Unicode plane */ - sscanf(&argv[i][2], "%x", &uniplane); /* Get Unicode plane */ + sscanf (&argv[i][2], "%x", &uniplane); /* Get Unicode plane */ planeset = 1; /* Use specified range, not what's in bitmap */ break; case 'w': /* force wide (16 pixels) for each glyph */ forcewide = 1; break; default: /* if unrecognized option, print list and exit */ - fprintf(stderr, "\nSyntax:\n\n"); - fprintf(stderr, " %s -p ", argv[0]); - fprintf(stderr, "-i -o -w\n\n"); - fprintf(stderr, " -w specifies .wbmp output instead of "); - fprintf(stderr, "default Windows .bmp output.\n\n"); - fprintf(stderr, " -p is followed by 1 to 6 "); - fprintf(stderr, "Unicode plane hex digits "); - fprintf(stderr, "(default is Page 0).\n\n"); - fprintf(stderr, "\nExample:\n\n"); - fprintf(stderr, " %s -p83 -iunifont.hex -ou83.bmp\n\n\n", + fprintf (stderr, "\nSyntax:\n\n"); + fprintf (stderr, " %s -p ", argv[0]); + fprintf (stderr, "-i -o -w\n\n"); + fprintf (stderr, " -w specifies .wbmp output instead of "); + fprintf (stderr, "default Windows .bmp output.\n\n"); + fprintf (stderr, " -p is followed by 1 to 6 "); + fprintf (stderr, "Unicode plane hex digits "); + fprintf (stderr, "(default is Page 0).\n\n"); + fprintf (stderr, "\nExample:\n\n"); + fprintf (stderr, " %s -p83 -iunifont.hex -ou83.bmp\n\n\n", argv[0]); - exit(1); + exit (1); } } } @@ -102,19 +104,19 @@ int main(int argc, char *argv[]) { Make sure we can open any I/O files that were specified before doing anything else. */ - if (strlen(infile) > 0) { - if ((infp = fopen(infile, "r")) == NULL) { - fprintf(stderr, "Error: can't open %s for input.\n", infile); - exit(1); + if (strlen (infile) > 0) { + if ((infp = fopen (infile, "r")) == NULL) { + fprintf (stderr, "Error: can't open %s for input.\n", infile); + exit (1); } } else { infp = stdin; } - if (strlen(outfile) > 0) { - if ((outfp = fopen(outfile, "w")) == NULL) { - fprintf(stderr, "Error: can't open %s for output.\n", outfile); - exit(1); + if (strlen (outfile) > 0) { + if ((outfp = fopen (outfile, "w")) == NULL) { + fprintf (stderr, "Error: can't open %s for output.\n", outfile); + exit (1); } } else { @@ -153,6 +155,17 @@ int main(int argc, char *argv[]) { wide[0x303F] = 0; /* CJK half-space fill */ + /* Supplemental Multilingual Plane (Plane 01) */ + for (i = 0x010A00; i <= 0x010A5F; i++) wide[i] = 1; /* Kharoshthi */ + for (i = 0x011000; i <= 0x01107F; i++) wide[i] = 1; /* Brahmi */ + for (i = 0x011080; i <= 0x0110CF; i++) wide[i] = 1; /* Kaithi */ + for (i = 0x011100; i <= 0x01114F; i++) wide[i] = 1; /* Chakma */ + for (i = 0x011180; i <= 0x0111DF; i++) wide[i] = 1; /* Sharada */ + for (i = 0x011680; i <= 0x0116CF; i++) wide[i] = 1; /* Takri */ + for (i = 0x016F00; i <= 0x016F9F; i++) wide[i] = 1; /* Mino */ + for (i = 0x01D100; i <= 0x01D1FF; i++) wide[i] = 1; /* Musical Symbols */ + for (i = 0x01D200; i <= 0x01D24F; i++) wide[i] = 1; /* Ancient Greek Musical Notation */ + /* Determine whether or not the file is a Microsoft Windows Bitmap file. If it starts with 'B', 'M', assume it's a Windows Bitmap file. @@ -163,8 +176,8 @@ int main(int argc, char *argv[]) { all bets are off. */ fatal = 0; /* assume everything is okay with reading input file */ - if ((header[0] = fgetc(infp)) != EOF) { - if ((header[1] = fgetc(infp)) != EOF) { + if ((header[0] = fgetc (infp)) != EOF) { + if ((header[1] = fgetc (infp)) != EOF) { if (header[0] == 'B' && header[1] == 'M') { wbmp = 0; /* Not a Wireless Bitmap -- it's a Windows Bitmap */ } @@ -179,8 +192,8 @@ int main(int argc, char *argv[]) { fatal = 1; if (fatal) { - fprintf(stderr, "Fatal error; end of input file.\n\n"); - exit(1); + fprintf (stderr, "Fatal error; end of input file.\n\n"); + exit (1); } /* If this is a Wireless Bitmap (.wbmp) format file, @@ -188,13 +201,13 @@ int main(int argc, char *argv[]) { */ if (wbmp) { for (i=2; i<6; i++) - header[i] = fgetc(infp); + header[i] = fgetc (infp); /* Now read the bitmap. */ for (i=0; i < 32*17; i++) { for (j=0; j < 32*18/8; j++) { - inchar = fgetc(infp); + inchar = fgetc (infp); bitmap[i][j] = ~inchar; /* invert bits for proper color */ } } @@ -206,13 +219,13 @@ int main(int argc, char *argv[]) { */ else { for (i=2; i<0x3e; i++) - header[i] = fgetc(infp); + header[i] = fgetc (infp); /* Now read the bitmap. */ for (i = 32*17-1; i >= 0; i--) { for (j=0; j < 32*18/8; j++) { - inchar = fgetc(infp); + inchar = fgetc (infp); bitmap[i][j] = ~inchar; /* invert bits for proper color */ } } @@ -220,7 +233,7 @@ int main(int argc, char *argv[]) { /* We've read the entire file. Now close the input file pointer. */ - fclose(infp); + fclose (infp); /* We now have the header portion in the header[] array, and have the bitmap portion from top-to-bottom in the bitmap[] array. @@ -352,9 +365,9 @@ int main(int argc, char *argv[]) { the normal Unicode range, but this has not been fully tested. */ if (uniplane > 0xff) - fprintf(outfp, "%04X%X%X:", uniplane, i, j); // 6 digit code pt. + fprintf (outfp, "%04X%X%X:", uniplane, i, j); // 6 digit code pt. else - fprintf(outfp, "%02X%X%X:", uniplane, i, j); // 4 digit code pt. + fprintf (outfp, "%02X%X%X:", uniplane, i, j); // 4 digit code pt. for (thisrow=0; thisrow<16; thisrow++) { /* If second half is empty and we're not forcing this @@ -362,17 +375,17 @@ int main(int argc, char *argv[]) { */ if (!forcewide && empty2 && !wide[(uniplane << 8) | (i << 4) | j]) - fprintf(outfp, + fprintf (outfp, "%02X", thischar1[thisrow]); else - fprintf(outfp, + fprintf (outfp, "%02X%02X", thischar1[thisrow], thischar2[thisrow]); } - fprintf(outfp, "\n"); + fprintf (outfp, "\n"); } } } - exit(0); + exit (0); }