A PDF page stores character codes, not letters. Each font’s encoding decides which shape a code draws, so one code can mean different letters in two fonts of one file.
Which encodings can a PDF font use?
A simple font reads one byte per code, so 256 shapes at most. Its dictionary either names one of three predefined tables, MacRomanEncoding, WinAnsiEncoding (Windows code page 1252) or MacExpertEncoding, for “expert” fonts with extra typographic characters, or holds an encoding dictionary whose Differences array changes some codes of one of those tables or of the font program’s own. With no Encoding entry, the font program’s built-in table applies. For most Latin Type 1 fonts that is Adobe’s StandardEncoding, which the standard keeps out of the names a file may use: “Conforming readers shall not have a predefined encoding named StandardEncoding.”
A CID font uses two-byte codes. Identity-H maps each code to “the same 2-byte CID value”; in an embedded TrueType CID font whose CIDToGIDMap is Identity, the usual case, that number is also the glyph’s.
Why do the euro sign and accented letters depend on the encoding?
WinAnsi has the euro; PDF’s MacRoman table “shall continue to map code 333 to currency.” The demo documents made for PDF Textfix’s screenshots use MacRoman, so a typed € comes from a fallback font. Accented letters sit at different codes in the two tables. pdffonts comes with Poppler, which a stock Mac lacks (brew install poppler qpdf adds it and qpdf); on the demo CV it shows:
$ pdffonts "Demo CV.pdf"
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
AAAAAB+IBMPlexSans-SmBld TrueType MacRoman yes yes no 9 0
AAAAAC+IBMPlexSans TrueType MacRoman yes yes no 10 0
In a copy decompressed with qpdf --qdf, the word “cafés” shows its é and the s after it as the codes 8E and 73:
/TT2 1 Tf [ … (e caf) 4 <8e73> 5 (, fr) …
Code 8E is é in MacRoman and Ž in WinAnsi: from a test copy whose fonts were relabeled WinAnsi, pdftotext reads “cafŽs”.
The same commands work on any PDF; finding which fonts a PDF uses walks through them.
Where do you see a font’s encoding?
In the encoding column of pdffonts, where “Custom” means a Differences array and a composite font shows its CMap, such as Identity-H. Acrobat Pro’s accessibility checker has a Character encoding rule, and Adobe’s help notes that “some character-encoding issues aren’t repairable within Acrobat.”
PDF Textfix’s editor bar and Lines pane show each line’s font, not its encoding. A line in a Chinese, Japanese or Korean encoding the app cannot write is locked, and its tooltip says why.
What does the encoding mean for an edit?
Every typed letter must become a code that maps to a shape the font holds. PDF Textfix edits simple TrueType fonts in WinAnsi, MacRoman or custom encodings, Identity-H CID fonts of the TrueType and CFF kinds, and the standard 14 and core TrueType fonts when they are not embedded; simple Type 1 and CFF fonts reuse their own glyphs. It never modifies a font already in the file. A letter the font lacks comes from another copy of the same font in the file, then the same font on your Mac or the closest standard font, and is marked.
What can you do about an encoding problem?
Wrong letters when copying point to the ToUnicode map; see copy-paste gibberish. With the source document, Adobe’s advice holds anywhere: re-create the PDF with another font, preferably OpenType. For accents that are missing or wrong, see accents and umlauts missing in a PDF.
Questions about PDF font encodings
What does Identity-H mean in pdffonts?
Two-byte codes, each the same number as a CID; in most embedded TrueType CID fonts that is also the glyph’s number. PDF Textfix edits Identity-H fonts of the TrueType and CFF kinds.
Can I change the font encoding of a PDF?
Not in place. Export the PDF again with a font that covers your letters.
Is a PDF's font encoding the same as UTF-8?
No. Each font has its own table, while strings such as the title use PDFDocEncoding or UTF-16; PDF 2.0 also allows UTF-8 for them.
Related terms
- Type 3 font: glyphs drawn with PDF operators.
- Embedded font: the font program inside the file.
- Fallback font: what draws a letter the font lacks.