mozilla/pdf.js · error · FormatError
"maxp" table has a wrong version number
Error message
"maxp" table has a wrong version number
What it means
Thrown when the maxp table's version field is neither 0x00010000 (version 1.0 for TrueType, 32+ bytes) nor 0x00005000 (version 0.5 for CFF, 6 bytes), AND the table length doesn't allow unambiguous inference of the correct version. When the length is 6, pdf.js assumes version 0.5; when >= 32, it assumes 1.0; otherwise it throws.
Source
Thrown at src/core/fonts.js:2828
}
}
font.pos = (font.start || 0) + tables.maxp.offset;
let version = font.getInt32();
const numGlyphs = numGlyphsFromCFF ?? font.getUint16();
if (version === 0x00005000 && tables.maxp.length !== 6) {
tables.maxp.data = tables.maxp.data.subarray(0, 6);
tables.maxp.length = 6;
}
if (version !== 0x00010000 && version !== 0x00005000) {
// https://learn.microsoft.com/en-us/typography/opentype/spec/maxp
if (tables.maxp.length === 6) {
version = 0x0005000;
} else if (tables.maxp.length >= 32) {
version = 0x00010000;
} else {
throw new FormatError(`"maxp" table has a wrong version number`);
}
writeUint32(tables.maxp.data, 0, version);
}
let isGlyphLocationsLong = int16(
tables.head.data[50],
tables.head.data[51]
);
if (tables.loca) {
const locaLength = isGlyphLocationsLong
? (numGlyphs + 1) * 4
: (numGlyphs + 1) * 2;
if (tables.loca.length !== locaLength) {
warn("Incorrect 'loca' table length -- attempting to fix it.");
// The length of the loca table is wrong (see #13425), so we check if we
// have enough space to fix it.
const sortedTables = Object.values(tables)
.filter(Boolean)View on GitHub (pinned to 5903d58d58)
Solutions
- Rebuild the font with fonttools to regenerate a correct maxp table with the proper version for its type.
- Ensure TrueType fonts use maxp version 0x00010000 (length >= 32) and CFF fonts use 0x00005000 (length 6).
- Replace the corrupt font with a known-good copy.
- Run ots-sanitize to catch maxp version/length mismatches before embedding.
Example fix
# fix maxp version with fonttools
from fontTools import ttLib
font = ttLib.TTFont('broken.ttf')
if hasattr(font, 'glyf'): # TrueType
font['maxp'].tableVersion = 0x00010000
else: # CFF
font['maxp'].tableVersion = 0x00005000
font.save('fixed.ttf') Defensive patterns
Strategy: validation
Validate before calling
// Server-side: verify maxp version matches table type
// from fontTools import ttLib
// font = ttLib.TTFont('font.ttf')
// maxp = font['maxp']
// isTrueType = 'glyf' in font
// expectedVersion = 0x00010000 if isTrueType else 0x00005000
// if maxp.tableVersion != expectedVersion:
// print(f'maxp version mismatch: {maxp.tableVersion:#x}')
Try / catch
try {
await page.render(renderParams).promise;
} catch (err) {
if (err.message?.includes('"maxp" table has a wrong version number')) {
console.error('Font maxp table version/length mismatch; rebuild the font.');
} else { throw err; }
} Prevention
- Use fonttools to rebuild fonts — it writes correct maxp versions automatically.
- Ensure TrueType fonts use maxp version 0x00010000 (>= 32 bytes); CFF fonts use 0x00005000 (6 bytes).
- Run ots-sanitize to catch maxp version/length mismatches.
When it happens
Trigger: The version read from tables.maxp.data via font.getInt32() is not 0x00010000 or 0x00005000. The code then checks: if length===6 → set 0x00005000, else if length>=32 → set 0x00010000, else throw. A maxp table with a bad version and a length between 7 and 31 bytes triggers the throw.
Common situations: A maxp table truncated to a non-standard size (e.g., 16 bytes) with a corrupt version field. Fonts produced by buggy generators that write an incorrect version number. Byte-level corruption of the maxp table's first 4 bytes. Experimental or non-conformant font formats.
Related errors
- Required "maxp" table is not found
- unsupported cmap: ${format}
- Unicode ranges Bits > 123 are reserved for internal usage
- Required "head" table is not found
- Required "hhea" table is not found
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/f5ed12db3b90d425.
Report an issue: GitHub.