/* $Log: makepkdir.c,v $ * Revision 0.8 92/11/23 19:46:50 19:46:50 bt (Bo Thide') * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support * * Revision 0.7 92/11/13 02:41:34 02:41:34 bt (Bo Thide') * More bug fixes and improvements. Support for PaintJet XL * * Revision 0.6 92/11/10 21:47:50 21:47:50 bt (Bo Thide') * Bug fixes. Added -R option. Better font handling. * * Revision 0.5 92/11/09 16:25:38 16:25:38 bt (Bo Thide') * Rewrite of dospecial.c. Extended \special support * * Revision 0.4 92/11/08 02:45:54 02:45:54 bt (Bo Thide') * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's. * * Revision 0.3 92/08/24 12:43:20 12:43:20 bt (Bo Thide') * Fixed 8 bit (dc font) support. * * Revision 0.2 92/08/23 17:28:58 17:28:58 bt (Bo Thide') * Source cleaned up. Changed certain function calls. Removed globals. * * Revision 0.1 92/08/22 23:58:48 23:58:48 bt (Bo Thide') * First Release. * */ /* * The coding scheme for the different characters in .pk files in general are * not stored in ascending order of the ascii value of the character. Access * to an individual character would need a lot of searching within the * pk buffer. So it is wise, to make a directory for all of the characters * in the .pk font which holds a pointer to the flag byte for each of the * characters when the pkfont is loaded the first time. These pointers are * relative to 'pkbase' and stored into '(cbase + c)->pk_char' of the * corresponding 'font'. */ #include #include "globals.h" #include "macros.h" #include "pk.h" static char rcsid[] = "$Header: makepkdir.c,v 0.8 92/11/23 19:46:50 bt Exp $"; makepkdir() { int flag, i; byte *p, *pc; int format; long ds, hppp, vppp, pkchksum; unsigned cc, pl; for(i=0 ; i<256 ; i++) (cbase + i)->pk_char = 0; p = pkbase + *(pkbase + 2) + 3; ds = getpuquad(p); pkchksum = getpuquad(p); #ifdef DEBUG2 fprintf(stderr,"makepkdir: p-pkbase=%d, ds=%d, pkchksum=%d\n", p-pkbase, ds, pkchksum); #endif /* DEBUG2 */ if(font->checksum != pkchksum) fprintf(stderr,"makepkdir: Checksum mismatch between\n%s and the .dvi file\n", pkname); hppp = getpuquad(p); vppp = getpuquad(p); /* points now to first pk charcter */ font->height = (double)ds/(double)vppp; #ifdef DEBUG2 fprintf(stderr,"makepkdir: ds = %d, hppp = %d, vppp = %d, font->height = %g\n", ds, hppp, vppp, font->height); #endif /* DEBUG2 */ while((flag = getpubyte(p)) != PK_POST) { if(flag < PK_CMD) { pc = p - 1; format = flag & FMASK; if(format < 4) { pl = getpubyte(p); cc = getpubyte(p); p += (format*256 + pl); } else if(format < 7) { pl = getpupair(p); cc = getpubyte(p); p += ((format-4)*65536L + pl); } else { pl = getpuquad(p); cc = getpuquad(p); p += pl; } if(cc < 256) (cbase + cc)->pk_char = pc - pkbase; } else { switch(flag) { case PK_XXX1: pl = getpubyte(p); break; case PK_XXX2: pl = getpupair(p); break; case PK_XXX3: pl = getputrio(p); break; case PK_XXX4: pl = getpuquad(p); break; case PK_YYY: pl = 4; break; case PK_PRE: fprintf(stderr,"PK_PRE command in the .pk font file %s\n", pkname); exit(-1); break; default: pl = 0; break; } p += pl; } } }