home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / DVIM72-Mac 1.9.6 / source / FIXPOS.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-14  |  1.3 KB  |  44 lines  |  [TEXT/R*ch]

  1. /* -*-C-*- fixpos.h */
  2. /*-->fixpos*/
  3. /**********************************************************************/
  4. /******************************* fixpos *******************************/
  5. /**********************************************************************/
  6. #include "dvihead.h"
  7. #include "commands.h"
  8. #include "gendefs.h"
  9. #include "gblprocs.h"
  10. #include "egblvars.h"
  11. #include "m72.h"
  12.  
  13. COORDINATE
  14. fixpos(cc,c,cnvfac)
  15. register COORDINATE cc;        /* coordinates in device pixels */
  16. register INT32 c;        /* coordinates in DVI units */
  17. register float cnvfac;        /* converts DVI units to pixels */
  18. {
  19.     register COORDINATE ccc;
  20.  
  21.     /*
  22.     A sequence  of consecutive  rules, or  consecutive characters  in  a
  23.     fixed-width font whose width is not an integer number of pixels, can
  24.     cause |cc| to  drift far away  from a correctly  rounded value.   We
  25.     follow DVITYPE Version 2.6 to ensure  that the amount of drift  will
  26.     never exceed MAXDRIFT pixels.  DVITYPE Version 2.0 did not do  this,
  27.     and the results could be visibly AWFUL!!
  28.     */
  29.  
  30.     ccc = PIXROUND(c,cnvfac);
  31.     if (ABS(ccc-cc) > MAXDRIFT)
  32.     {        /* drag cc toward the correctly rounded value ccc */
  33.         if (ccc > cc)
  34.     {
  35.         cc = ccc - MAXDRIFT;
  36.     }
  37.         else
  38.     {
  39.             cc = ccc + MAXDRIFT;
  40.     }
  41.     }
  42.     return (cc);
  43. }
  44.