mozilla/pdf.js · error · FormatError
TrueType Collection font must contain a "name" table.
Error message
TrueType Collection font must contain a "name" table.
What it means
Thrown by readTrueTypeCollectionData() when iterating over sub-fonts in a TrueType Collection and one of the member fonts lacks a 'name' table. The 'name' table is mandatory in OpenType/TrueType — it carries the font's human-readable names used for matching the requested fontName.
Source
Thrown at src/core/fonts.js:1555
return header;
}
throw new FormatError(
`Invalid TrueType Collection majorVersion: ${majorVersion}.`
);
}
function readTrueTypeCollectionData(ttc, fontName) {
const { numFonts, offsetTable } = readTrueTypeCollectionHeader(ttc);
const fontNameParts = fontName.split("+");
let fallbackData;
for (let i = 0; i < numFonts; i++) {
ttc.pos = (ttc.start || 0) + offsetTable[i];
const potentialHeader = readOpenTypeHeader(ttc);
const potentialTables = readTables(ttc, potentialHeader.numTables);
if (!potentialTables.name) {
throw new FormatError(
'TrueType Collection font must contain a "name" table.'
);
}
const [nameTable] = readNameTable(potentialTables.name);
for (const nameArr of nameTable) {
for (const entry of nameArr) {
const nameEntry = entry?.replaceAll(/\s/g, "");
if (!nameEntry) {
continue;
}
if (nameEntry === fontName) {
return {
header: potentialHeader,
tables: potentialTables,
};
}
if (fontNameParts.length < 2) {View on GitHub (pinned to 5903d58d58)
Solutions
- Rebuild the TTC with fonttools TTCollection, which ensures all member fonts have complete tables.
- Remove the corrupt member font from the collection if it is not the one needed.
- Extract the specific font you need with TTFont('file.ttc', fontNumber=N) and embed it standalone.
- Run ots-sanitize on each member font to identify structural deficiencies.
Example fix
# extract the valid member font, drop the corrupt one
from fontTools import ttLib
for i in range(10):
try:
f = ttLib.TTFont('broken.ttc', fontNumber=i)
if 'name' in f:
f.save(f'font_{i}.ttf')
break
except Exception:
continue Defensive patterns
Strategy: validation
Validate before calling
// Server-side: verify all TTC member fonts have a 'name' table
// from fontTools import ttLib
// ttc = ttLib.TTCollection('fonts.ttc')
// for i, font in enumerate(ttc.fonts):
// if 'name' not in font:
// print(f'Member font {i} is missing name table')
function ttcMembersHaveNameTable(buffer) {
// Parse TTC offset table, iterate members, check for 'name' tag in each
// Requires a minimal SFNT/TTC parser; use fonttools server-side instead.
} Try / catch
try {
await page.render(renderParams).promise;
} catch (err) {
if (err.message?.includes('must contain a "name" table')) {
console.error('TTC member font is missing mandatory name table; rebuild the TTC.');
} else { throw err; }
} Prevention
- Build TTCs with fonttools TTCollection, which enforces mandatory tables on all members.
- Run ots-sanitize on each TTC member font.
- Remove corrupt member fonts from TTCs before embedding.
When it happens
Trigger: For each member font i in the TTC, readTables() returns potentialTables, and potentialTables.name is falsy. This triggers an immediate throw for that member font before name matching can occur.
Common situations: A TTC containing a corrupt, truncated, or stripped member font where the 'name' table was removed or never written. TTCs assembled by non-standard tools that omit mandatory tables. A TTC where one sub-font's offset table points to garbage data.
Related errors
- Invalid TrueType Collection majorVersion: ${majorVersion}.
- TrueType Collection does not contain "${fontName}" font.
- Invalid entry in 'Differences' array: ${data}
- Encoding is not a Name nor a Dict
- Max size of CID is 65,535
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/3e6b6236692c535f.
Report an issue: GitHub.