[pdftex] Problems with pdftex.map

rhowlett at mail.usyd.edu.au rhowlett at mail.usyd.edu.au
Mon May 13 12:52:17 CEST 2002


Quoting Reinhard Kotucha <reinhard at kammer.uni-hannover.de>:

> >>>>> "Bob" == Bob Howlett <rhowlett at mail.usyd.edu.au> writes:
> 
>     > I thought that it was necessary to put the font names in the map
>     > file if you want to prevent pdftex from including the same font
>     > twice (if the font is used in an image that you are including as
>     > well as elsewhere in your document).
> 
> No, the font name is part of the font definition.  When pdfTeX loads a
> font, it knows its name.
> 
>     > I presume the font has to be included twice if you use it once
>     > without "SlantFont" (or "ExtendFont") and once with.
> 
> "SlantFont" and "ExtendFont" modifies the coordinate system when the
> font is used, not the font itself.  There is no need to load the font
> twice, and I think pdfTeX doesn't.
>


I believed that pdftex does. I hunted back through my records to find the
basis for my belief, and found the following two messages, one
from Thanh and the other from Mark Wicks:

This from Thanh:

(Quoting Kuznetsov A,V.)
> I found excessive font embedding in documents
> produced by pdftex.
> 
> I use 3 ways (dvips+distiller, dvipdfm, pdftex) to generate pdf
> from the following file and font map.
> %%%  FILE %%%%
>         \def\test{abcdefghijklmnopqrstuvwxyz\\}
>         \begin{document}
>             \font\true=ptmr8r17 at 10 pt\selectfont\true\test
>             \font\true=ptmr8r   at 10 pt\selectfont\true\test
>             \font\true=ptmr8r9  at 10 pt\selectfont\true\test
>             \font\true=ptmr8r8  at 10 pt\selectfont\true\test
>             \font\true=ptmr8r7  at 10 pt\selectfont\true\test
>             \font\true=ptmr8r6  at 10 pt\selectfont\true\test
>             \font\true=ptmr8r5  at 10 pt\selectfont\true\test
>         \end{document}
> %%%  This is the map for pdftex, maps for dvips and dvipdfm are similar  %%%
>         ptmr8r   Times-Roman   <8r.enc
>         ptmr8r17 <tir_____.pfb <8r.enc ".97 ExtendFont"
>         ptmr8r9  <tir_____.pfb <8r.enc "1.03 ExtendFont"
>         ptmr8r8  <tir_____.pfb <8r.enc "1.07 ExtendFont"
>         ptmr8r7  <tir_____.pfb <8r.enc "1.11 ExtendFont"
>         ptmr8r6  <tir_____.pfb <8r.enc "1.15 ExtendFont"
>         ptmr8r5  <tir_____.pfb <8r.enc "1.25 ExtendFont"
> %%%%%%%%%%%%%%
> As seen, only the standard font is used.
> 
> The results are dramatically different.
> Neither dvipdfm nor dvips+distiller embed standard resource
> but pdftex embeds it six times. Why? Only Tz operator should
> change horizontal scaling when an extended font is used
> (see 'PDF reference' sec.ed. 5.2.).
> 
> Excessive font embedding increases file size, for example,
>  1.987 kB for dvips+distiller,
>  3.990 kB for dvipdfm and
> 51.791 kB (!) for pdftex.
> Moreover, such a font strategy leads to incorrect result.
> Printer (or viewer) font will be used for unextended font
> while creator's font is embedded for extended fonts. As it was
> recently discussed in mail-list, these fonts can be different.
> 
> What is the reason for the excessive font embedding in pdftex?

in the early days of pdftex, I used to change the graphic state matrix to
emulate FontExtend and FontSlant, so it could be used for truetype fonts as
well.  Afterward, when experimenting with hz-opt, I found it too
problematic to do it this way. So I switched to changing the FontMatrix of
Type1 font instead. This causes the output larger and avoids
extending/slanting truetype fonts, but also makes the implementation
cleaner and easier to extend, especially when playing with the hz-opt. 

Concerning use of builtin fonts, one can always embed the 14 base fonts by
URW++ if he/she wishes. 

The current implementaion however doesn't check if two tfm share a single
font file. It could have been improved, but I don't consider it worthwhile.
It happens rarely, and having the file a little bit larger doesn't seem to
hurt much.

Regards,
Thanh


---------------------------

And this from Mark Wicks:



On Tue, 13 Feb 2001, Kuznetsov A,V. wrote:

> Dear pdftex developers,
> I found excessive font embedding in documents
> produced by pdftex.
> 
[snip]
>         ptmr8r   Times-Roman   <8r.enc
>         ptmr8r17 <tir_____.pfb <8r.enc ".97 ExtendFont"
>         ptmr8r9  <tir_____.pfb <8r.enc "1.03 ExtendFont"
>         ptmr8r8  <tir_____.pfb <8r.enc "1.07 ExtendFont"
>         ptmr8r7  <tir_____.pfb <8r.enc "1.11 ExtendFont"
...
[snip]
> As seen, only the standard font is used.
> 
> The results are dramatically different.
> Neither dvipdfm nor dvips+distiller embed standard resource
> but pdftex embeds it six times. Why? Only Tz operator should
> change horizontal scaling when an extended font is used
[snip]
> What is the reason for the excessive font embedding in pdftex?

   I am not a pdftex developer, but I think I understand the problem
pretty well. You are correct that Tz can change the horizontal scaling to
implement ExtendFont, but that doesn't solve the more general problem.  
What about SlantFont, for example?  If I recall correctly, PDF, unlike
PostScript, does not allow the font matrix to be modified on the fly.  
The slant of the font is determined from the font matrix contained in the
embedded font. I believe that the only way to change the font matrix is to
re-embed a new copy of the font using different font matrix for each
instance, and that's apparently what pdftex is doing.

   Dvipdfm and Distiller handle this by modifying the graphics state
rather than the text state.  Having implemented this in dvipdfm, I know
that this is very difficult to get right (I'll explain the issues to
anybody who wants to know), and it produces some unnatural looking PDF
output streams. However, it does produce the right result and allows the
font to be embedded only once.

> Moreover, such a font strategy leads to incorrect result.
> Printer (or viewer) font will be used for unextended font
> while creator's font is embedded for extended fonts. As it was

   Can't you explicitly embed the font in the unextended case?
e.g.,

         ptmr8r <tir_____.pfb <8r.enc
instead of
         ptmr8r   Times-Roman   <8r.enc> 

-------------------------------------------------
This mail sent through IMP: www-mail.usyd.edu.au



More information about the pdftex mailing list