summaryrefslogtreecommitdiff
path: root/dviware/beebe/src/fixpos.h
blob: a4bbb806787a992292910b31d82a42c8d409db9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* -*-C-*- fixpos.h */
/*-->fixpos*/
/**********************************************************************/
/******************************* fixpos *******************************/
/**********************************************************************/
COORDINATE
fixpos(cc,c,cnvfac)
register COORDINATE cc;		/* coordinates in device pixels */
register INT32 c;		/* coordinates in DVI units */
register float cnvfac;		/* converts DVI units to pixels */
{
    register COORDINATE ccc;

    /*
    A sequence  of consecutive  rules, or  consecutive characters  in  a
    fixed-width font whose width is not an integer number of pixels, can
    cause |cc| to  drift far away  from a correctly  rounded value.   We
    follow DVITYPE Version 2.6 to ensure  that the amount of drift  will
    never exceed MAXDRIFT pixels.  DVITYPE Version 2.0 did not do  this,
    and the results could be visibly AWFUL!!
    */

    ccc = PIXROUND(c,cnvfac);
    if (ABS(ccc-cc) > MAXDRIFT)
    {		/* drag cc toward the correctly rounded value ccc */
        if (ccc > cc)
	{
	    cc = ccc - MAXDRIFT;
	}
        else
	{
            cc = ccc + MAXDRIFT;
	}
    }
    return (cc);
}