home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / dvi2pcl.lha / makepkdir.c < prev    next >
C/C++ Source or Header  |  1992-11-25  |  3KB  |  121 lines

  1. /* $Log:    makepkdir.c,v $
  2.  * Revision 0.8  92/11/23  19:46:50  19:46:50  bt (Bo Thide')
  3.  * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
  4.  * 
  5.  * Revision 0.7  92/11/13  02:41:34  02:41:34  bt (Bo Thide')
  6.  * More bug fixes and improvements. Support for PaintJet XL
  7.  * 
  8.  * Revision 0.6  92/11/10  21:47:50  21:47:50  bt (Bo Thide')
  9.  * Bug fixes. Added -R option. Better font handling.
  10.  * 
  11.  * Revision 0.5  92/11/09  16:25:38  16:25:38  bt (Bo Thide')
  12.  * Rewrite of dospecial.c. Extended \special support
  13.  * 
  14.  * Revision 0.4  92/11/08  02:45:54  02:45:54  bt (Bo Thide')
  15.  * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
  16.  * 
  17.  * Revision 0.3  92/08/24  12:43:20  12:43:20  bt (Bo Thide')
  18.  * Fixed 8 bit (dc font) support.
  19.  * 
  20.  * Revision 0.2  92/08/23  17:28:58  17:28:58  bt (Bo Thide')
  21.  * Source cleaned up.  Changed certain function calls.  Removed globals.
  22.  * 
  23.  * Revision 0.1  92/08/22  23:58:48  23:58:48  bt (Bo Thide')
  24.  * First Release.
  25.  *  */
  26.  
  27. /*
  28.  * The coding scheme for the different characters in .pk files in general are
  29.  * not stored in ascending order of the ascii value of the character. Access
  30.  * to an individual character would need a lot of searching within the
  31.  * pk buffer. So it is wise, to make a directory for all of the characters
  32.  * in the .pk font which holds a pointer to the flag byte for each of the
  33.  * characters when the pkfont is loaded the first time. These pointers are
  34.  * relative to 'pkbase' and stored into '(cbase + c)->pk_char' of the
  35.  * corresponding 'font'.
  36.  */
  37.  
  38. #include <stdio.h>
  39. #include "globals.h"
  40. #include "macros.h"
  41. #include "pk.h"
  42.  
  43. static char rcsid[] = "$Header: makepkdir.c,v 0.8 92/11/23 19:46:50 bt Exp $";
  44.  
  45. makepkdir()
  46. {
  47.     int        flag, i;
  48.     byte        *p, *pc;
  49.     int        format;
  50.     long        ds, hppp, vppp, pkchksum;
  51.     unsigned    cc, pl;
  52.  
  53.     for(i=0 ; i<256 ; i++)
  54.         (cbase + i)->pk_char = 0;
  55.     p = pkbase + *(pkbase + 2) + 3;
  56.     ds = getpuquad(p);
  57.     pkchksum = getpuquad(p);
  58. #ifdef DEBUG2
  59.     fprintf(stderr,"makepkdir: p-pkbase=%d, ds=%d, pkchksum=%d\n", p-pkbase, ds, pkchksum);
  60. #endif /* DEBUG2 */
  61.     if(font->checksum != pkchksum)
  62.         fprintf(stderr,"makepkdir: Checksum mismatch between\n%s and the .dvi file\n", pkname);
  63.     hppp = getpuquad(p);
  64.     vppp = getpuquad(p);        /* points now to first pk charcter */
  65.  
  66.     font->height = (double)ds/(double)vppp;
  67. #ifdef DEBUG2
  68.     fprintf(stderr,"makepkdir: ds = %d, hppp = %d, vppp = %d, font->height = %g\n", ds, hppp, vppp, font->height);
  69. #endif /* DEBUG2 */
  70.  
  71.     while((flag = getpubyte(p)) != PK_POST) { 
  72.         if(flag < PK_CMD) { 
  73.             pc = p - 1;
  74.             format = flag & FMASK;
  75.             if(format < 4) { 
  76.                 pl = getpubyte(p);
  77.                 cc = getpubyte(p);
  78.                 p += (format*256 + pl);
  79.             }
  80.             else if(format < 7) { 
  81.                 pl = getpupair(p);
  82.                 cc = getpubyte(p);
  83.                 p += ((format-4)*65536L + pl);
  84.             }
  85.             else { 
  86.                 pl = getpuquad(p);
  87.                 cc = getpuquad(p);
  88.                 p += pl;
  89.             }
  90.             if(cc < 256) (cbase + cc)->pk_char =  pc - pkbase;
  91.         }
  92.         else { 
  93.             switch(flag) { 
  94.             case PK_XXX1:
  95.                 pl = getpubyte(p);
  96.                 break;
  97.             case PK_XXX2:
  98.                 pl = getpupair(p);
  99.                 break;
  100.             case PK_XXX3:
  101.                 pl = getputrio(p);
  102.                 break;
  103.             case PK_XXX4:
  104.                 pl = getpuquad(p);
  105.                 break;
  106.             case PK_YYY:
  107.                 pl = 4;
  108.                 break;
  109.             case PK_PRE:
  110.                 fprintf(stderr,"PK_PRE command in the .pk font file %s\n", pkname);
  111.                 exit(-1);
  112.                 break;
  113.             default:
  114.                 pl = 0;
  115.                 break;
  116.             }
  117.             p += pl;
  118.         }
  119.     }
  120. }
  121.