diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-17 21:41:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-17 21:41:51 +0000 |
commit | 487ca4806cc046076293cf6cc5fbba0db282bac7 (patch) | |
tree | 847b412ab5158dd7bdd7ed7e5a4cc3fbca94be32 /Build/source/texk/dvipsk/dpicheck.c | |
parent | a3d3111bfe26b8e5f5bc6049dfb2a4ca2edc7881 (diff) |
texk 1
git-svn-id: svn://tug.org/texlive/trunk@1485 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipsk/dpicheck.c')
-rw-r--r-- | Build/source/texk/dvipsk/dpicheck.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Build/source/texk/dvipsk/dpicheck.c b/Build/source/texk/dvipsk/dpicheck.c new file mode 100644 index 00000000000..7665112d815 --- /dev/null +++ b/Build/source/texk/dvipsk/dpicheck.c @@ -0,0 +1,75 @@ +/* + * This software is Copyright 1988 by Radical Eye Software. + */ +/* + * dpicheck of dvips.c. Checks the dots per inch to make sure + * it exists. The fonts which exist are DPI at the appropriate + * magnifications. + */ +#include "dvips.h" +extern int actualdpi ; +static integer existsizes[30] = { 0 , 99999999 } ; +static int checkdpi ; +/* + * This routine adds some sizes to `existsizes'. + */ +void addsiz P1C(int, rhsize) +{ + register integer *p ; + long t, hsize ; + + hsize = rhsize ; + for (p=existsizes; *p < hsize; p++) ; + if (*p == hsize) + return ; + do { + t = *p ; + *p++ = hsize ; + hsize = t ; + } while (hsize) ; +} +void adddpi P1C(int, hsize) +{ + long a, b, c ; + int i ; + + addsiz(hsize) ; + addsiz((int)((hsize * 116161L + 53020L) / 106040L)) ; + a = hsize ; + b = 0 ; + c = 1 ; + for (i=0; i<9; i++) { + b = 6 * b + (a % 5) * c ; + a = a + a / 5 ; + c = c * 5 ; + if (b > c) { + b -= c ; + a++ ; + } + if (b + b >= c) + addsiz((int)(a+1)) ; + else + addsiz((int)a) ; + } +} +/* + * Finally, the routine that checks a size for match. + */ +halfword +dpicheck P1C(halfword, dpi) +{ + integer i ; + integer margin = 1 + dpi / 500 ; + + if (! checkdpi) { + adddpi(DPI) ; + checkdpi = 1 ; + } + for (i=0; existsizes[i] < dpi; i++) ; + if (existsizes[i]-dpi <= margin) + return(existsizes[i]) ; + else if (dpi-existsizes[i-1] <= margin) + return(existsizes[i-1]) ; + else + return(dpi) ; +} |