63       "0030:00000000182442424242424224180000",  
 
   64       "0031:000000000818280808080808083E0000",  
 
   65       "0032:000000003C4242020C102040407E0000",  
 
   66       "0033:000000003C4242021C020242423C0000",  
 
   67       "0034:00000000040C142444447E0404040000",  
 
   68       "0035:000000007E4040407C020202423C0000",  
 
   69       "0036:000000001C2040407C424242423C0000",  
 
   70       "0037:000000007E0202040404080808080000",  
 
   71       "0038:000000003C4242423C424242423C0000",  
 
   72       "0039:000000003C4242423E02020204380000",  
 
   73       "0041:0000000018242442427E424242420000",  
 
   74       "0042:000000007C4242427C424242427C0000",  
 
   75       "0043:000000003C42424040404042423C0000",  
 
   76       "0044:00000000784442424242424244780000",  
 
   77       "0045:000000007E4040407C404040407E0000",  
 
   78       "0046:000000007E4040407C40404040400000",  
 
   79       "0055:000000004242424242424242423C0000",  
 
   80       "002B:0000000000000808087F080808000000"    
   96 main (
int argc, 
char *argv[])
 
  106    unsigned char thischarbyte; 
 
  113    unsigned char bitmap[17*32][18*4]; 
 
  114    unsigned char charbits[32][4];  
 
  116    char *infile=
"", *outfile=
"";  
 
  122    bitmapsize = 17*32*18*4;  
 
  125       for (i = 1; i < argc; i++) {
 
  126          if (argv[i][0] == 
'-') {  
 
  127             switch (argv[i][1]) {
 
  132                   infile = &argv[i][2];
 
  135                   outfile = &argv[i][2];
 
  138                   sscanf (&argv[i][2], 
"%x", &
unipage); 
 
  144                   fprintf (stderr, 
"\nSyntax:\n\n");
 
  145                   fprintf (stderr, 
"   %s -p<Unicode_Page> ", argv[0]);
 
  146                   fprintf (stderr, 
"-i<Input_File> -o<Output_File> -w\n\n");
 
  147                   fprintf (stderr, 
"   -w specifies .wbmp output instead of ");
 
  148                   fprintf (stderr, 
"default Windows .bmp output.\n\n");
 
  149                   fprintf (stderr, 
"   -p is followed by 1 to 6 ");
 
  150                   fprintf (stderr, 
"Unicode page hex digits ");
 
  151                   fprintf (stderr, 
"(default is Page 0).\n\n");
 
  152                   fprintf (stderr, 
"\nExample:\n\n");
 
  153                   fprintf (stderr, 
"   %s -p83 -iunifont.hex -ou83.bmp\n\n\n",
 
  164    if (strlen (infile) > 0) {
 
  165       if ((infp = fopen (infile, 
"r")) == NULL) {
 
  166          fprintf (stderr, 
"Error: can't open %s for input.\n", infile);
 
  173    if (strlen (outfile) > 0) {
 
  174       if ((outfp = fopen (outfile, 
"w")) == NULL) {
 
  175          fprintf (stderr, 
"Error: can't open %s for output.\n", outfile);
 
  188    while (lastpage <= 
unipage && fgets (inbuf, 
MAXBUF-1, infp) != NULL) {
 
  189       sscanf (inbuf, 
"%x", &thischar);
 
  190       lastpage = thischar >> 8; 
 
  192          thischarbyte = (
unsigned char)(thischar & 0xff);
 
  193          for (k0=0; inbuf[k0] != 
':'; k0++);
 
  195          hex2bit (&inbuf[k0], charbits);  
 
  203          thiscol = (thischarbyte & 0xf) + 2;  
 
  204          thischarrow = thischarbyte >> 4;     
 
  207             thiscol = thischarrow;
 
  212          toppixelrow = 32 * (thischarrow + 1) - 1; 
 
  220          for (i=8; i<24; i++) {
 
  221             bitmap[toppixelrow + i][(thiscol << 2) | 0] =
 
  222                ~charbits[i][0] & 0xff;
 
  223             bitmap[toppixelrow + i][(thiscol << 2) | 1] =
 
  224                ~charbits[i][1] & 0xff;
 
  225             bitmap[toppixelrow + i][(thiscol << 2) | 2] =
 
  226                ~charbits[i][2] & 0xff;
 
  228             bitmap[toppixelrow + i][(thiscol << 2) | 3] =
 
  229                ~charbits[i][3] & 0xfe;
 
  235          bitmap[toppixelrow +  8][(thiscol << 2) | 3] |= 1;
 
  236          bitmap[toppixelrow + 14][(thiscol << 2) | 3] |= 1;
 
  237          bitmap[toppixelrow + 15][(thiscol << 2) | 3] |= 1;
 
  238          bitmap[toppixelrow + 23][(thiscol << 2) | 3] |= 1;
 
  249       fprintf (outfp, 
"%c", 0x00); 
 
  250       fprintf (outfp, 
"%c", 0x00); 
 
  251       fprintf (outfp, 
"%c%c", 0x84, 0x40); 
 
  252       fprintf (outfp, 
"%c%c", 0x84, 0x20); 
 
  256       for (toppixelrow=0; toppixelrow <= 17*32-1; toppixelrow++) {
 
  257          for (j=0; j<18; j++) {
 
  258             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2)    ]);
 
  259             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2) | 1]);
 
  260             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2) | 2]);
 
  261             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2) | 3]);
 
  271       fprintf (outfp, 
"%c%c", 0x42, 0x4d);
 
  274       filesize   = 0x3E + bitmapsize;
 
  275       fprintf (outfp, 
"%c", (
unsigned char)((filesize        ) & 0xff));
 
  276       fprintf (outfp, 
"%c", (
unsigned char)((filesize >> 0x08) & 0xff));
 
  277       fprintf (outfp, 
"%c", (
unsigned char)((filesize >> 0x10) & 0xff));
 
  278       fprintf (outfp, 
"%c", (
unsigned char)((filesize >> 0x18) & 0xff));
 
  281       fprintf (outfp, 
"%c%c%c%c", 0x00, 0x00, 0x00, 0x00);
 
  284       fprintf (outfp, 
"%c%c%c%c", 0x3E, 0x00, 0x00, 0x00);
 
  287       fprintf (outfp, 
"%c%c%c%c", 0x28, 0x00, 0x00, 0x00);
 
  290       fprintf (outfp, 
"%c%c%c%c", 0x40, 0x02, 0x00, 0x00);
 
  293       fprintf (outfp, 
"%c%c%c%c", 0x20, 0x02, 0x00, 0x00);
 
  296       fprintf (outfp, 
"%c%c", 0x01, 0x00);
 
  299       fprintf (outfp, 
"%c%c", 0x01, 0x00);
 
  302       fprintf (outfp, 
"%c%c%c%c", 0x00, 0x00, 0x00, 0x00);
 
  305       fprintf (outfp, 
"%c", (
unsigned char)((bitmapsize        ) & 0xff));
 
  306       fprintf (outfp, 
"%c", (
unsigned char)((bitmapsize >> 0x08) & 0xff));
 
  307       fprintf (outfp, 
"%c", (
unsigned char)((bitmapsize >> 0x10) & 0xff));
 
  308       fprintf (outfp, 
"%c", (
unsigned char)((bitmapsize >> 0x18) & 0xff));
 
  311       fprintf (outfp, 
"%c%c%c%c", 0xC4, 0x0E, 0x00, 0x00);
 
  314       fprintf (outfp, 
"%c%c%c%c", 0xC4, 0x0E, 0x00, 0x00);
 
  317       fprintf (outfp, 
"%c%c%c%c", 0x02, 0x00, 0x00, 0x00);
 
  320       fprintf (outfp, 
"%c%c%c%c", 0x02, 0x00, 0x00, 0x00);
 
  323       fprintf (outfp, 
"%c%c%c%c", 0x00, 0x00, 0x00, 0x00);
 
  326       fprintf (outfp, 
"%c%c%c%c", 0xFF, 0xFF, 0xFF, 0x00);
 
  333       for (toppixelrow=17*32-1; toppixelrow >= 0; toppixelrow--) {
 
  334          for (j=0; j<18; j++) {
 
  335             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2)    ]);
 
  336             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2) | 1]);
 
  337             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2) | 2]);
 
  339             fprintf (outfp, 
"%c", bitmap[toppixelrow][(j<<2) | 3]);
 
  361 hex2bit (
char *instring, 
unsigned char character[32][4])
 
  370       character[i][0] = character[i][1] = character[i][2] = character[i][3] = 0; 
 
  373    if (strlen (instring) <= 34)  
 
  375    else if (strlen (instring) <= 66)  
 
  377    else if (strlen (instring) <= 98)  
 
  382    k = (width > 1) ? 0 : 1; 
 
  384    for (i=8; i<24; i++) {  
 
  385       sscanf (&instring[j], 
"%2hhx", &character[i][k]);
 
  388          sscanf (&instring[j], 
"%2hhx", &character[i][k+1]);
 
  391             sscanf (&instring[j], 
"%2hhx", &character[i][k+2]);
 
  394                sscanf (&instring[j], 
"%2hhx", &character[i][k+3]);
 
  412 init (
unsigned char bitmap[17*32][18*4])
 
  415    unsigned char charbits[32][4];  
 
  416    unsigned toppixelrow;
 
  418    unsigned char pnybble0, pnybble1, pnybble2, pnybble3;
 
  420    for (i=0; i<18; i++) { 
 
  424       for (j=0; j<32; j++) 
hexbits[i][j] = ~charbits[j][1];
 
  430    for (toppixelrow=0; toppixelrow < 17*32; toppixelrow++) {
 
  431       for (thiscol=0; thiscol<18; thiscol++) {
 
  432          bitmap[toppixelrow][(thiscol << 2)    ] = 0xff;
 
  433          bitmap[toppixelrow][(thiscol << 2) | 1] = 0xff;
 
  434          bitmap[toppixelrow][(thiscol << 2) | 2] = 0xff;
 
  435          bitmap[toppixelrow][(thiscol << 2) | 3] = 0xff;
 
  443    pnybble2 = (
unipage >> 16) & 0xf;
 
  444    pnybble1 = (
unipage >> 12) & 0xf;
 
  445    pnybble0 = (
unipage >>  8) & 0xf;
 
  446    for (i=0; i<32; i++) {
 
  449       bitmap[i][3] = 
hexbits[pnybble3][i];
 
  450       bitmap[i][4] = 
hexbits[pnybble2][i];
 
  451       bitmap[i][5] = 
hexbits[pnybble1][i];
 
  452       bitmap[i][6] = 
hexbits[pnybble0][i];
 
  457    pnybble3 = (
unipage >> 4) & 0xf;  
 
  462    toppixelrow = 32 * 17 - 1; 
 
  469    for (i=0; i<16; i++) {
 
  470       for (j=0; j<32; j++) {
 
  472             bitmap[j][((i+2) << 2) | 0]  = (
hexbits[pnybble3][j] >> 4) | 0xf0;
 
  473             bitmap[j][((i+2) << 2) | 1]  = (
hexbits[pnybble3][j] << 4) |
 
  475             bitmap[j][((i+2) << 2) | 2]  = (
hexbits[pnybble2][j] << 4) |
 
  477             bitmap[j][((i+2) << 2) | 3]  = (
hexbits[i][j] << 4) | 0x0f;
 
  480             bitmap[j][((i+2) << 2) | 1] = (
hexbits[i][j] >> 4) | 0xf0;
 
  481             bitmap[j][((i+2) << 2) | 2] = (
hexbits[i][j] << 4) | 0x0f;
 
  488    for (i=0; i<16; i++) {
 
  489       toppixelrow = 32 * (i + 1) - 1; 
 
  491       for (j=0; j<32; j++) {
 
  493             bitmap[toppixelrow + j][4] = 
hexbits[pnybble3][j];
 
  494             bitmap[toppixelrow + j][5] = 
hexbits[pnybble2][j];
 
  496          bitmap[toppixelrow + j][6] = 
hexbits[i][j];
 
  503    for (i=1*32; i<17*32; i++) {
 
  506       else if ((i & 0x1f) == 14)
 
  508       else if ((i & 0x1f) == 22)
 
  510       for (j=1; j<18; j++) {
 
  511          bitmap[i][(j << 2) | 3] &= 0xfe;
 
  515    for (i=1*32-1; i<18*32-1; i+=32) {
 
  516       for (j=2; j<18; j++) {
 
  517          bitmap[i][(j << 2)    ] = 0x00;
 
  518          bitmap[i][(j << 2) | 1] = 0x81;
 
  519          bitmap[i][(j << 2) | 2] = 0x81;
 
  520          bitmap[i][(j << 2) | 3] = 0x00;
 
  524    bitmap[31][7] = 0xfe;
 
#define MAXBUF
Maximum allowable input file line length - 1.
int init(unsigned char bitmap[17 *32][18 *4])
Initialize the bitmap grid.
int main(int argc, char *argv[])
The main function.
int hex2bit(char *instring, unsigned char character[32][4])
Generate a bitmap for one glyph.
unsigned unipage
Unicode page number, 0x00..0xff.
int flip
Transpose entire matrix as in Unicode book.
unsigned char hexbits[18][32]
The digits converted into bitmaps.
char * hex[18]
GNU Unifont bitmaps for hexadecimal digits.