The 14 standard PDF fonts and character encoding
<p>I'm having difficulty producing PDFs that make use of the 14 standard PDF fonts. Let's use Times-Roman as an example.</p>

<p>I create a <code>Font</code> dictionary of type <code>Type1</code>, with <code>BaseFont</code> set to <code>Times-Roman</code>. If I omit the <code>Encoding</code> entry to the <code>Font</code> dictionary, or add an <code>Encoding</code> dictionary without a <code>BaseEncoding</code> set, the PDF viewer application should use the font's built-in encoding. For Times-Roman, this is <em>AdobeStandardEncoding</em>.</p>

<p>This works fine for ASCII characters. However, something more exotic like the 'fi' ligature (AdobeStandardEncoding code 174) is not displayed correctly by all PDF viewers:</p>

<ul>
<li>Adobe Reader shows ® (unicode index 174) for Times-Roman and Ă for Times-Italic</li>
<li>SumatraPDF (wine) shows ® for both fonts</li>
<li>Mozilla's PDF.js shows the 'AE' ligature both fonts</li>
</ul>

<p>All other PDF viewers I've tried, display the 'fi' ligature properly. They also display the € symbol correctly, which is additionally mapped using the <code>Differences</code> array in the <code>Encoding</code> dictionary (because it is not included in AdobeStandardEncoding):</p>

<ul>
<li>Apple Preview/Skim</li>
<li>GhostScript</li>
<li>PDF-XChange Viewer (wine)</li>
<li>Foxit Reader (wine)</li>
<li>Chromium's internal PDF viewer</li>
<li>Evince (homebrew)</li>
</ul>

<p>Opening Adobe Reader's <em>Document Properties</em> window shows:</p>

<pre><code>Times-Roman
    Type: Type1
    Encoding: Custom
    Actual Font: Times-Roman
    Actual Font Type: TrueType
</code></pre>

<p>I suspect the fact that a TrueType font is being used instead of a Type1 font might be related to the problem. The PDF specification:</p>

<blockquote>
  <p><strong>StandardEncoding</strong>  Adobe standard Latin-text encoding. This is the 
  built-in encoding defined in Type 1 Latin-text font programs (but
  <em>generally not in TrueType font programs</em>).</p>
</blockquote>

<p>It also says <strong>WinAnsiEncoding</strong> and <strong>MacRomanEncoding</strong> <em>can</em> be used with TrueType fonts. So should we avoid using the built-in or <strong>StandardEncoding</strong> for the standard 14 fonts? Its effects seem to be undefined. It seems Adobe Reader doesn't bother performing a proper mapping from glyph names to glyphs in the TrueType font being used.</p>

<p>Will providing a <code>Differences</code> array when using the Win or Mac encodings produce proper results? Since these map codepoints to Type1/Postscript glyphs names, there is no direct link to TrueType glyphs.</p>

<p><strong>EDIT</strong> Mmm, I have a feeling the Font Descriptor Flags might be important for these standard fonts. I set the flags to 4 up to now for all fonts, which seemed to work fine for True/OpenType fonts.</p>