[pdftex] Patch for longstanding pdftex font subsetting bug

The Thanh Han hanthethanh at gmail.com
Mon Mar 23 22:03:13 CET 2009

On Saturday 21 March 2009 03:45:12 pm Melissa O'Neill wrote:
> The enclosed patch fixes a longstanding bug in font
> subsetting for pdflatex that has existed since 1.20a-rc1
> (March 2004).  This bug has been causing problems for Mac
> users for some time because OS X does not like the subtly
> invalid fonts that pdflatex can output (but it may have
> affected others as well).
> The technical details and patch are below...
> [...]
> In one part of the pdftex font-subsetting code (the part
> that writes out empty subroutines that have been dropped
> in the process of subsetting), pdftex incorrectly treats
> a padding of zero as meaning that it should abandon
> charstring encryption altogether.  Not so. (FWIW, by
> undocumented convention, a padding of -1 does, in fact,
> mean no encryption.)
> [...]
> which explains why so many people have said, "I see no
> problem; it works for me" in response to the anguished
> cries of Mac users with PDFTeX-generated documents
> everywhere.
> FWIW, the buggy code was checked into the repository for
> version 1.20a- rc1.  Prior to that point, this aspect of
> font subsetting worked correctly.
> The patch is, thankfully, trivial, changing (t1_lenIV >
> 0) to (t1_lenIV >= 0).

many thanks for the great analysis. This is indeed a very
nasty bug that was introduced most likely by me, when I
"revised" the patch by Tom Kacvinsky and overlooked the
necessity of the case t1_lenIV = 0.

This bug affects dvips as well, since the same code is also
used for dvips for subsetting t1 fonts.

This fix will be included in next version of pdftex (1.40.10)
and texlive. Thanks a bunch for catching it.

> P.S.  Sadly, I don't know if this is the *only* bug in
> fonts and subsetting that causes fonts to be subtly
> invalid, but it is at least *a* bug that's been squished.

yes I also wish we had a tool for T1/TTF font validation. So
far the most useful validating tools are the applications
themselves. Unfortunately, in this case the bug is quite
hard to reproduce, which explains why it's been there for so
long as you said above. 


PS: t1lint from LCDF tools seems to catch some problems, but
not all.

More information about the pdftex mailing list