🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #972

Re: reverse engineering PK extensions

#972
From: Tomas G. Rokicki
Date: Thu, 05 Oct 1989 20:58
54 lines
2459 bytes
grunwald@foobar.colorado.edu (Dirk Grunwald) writes:
> The input is a striped version of the \font declerations in lfonts.tex,
> i.e.:
> cmssi10 scaled 900
> One option to this program is the DPI for metafont. E.g., at 85dpi,
> the above yields:
> The question is ``how does metafont generate the number used in the
> pk/gf suffix.''

It's round(dpi * mag).  As you surmised.  But one flaw is that the mag
(as all numbers in MF) is stored in radix format, with 16 bits of
fraction.  Thus, 0.9 is stored as 58982/65536.  This is really
about 0.899993896.  When this is multiplied by 85, you end up with
76.49948, which is then rounded to 76.  (The `real' value should have
been 76.5, rounded up to 77.)  Thus, one possible `more valid' expression
is

   round(round(mag*65536)*dpi/65536)

I believe this will always work.  In general, though, `900' is a bad
number (I realize LaTeX uses it) with odd resolutions (like 85) since
85 * 0.9 is 76.5---right at the borderline where finite precision gives
you problems.  The magsteps used by TeX will almost never present such a
problem.

Also, note that the magnification used in TeX documents is really

   round(mag*1000)

so \magstephalf goes to the integer 1095.  Thus, the arithmetic in the
drivers is somewhat different than the arithmetic in MF.  (ie, MF
says foo scaled 900 requires 76; the drivers normally say 77.  Thus,
for a dpi of 2000 at magstephalf, MF says the output dpi is

   round(round(mag*65536)*dpi/65536)
   =round(71791*2000/65536)
   =round(2190.88)
   =2191

TeX, on the other hand, says the required dpi is

   round(round(mag*1000)*dpi/1000)
   =round(1095*2000/1000)
   =round(2190)
   =2190

And, given the exact numbers MF uses and the exact numbers put in the dvi
file, there is no rounding method that will work.

So drivers have to do a little extra work to find the appropriate font.
And users should stick to the magstep ratios if possible---it makes things
a tad easier to deal with.

-tom
Technical Details
Message-ID: <12208@polya.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!Teknowledge.COM!polya!rokicki
References: <12425@boulder.Colorado.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!Teknowledge.COM!polya!rokicki
From: rokicki@polya.Stanford.EDU (Tomas G. Rokicki)
Newsgroups: comp.text
Subject: Re: reverse engineering PK extensions
Message-ID: <12208@polya.Stanford.EDU>
Date: 5 Oct 89 20:58:57 GMT
References: <12425@boulder.Colorado.EDU>
Distribution: comp
Organization: Computer Science Department, Stanford University
Lines: 54