66 "0030:00000000182442424242424224180000",
67 "0031:000000000818280808080808083E0000",
68 "0032:000000003C4242020C102040407E0000",
69 "0033:000000003C4242021C020242423C0000",
70 "0034:00000000040C142444447E0404040000",
71 "0035:000000007E4040407C020202423C0000",
72 "0036:000000001C2040407C424242423C0000",
73 "0037:000000007E0202040404080808080000",
74 "0038:000000003C4242423C424242423C0000",
75 "0039:000000003C4242423E02020204380000",
76 "0041:0000000018242442427E424242420000",
77 "0042:000000007C4242427C424242427C0000",
78 "0043:000000003C42424040404042423C0000",
79 "0044:00000000784442424242424244780000",
80 "0045:000000007E4040407C404040407E0000",
81 "0046:000000007E4040407C40404040400000",
82 "0055:000000004242424242424242423C0000",
83 "002B:0000000000000808087F080808000000"
99main (
int argc,
char *argv[])
109 unsigned char thischarbyte;
116 unsigned char bitmap[17*32][18*4];
117 unsigned char charbits[32][4];
119 char *infile=
"", *outfile=
"";
123 int init (
unsigned char bitmap[17*32][18*4]);
126 int hex2bit (
char *instring,
unsigned char character[32][4]);
128 bitmapsize = 17*32*18*4;
131 for (i = 1; i < argc; i++) {
132 if (argv[i][0] ==
'-') {
133 switch (argv[i][1]) {
138 infile = &argv[i][2];
141 outfile = &argv[i][2];
144 sscanf (&argv[i][2],
"%x", &
unipage);
150 fprintf (stderr,
"\nSyntax:\n\n");
151 fprintf (stderr,
" %s -p<Unicode_Page> ", argv[0]);
152 fprintf (stderr,
"-i<Input_File> -o<Output_File> -w\n\n");
153 fprintf (stderr,
" -w specifies .wbmp output instead of ");
154 fprintf (stderr,
"default Windows .bmp output.\n\n");
155 fprintf (stderr,
" -p is followed by 1 to 6 ");
156 fprintf (stderr,
"Unicode page hex digits ");
157 fprintf (stderr,
"(default is Page 0).\n\n");
158 fprintf (stderr,
"\nExample:\n\n");
159 fprintf (stderr,
" %s -p83 -iunifont.hex -ou83.bmp\n\n\n",
170 if (strlen (infile) > 0) {
171 if ((infp = fopen (infile,
"r")) == NULL) {
172 fprintf (stderr,
"Error: can't open %s for input.\n", infile);
179 if (strlen (outfile) > 0) {
180 if ((outfp = fopen (outfile,
"w")) == NULL) {
181 fprintf (stderr,
"Error: can't open %s for output.\n", outfile);
194 while (lastpage <=
unipage && fgets (inbuf,
MAXBUF-1, infp) != NULL) {
195 sscanf (inbuf,
"%x", &thischar);
196 lastpage = thischar >> 8;
198 thischarbyte = (
unsigned char)(thischar & 0xff);
199 for (k0=0; inbuf[k0] !=
':'; k0++);
201 hex2bit (&inbuf[k0], charbits);
209 thiscol = (thischarbyte & 0xf) + 2;
210 thischarrow = thischarbyte >> 4;
213 thiscol = thischarrow;
218 toppixelrow = 32 * (thischarrow + 1) - 1;
226 for (i=8; i<24; i++) {
227 bitmap[toppixelrow + i][(thiscol << 2) | 0] =
228 ~charbits[i][0] & 0xff;
229 bitmap[toppixelrow + i][(thiscol << 2) | 1] =
230 ~charbits[i][1] & 0xff;
231 bitmap[toppixelrow + i][(thiscol << 2) | 2] =
232 ~charbits[i][2] & 0xff;
234 bitmap[toppixelrow + i][(thiscol << 2) | 3] =
235 ~charbits[i][3] & 0xfe;
241 bitmap[toppixelrow + 8][(thiscol << 2) | 3] |= 1;
242 bitmap[toppixelrow + 14][(thiscol << 2) | 3] |= 1;
243 bitmap[toppixelrow + 15][(thiscol << 2) | 3] |= 1;
244 bitmap[toppixelrow + 23][(thiscol << 2) | 3] |= 1;
255 fprintf (outfp,
"%c", 0x00);
256 fprintf (outfp,
"%c", 0x00);
257 fprintf (outfp,
"%c%c", 0x84, 0x40);
258 fprintf (outfp,
"%c%c", 0x84, 0x20);
262 for (toppixelrow=0; toppixelrow <= 17*32-1; toppixelrow++) {
263 for (j=0; j<18; j++) {
264 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) ]);
265 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) | 1]);
266 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) | 2]);
267 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) | 3]);
277 fprintf (outfp,
"%c%c", 0x42, 0x4d);
280 filesize = 0x3E + bitmapsize;
281 fprintf (outfp,
"%c", (
unsigned char)((filesize ) & 0xff));
282 fprintf (outfp,
"%c", (
unsigned char)((filesize >> 0x08) & 0xff));
283 fprintf (outfp,
"%c", (
unsigned char)((filesize >> 0x10) & 0xff));
284 fprintf (outfp,
"%c", (
unsigned char)((filesize >> 0x18) & 0xff));
287 fprintf (outfp,
"%c%c%c%c", 0x00, 0x00, 0x00, 0x00);
290 fprintf (outfp,
"%c%c%c%c", 0x3E, 0x00, 0x00, 0x00);
293 fprintf (outfp,
"%c%c%c%c", 0x28, 0x00, 0x00, 0x00);
296 fprintf (outfp,
"%c%c%c%c", 0x40, 0x02, 0x00, 0x00);
299 fprintf (outfp,
"%c%c%c%c", 0x20, 0x02, 0x00, 0x00);
302 fprintf (outfp,
"%c%c", 0x01, 0x00);
305 fprintf (outfp,
"%c%c", 0x01, 0x00);
308 fprintf (outfp,
"%c%c%c%c", 0x00, 0x00, 0x00, 0x00);
311 fprintf (outfp,
"%c", (
unsigned char)((bitmapsize ) & 0xff));
312 fprintf (outfp,
"%c", (
unsigned char)((bitmapsize >> 0x08) & 0xff));
313 fprintf (outfp,
"%c", (
unsigned char)((bitmapsize >> 0x10) & 0xff));
314 fprintf (outfp,
"%c", (
unsigned char)((bitmapsize >> 0x18) & 0xff));
317 fprintf (outfp,
"%c%c%c%c", 0xC4, 0x0E, 0x00, 0x00);
320 fprintf (outfp,
"%c%c%c%c", 0xC4, 0x0E, 0x00, 0x00);
323 fprintf (outfp,
"%c%c%c%c", 0x02, 0x00, 0x00, 0x00);
326 fprintf (outfp,
"%c%c%c%c", 0x02, 0x00, 0x00, 0x00);
329 fprintf (outfp,
"%c%c%c%c", 0x00, 0x00, 0x00, 0x00);
332 fprintf (outfp,
"%c%c%c%c", 0xFF, 0xFF, 0xFF, 0x00);
339 for (toppixelrow=17*32-1; toppixelrow >= 0; toppixelrow--) {
340 for (j=0; j<18; j++) {
341 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) ]);
342 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) | 1]);
343 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) | 2]);
345 fprintf (outfp,
"%c", bitmap[toppixelrow][(j<<2) | 3]);
367hex2bit (
char *instring,
unsigned char character[32][4])
376 character[i][0] = character[i][1] = character[i][2] = character[i][3] = 0;
379 if (strlen (instring) <= 34)
381 else if (strlen (instring) <= 66)
383 else if (strlen (instring) <= 98)
388 k = (width > 1) ? 0 : 1;
390 for (i=8; i<24; i++) {
391 sscanf (&instring[j],
"%2hhx", &character[i][k]);
394 sscanf (&instring[j],
"%2hhx", &character[i][k+1]);
397 sscanf (&instring[j],
"%2hhx", &character[i][k+2]);
400 sscanf (&instring[j],
"%2hhx", &character[i][k+3]);
418init (
unsigned char bitmap[17*32][18*4])
421 unsigned char charbits[32][4];
422 unsigned toppixelrow;
424 unsigned char pnybble0, pnybble1, pnybble2, pnybble3;
426 for (i=0; i<18; i++) {
430 for (j=0; j<32; j++)
hexbits[i][j] = ~charbits[j][1];
436 for (toppixelrow=0; toppixelrow < 17*32; toppixelrow++) {
437 for (thiscol=0; thiscol<18; thiscol++) {
438 bitmap[toppixelrow][(thiscol << 2) ] = 0xff;
439 bitmap[toppixelrow][(thiscol << 2) | 1] = 0xff;
440 bitmap[toppixelrow][(thiscol << 2) | 2] = 0xff;
441 bitmap[toppixelrow][(thiscol << 2) | 3] = 0xff;
449 pnybble2 = (
unipage >> 16) & 0xf;
450 pnybble1 = (
unipage >> 12) & 0xf;
451 pnybble0 = (
unipage >> 8) & 0xf;
452 for (i=0; i<32; i++) {
455 bitmap[i][3] =
hexbits[pnybble3][i];
456 bitmap[i][4] =
hexbits[pnybble2][i];
457 bitmap[i][5] =
hexbits[pnybble1][i];
458 bitmap[i][6] =
hexbits[pnybble0][i];
463 pnybble3 = (
unipage >> 4) & 0xf;
468 toppixelrow = 32 * 17 - 1;
475 for (i=0; i<16; i++) {
476 for (j=0; j<32; j++) {
478 bitmap[j][((i+2) << 2) | 0] = (
hexbits[pnybble3][j] >> 4) | 0xf0;
479 bitmap[j][((i+2) << 2) | 1] = (
hexbits[pnybble3][j] << 4) |
481 bitmap[j][((i+2) << 2) | 2] = (
hexbits[pnybble2][j] << 4) |
483 bitmap[j][((i+2) << 2) | 3] = (
hexbits[i][j] << 4) | 0x0f;
486 bitmap[j][((i+2) << 2) | 1] = (
hexbits[i][j] >> 4) | 0xf0;
487 bitmap[j][((i+2) << 2) | 2] = (
hexbits[i][j] << 4) | 0x0f;
494 for (i=0; i<16; i++) {
495 toppixelrow = 32 * (i + 1) - 1;
497 for (j=0; j<32; j++) {
499 bitmap[toppixelrow + j][4] =
hexbits[pnybble3][j];
500 bitmap[toppixelrow + j][5] =
hexbits[pnybble2][j];
502 bitmap[toppixelrow + j][6] =
hexbits[i][j];
509 for (i=1*32; i<17*32; i++) {
512 else if ((i & 0x1f) == 14)
514 else if ((i & 0x1f) == 22)
516 for (j=1; j<18; j++) {
517 bitmap[i][(j << 2) | 3] &= 0xfe;
521 for (i=1*32-1; i<18*32-1; i+=32) {
522 for (j=2; j<18; j++) {
523 bitmap[i][(j << 2) ] = 0x00;
524 bitmap[i][(j << 2) | 1] = 0x81;
525 bitmap[i][(j << 2) | 2] = 0x81;
526 bitmap[i][(j << 2) | 3] = 0x00;
530 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.