[tex-live] Metafont: DVI and PDF trouble

Zdenek Wagner zdenek.wagner at gmail.com
Thu Mar 12 23:50:32 CET 2009


2009/3/12 Thomas Hühn <xf27 at arcor.de>:
> Dan Luecking <luecking at uark.edu> writes:
>
>> In most TeX distributions, the tfm file gray.tfm is produced at 300dpi.
>> This includes Tex Live 2008. However, the file gray.mf that would be
>> used to creates the PK font file contains
>>   if mode=ljfour: input graylj;
>>   elseif mode=cx: input graycx;
>>   elseif mode=aps: input grayaps;
>>   fi
>> The default mode on most systems (e.g., when automatically generating
>> a PK font file) is ljfour, and that is a 600dpi font. Thus, there
>> will almost always be a mismatch between the tfm file and the PK file
>> used for display.
>
> Just a second: Isn't the tfm file created together with the pk file
> (\fontmaking=yes)? Shouldn't those two files be consistent, no matter
> which mode has been selected?
>
Yes and not. The information for TFM is taken from the beginchar
command. It is stored in the units of design_size with precision
2^{-20}, the largest possible value is 2048-2^{-20}, the smallest
possible value is -2048. TFM does not store the values of
width/height/depth/italic correction of each individual character.
Instead it starts with a table of these values and each character
contains indices to this table. Index zero must refer to a zero value,
thus you can have not more than 15 nonzero heights, 15 nonzero depths,
63 nonzero italic corrections and 255 nonzero widths. If you have
more, some values have to be rounded. On the contrary, the bitmap is
generated for a specific resolution and it must adapt to the pixel
grid. Thus the dimensions of the bitmap need not agree with the metric
information in the TFM. The lower the resolution is, the greater the
differences may be.

Now what happens if you have a character with a bitmap of different
dimensions. Both GF and PK contain the information on the dimensions
of the bitmap. Most DVI viewer will use it. If the characters are just
rectangles that should be typeset without spaces between them, the DVI
viewer or a driver for laserjet (not a PS printer) will do itm the
rectangles will be aligned properly. If you convert DVI to PS or PDF,
another algorithm is usually applied. The PK font is first transformed
to Type 3 font. Since PS and PDF allow various transformations with
the font, the metric information, that has been used by TeX, is
enforced to the Type 3 font, that is PS and PDF obey the information
from TFM. The difference between the bitmap dimensions and the
dimensions in the TFM may be 2 pixels and such spaces may be visible
at low resolutions. If you view the PS pr PDF file on screen, you
almost always use bitmap fonts in the wrong resolution. The PS/PDF
viewer will round the bitmap to the nearest screen pixel by the
fastest way which usually decreases the quality. What is usually
almost invisible on the printout may look horrible on screen. That's
why Type 1 fonts are preferred for PDF. They retain hinting
information (unlike Type 3 generated from PK) so that PDF viewers can
take it into account when rounding the shape to the pixel grid. If you
see an isolated character, you hardly notice any difference, but if
you see a typeset line of characters, you can notice the difference of
a single pixel even at 600 dpi.

If you are interested in technical details beyoud DVI, GF, PK and TFM, look at:
www.ctan.org/tex-archive/dviware/driv-standard/level-0/dvistd0.pdf

-- 
Zdeněk Wagner
http://hroch486.icpf.cas.cz/wagner/
http://icebearsoft.euweb.cz


More information about the tex-live mailing list