Distiller & Embedding Fonts

The Embedding Issue

The problem discussed here the Adobe Distiller failure "font blabla can not be embedded due to licensing restrictions". This problem mostly occurs when an exact copy of the output from the program is really needed, and EPS is used as an inbetween format. We present a few workarounds, depending on what the file is actually being used for.

The Technical Side of the Problem

Technically, the problem is caused by fonts that have their "restricted licence embedding" bit turned on. This causes Acrobat Distiller to refuse to generate any documents with this font. You typically end up with messages from distiller like

<some font> cannot be embedded due to licensing restrictions.
Font vendor (...) does not permit this font to be embedded in PDF.
Error: invalidfont; OffendingCommand: show

The tips from Adobe for this problem are often not very useful: exporting as PDF from the source gives very low quality and rasterized images, and changing Distiller job options won't help either. Here we go for the workarounds.

0. Don't use EPS.

In many cases, "copy as PICT" or a similar vector-based format will pick another, non restricted font. And still being vector based, results of such a copy are still quite accurate. However, going to these other formats usually causes slight changes, such as incorrect line widths. In some cases, such as highly detailed graphs, the resulting picture becomes very low quality, and EPS may remain the only option.

1. Use Other Fonts

This is the only really useful tip on adobe website, and the most straightforward solution. It is usually not that hard, just a lot of work, to find all positions (e.g., in the Mathematica source file) where you include the offending fonts in your output. Select all these characters one by one and select another font containing the same looking character (typically the Symbol font) using the Format/Font menu and sometimes picking the right character from the other font.

2. Work via Illustrator

This works OK almost always. Print the relevant parts to a postscript file and edit them with Adobe Illustrator. It takes a lot of work but it is the way to go for anything that has to be made public and needs high quality.

3. Hack EPS File

If finding all places takes too long, a quick hack is to just generate the EPS file, but before using the EPS in another document first hack it as follows:
Open the ESP file in a standard text editor (vi, BBedit, whatever). Replace all occurences of offending fonts (e.g. "Math1Mono" when Mathematica is involved) with "Symbol" or another non-restricted font that has the same symbols at the same place.

4. Changing Embedding Permissions

I did not read up on the exact licence agreement with Wolfram but :
If you follow this approach, you should not use the resulting files that contain the Mathematica fonts for anything public.
Since TrueType is an open standard and anyone can read about its contents here at Microsoft, I think nothing is wrong explaining how it works. What I describe here is just what this program does for you automatically.
The procedure is simple, although a resource editor is needed because the font actually resides in the resource fork of font files:
1. Open the font using a resource editor. I'm still using ResEdit 2.1.3, it's small and just works.
2. Open the font in question. At least two resources should appear: FOND and sfnt. There may also be kwst, movp, NFNT and vers.
3. Select the sfnt resource.
4. The font(s) to be modified should be there. Select it.
5. You get a hex dump. Find the string "OS/2", using for instance the Edit/Find function and searching for hexadecimal 4F532F32 (The string "OS/2" in hexadecimal). Note that each two symbols, for instance "4F", stands for one byte in memory. The table starting with the "OS/2" is actually part of the table directory. Following the manual it contains the following:

TypeNameDescription
ULONG (4 bytes)tag4-byte identifier
ULONGChecksumChecksum for the table pointed at
ULONGoffsetOffset from beginning of TrueType font file
ULONGlengthLength of table pointed at

The offset in the Macintosh case is with respect to the start of the table you are looking at, the fsnt table.
6. Go to the position indicated at the "offset". For instance, if the second ULONG (an ULONG is 4 bytes) after the "OS/2" says "00000214" scroll down to the longwords starting at 0214. That is the start of the OS/2 table.
7. You are looking at the OS/2 table. It contains the following:

TypeNameDescription
USHORT (2 bytes)version0x0001
SHORT (2 bytes)xAvgCharWidth
USHORTusWeightClass
USHORTusWidthClass
SHORTfsType
...much more......

Now check the fsType field, the SHORT at offset+8 (remember to calculate in hexadecimal). It can contain only a few values:

fsType valueDescription
0No restrictions on font usage
2No embedding, copying or modification allowed
4Font embedding allowed in preview and printing
8Documents using this font are allowed to be edited

7. Change the value to the desired value, and notice how much it changed.
8. Go back to the place where you found the "OS/2" marker and correct the checksum directly after it. If you lowered the number by 2 in step 7, you need to lower the checksum by 2.
9. Save the font, you're done.

Acknowledgements

Thanks to Andrew and this program I was quickly put on the track to the last trick. The previous tricks were the result of many hours of trying many combinations of export options from Mathematica, Adobe Illustrator, Distiller job settings, Word export options, etc. I hope that others can save valuable time using these tricks.