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

  1. /* $Log:    pkcharinfo.c,v $
  2.  * Revision 0.8  92/11/23  19:46:52  19:46:52  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:36  02:41:36  bt (Bo Thide')
  6.  * More bug fixes and improvements. Support for PaintJet XL
  7.  * 
  8.  * Revision 0.6  92/11/10  21:48:34  21:48:34  bt (Bo Thide')
  9.  * Bug fixes. Added -R option. Better font handling.
  10.  * 
  11.  * Revision 0.5  92/11/09  16:25:40  16:25:40  bt (Bo Thide')
  12.  * Rewrite of dospecial.c. Extended \special support
  13.  * 
  14.  * Revision 0.4  92/11/08  02:45:56  02:45:56  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:45:47  12:45:47  bt (Bo Thide')
  18.  * Fixed 8 bit (dc font) support.
  19.  * 
  20.  * Revision 0.2  92/08/23  17:28:59  17:28:59  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.  * This routine determines the global variables 
  29.  *    c_flag, dyn_f, c_width, c_height, c_hoffset, c_voffset
  30.  * for the character c. (cbase + c)->pk_char points to its flag byte relative
  31.  * to pkbase. It returns a pointer, which points to the first run count of
  32.  * the character in progress.
  33.  */
  34.  
  35. #include <stdio.h>
  36. #include "globals.h"
  37. #include "macros.h"
  38.  
  39. byte *pkcharinfo(c)
  40. int c;
  41.     int format;
  42.     byte *p;
  43.     charfmt *u;
  44.     long tfm;
  45.  
  46.     u = cbase + c;
  47.     if(u->pk_char == 0) {
  48.         c_flag = dyn_f = c_width = c_height = c_hoffset = c_voffset = 0;
  49.         if(verbose)
  50.             fprintf(stderr, "Character %d does not exist in this font\n",c);
  51.         return(NULL);
  52.     }
  53.     p = pkbase + u->pk_char;
  54.     c_flag = getpubyte(p);
  55.     dyn_f = c_flag >> 4;
  56.     format = c_flag & FMASK;
  57.  
  58.     if(format < 4) {
  59.         p += 2;
  60.         tfm = getputrio(p);
  61.         p++;
  62.         c_width = getpubyte(p);
  63.         c_height = getpubyte(p);
  64.         c_hoffset = getpsbyte(p);
  65.         c_voffset = getpsbyte(p);
  66.     }
  67.     else if(format < 7) {
  68.         p += 3;
  69.         tfm = getputrio(p);        
  70.         p += 2;
  71.         c_width = getpupair(p);
  72.         c_height = getpupair(p);
  73.         c_hoffset = getpspair(p);
  74.         c_voffset = getpspair(p);
  75.     }
  76.     else {
  77.         p += 8;
  78.         tfm = getpuquad(p);        
  79.         p += 8;
  80.         c_width = getpuquad(p);
  81.         c_height = getpuquad(p);
  82.         c_hoffset = getpsquad(p);
  83.         c_voffset = getpsquad(p);
  84.     }
  85.     u->tfm_width = round(tfm*convtfm);
  86.     u->pxl_width = round(tfm*convpxl);
  87.  
  88. #ifdef DEBUG
  89. fprintf(stderr,"pkcharinfo: tfm = %ld, convtfm = %g, convpxl = %g\n",
  90.   tfm, convtfm, convpxl);
  91. #endif /* DEBUG */
  92.  
  93.     return(p);
  94. }
  95.