mozilla/pdf.js · error · FormatError
TrueType Collection does not contain "${fontName}" font.
Error message
TrueType Collection does not contain "${fontName}" font. What it means
Thrown by readTrueTypeCollectionData() after scanning all member fonts in a TTC and finding none whose 'name' table entries match the requested fontName — and no partial fallback match was found either. The PDF references a specific font name that the TTC does not contain.
Source
Thrown at src/core/fonts.js:1598
header: potentialHeader,
tables: potentialTables,
};
}
}
}
}
}
if (fallbackData) {
warn(
`TrueType Collection does not contain "${fontName}" font, ` +
`falling back to "${fallbackData.name}" font instead.`
);
return {
header: fallbackData.header,
tables: fallbackData.tables,
};
}
throw new FormatError(
`TrueType Collection does not contain "${fontName}" font.`
);
}
/**
* Read the appropriate subtable from the cmap according to 9.6.6.4 from
* PDF spec
*/
function readCmapTable(cmap, file, isSymbolicFont, hasEncoding) {
if (!cmap) {
warn("No cmap table available.");
return {
platformId: -1,
encodingId: -1,
mappings: [],
hasShortCmap: false,
};
}View on GitHub (pinned to 5903d58d58)
Solutions
- Inspect the TTC member font names with fonttools: [TTFont('file.ttc', fontNumber=i)['name'].getDebugName(1) for i in range(count)] and compare with the PDF's BaseFont name.
- Ensure the PDF's font resource name matches a name table entry (nameID 1 or 4/6) in the TTC.
- Rebuild the PDF ensuring the correct font from the TTC is referenced.
- If the font name includes a subset prefix (XXXX+), verify it matches the embedded subset.
Example fix
# find which font names exist in the TTC
from fontTools import ttLib
ttc = ttLib.TTCollection('fonts.ttc')
for i, font in enumerate(ttc.fonts):
name = font['name'].getDebugName(1) # Family name
post = font['name'].getDebugName(6) # PostScript name
print(f'{i}: {name} / {post}')
# then fix the PDF to reference the matching PostScript name Defensive patterns
Strategy: validation
Validate before calling
// Server-side: list all names in the TTC and compare with the PDF's BaseFont
// from fontTools import ttLib
// ttc = ttLib.TTCollection('fonts.ttc')
// available = set()
// for font in ttc.fonts:
// for record in font['name'].names:
// available.add(record.toUnicode())
// if pdfBaseFont not in available:
// print(f'{pdfBaseFont} not found in TTC')
Try / catch
try {
await page.render(renderParams).promise;
} catch (err) {
if (err.message?.includes('TrueType Collection does not contain')) {
console.error('Font name mismatch between PDF and embedded TTC; check BaseFont name.');
} else { throw err; }
} Prevention
- Ensure the PDF's BaseFont name exactly matches a name table entry (nameID 6 PostScript name) in the TTC.
- Verify subset prefixes (XXXX+) in the PDF match the embedded subset's names.
- When updating a TTC, regenerate the PDF so font references stay in sync.
When it happens
Trigger: The loop over numFonts completes without returning (no exact nameEntry === fontName match), fallbackData remains null (no fontNameParts partial match), and execution reaches the final throw. The fontName comes from the PDF's font resource name (e.g., 'ABCDEF+Arial').
Common situations: The PDF references a font subset prefix (e.g., 'ABCDEF+TimesNewRoman') that doesn't match any name in the TTC. The TTC was replaced or updated but the PDF still references old font names. A mismatch between the PDF's BaseFont name and the actual embedded TTC member names. The fontName uses a different naming convention than the TTC member.
Related errors
- Invalid TrueType Collection majorVersion: ${majorVersion}.
- TrueType Collection font must contain a "name" table.
- invalid font name
- Invalid entry in 'Differences' array: ${data}
- Encoding is not a Name nor a Dict
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/10b809f03a7f9fc2.
Report an issue: GitHub.