Fix inconsistent PDF fonts | Nutrient
PDFs use different encoding systems to map character codes to glyphs. The most common are:
- Standard encodings (WinAnsiEncoding, MacRomanEncoding) — Maps character codes to Unicode values, enabling viewers to substitute fonts reliably.
- Identity-H encoding — Maps character codes directly to glyph positions within a specific font file. This encoding is commonly used for CJK (Chinese, Japanese, Korean) fonts and some complex scripts.
Checking font encoding
To determine if a font uses Identity-H encoding:
- Open a PDF in Adobe Acrobat Pro/Reader.
- Go to File > Document Properties > Fonts.
- Look for fonts with encoding listed as Identity-H or Identity-V.
Why Identity-H fonts need special handling
When a PDF uses Identity-H encoding without embedding a font, the PDF refers to glyph positions (e.g. glyph #245) rather than Unicode characters. In these cases:
- The viewer needs either the exact original font or a
ToUnicodemap in the PDF to determine which characters to display. - If neither is available, the viewer cannot reliably render the text, regardless of which custom fonts you provide.
Working with embedded fonts
If your PDF document has embedded fonts, any viewer on any device should render them as expected. A PDF viewer will replace a font if the document doesn’t have it embedded and if it’s not available on the device.
Here’s how determine if your PDF document has embedded fonts:
- Open the PDF document in Acrobat Pro(opens in a new tab) or Acrobat Reader(opens in a new tab) (free and available on all platforms).
- Go to the File menu, right-click anywhere empty on the page, and select Document Properties.
- Click the Fonts tab.
- See the fonts used in the PDF and ensure they’re included in your Custom Fonts.
Ensure that the embedded font in your PDF is indeed included in your custom fonts array. If a subset of a font is embedded, this means only the characters used in that particular document are embedded.
When custom fonts won’t help
Custom fonts configured via customFonts will not resolve rendering issues when:
- The PDF uses Identity-H encoding without
ToUnicodemaps. - The PDF uses Type 3 fonts (custom vector glyphs).
- The font is embedded but corrupted in the PDF.
In these cases, the PDF itself must be regenerated with proper font embedding or encoding.
Collecting diagnostic information
When reporting font rendering issues to support, always include a sample PDF demonstrating the issue so that we can look at its properties and determine the issue.