mactexlion logo OX5

Fixing the Font Cache Bug

MacTeX  |  Donate  |  FAQ  |  Help  |  TUG

Note: The font-cache bug problem no longer exists in MacTeX-2009 and later.

The Corrupt Font Cache Bug in Mac OS X

Many users of TeX are aware of the "font cache bug" in OS X. While typesetting a document, the output display suddenly develops problems. Exact symptoms vary --- sometimes half of the mathematical characters are missing, and sometimes the text mysteriously changes from Computer Modern to Helvetica. When the problem occurs, it is visible in many programs at once: Preview, TeXShop, LaTeXiT, TeXniscope, etc. But the pdf file displays correctly in Adobe Acrobat.

This problem is caused by a corrupt font cache. When GUI programs display pdf files, they call Apple's internal pdf routines. In turn, these routines call Apple's font routines to construct bitmaps for the outline fonts. These Apple routines store the bitmaps in a font cache to speed up future display. For reasons unknown until recently, this font cache can become corrupt; this is "triggered" by displaying a defective pdf file. After that trigger, display problems persist for all files. To fix the problem, the font cache needs to be rebuilt, as happens when the machine is rebooted.

In a heroic debugging campaign, Melissa O'Neill, the author of the program PDF to Keynote, traced the bug to a particular line of code in pdftex. The details are available in documents linked below; suffice it to say that pdftex source code contained the symbol > in a spot where >= was required. The bug has been present in pdftex since 2004 on all computer platforms; it causes incorrect fonts to be embedded in pdf documents and then these documents trigger the bug. The defective code in pdftex is also used in dvips, so dvips has the same bug.

Subsequent debugging revealed that many fonts in TeX Live are also broken, with a related bug. When these fonts are used in a pdf document, that document can trigger the bug. Pdftex and dvips have been patched to correct this problem; when they embed one of the broken fonts, they automatically repair it.

These problems were fixed in TeX Live 2009 and do not affect later versions of TeX Live.


More Details

The first document below explains the bug in more detail. The second provides a glimpse over the debuggers' shoulders as they unraveled the mystery of the bug:

This bug only affected MacTeX Versions 2004 to 2008.