A /Differences entry in a PDF font allows you to setup a custom encoding for a Font (rather that using a standard set of values such as WIN or MAC encoding). In theory, it should be very simple – the glyph number followed by one or more glyph names. Here are 2 examples from the PDF reference guide.
9 0 obj /Differences [ 97 /square /triangle ] ... /square 11 0 R /triangle 12 0 R endobj
25 0 obj << /Type /Encoding /Differences [ 39 /quotesingle 96 /grave 128 /Adieresis /Aring /Ccedilla /Eacute /Ntilde /Odieresis /Udieresis /aacute /agrave /acircumflex /adieresis /atilde /aring /ccedilla /eacute /egrave /ecircumflex /edieresis /iacute /igrave /icircumflex /idieresis /ntilde /oacute /ograve /ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex /udieresis /dagger /degree /cent /sterling /section /bullet /paragraph /germandbls /registered /copyright /trademark /acute /dieresis 174 /AE /Oslash 177 /plusminus 180 /yen /mu 187 /ordfeminine /ordmasculine
So far so good. It turns out that you can use any character name, so long as you use the same reference elsewhere (as in the first example).
So if you think you have it figured out, here is an interesting example for you…
<i255/5/6/7/8/9/10 /11/12/13/14/15/16/17/18/19/20 /21/22/23/24/25/26/27/28/29/30 /31/32/33/34/35/36/37/38/39/40 /41/42/43/44/45/46/47/49/50 /51/52/53/54/55/56/57/58/59/60 /61/62/63/64/65/66/67/68/69/70 /71/72/73/74/75/76/77/78/79/80 /81/82/83/84/85/86/87/88/89/90 /91/92/93/94/95/96/97/98/99/100 /101/102/103/104/105/106/107/108/109/110 /111/112/113/114/115/116/117/118/119/120 /121/122/123/124/125/126/127/128/129/130 /131/132/133]/Type/Encoding
This is very confusing because numbers are being used as character names (and the number is the WIN encoding value for the actual character). So you have to be very exact about whether a value is preceded by a slash (/) which shows it is a name rather than a number. There is also a rather odd i255 value. This PDF file looks like it was created with Ghostscript.
In general, the PDF is far more useful if you use the actual defined glyph names (as in the Adobe examples). Have you seen any odd Differences values?
This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.