{"record":{"id":"dc19eb04849f52a6","repo":"mozilla/pdf.js","slug":"invalid-truetype-collection-majorversion-majorv","errorCode":null,"errorMessage":"Invalid TrueType Collection majorVersion: ${majorVersion}.","messagePattern":"Invalid TrueType Collection majorVersion: (.+?)\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/fonts.js","lineNumber":1539,"sourceCode":"      }\n\n      const header = {\n        ttcTag,\n        majorVersion,\n        minorVersion,\n        numFonts,\n        offsetTable,\n      };\n      switch (majorVersion) {\n        case 1:\n          return header;\n        case 2:\n          header.dsigTag = ttc.getInt32() >>> 0;\n          header.dsigLength = ttc.getInt32() >>> 0;\n          header.dsigOffset = ttc.getInt32() >>> 0;\n          return header;\n      }\n      throw new FormatError(\n        `Invalid TrueType Collection majorVersion: ${majorVersion}.`\n      );\n    }\n\n    function readTrueTypeCollectionData(ttc, fontName) {\n      const { numFonts, offsetTable } = readTrueTypeCollectionHeader(ttc);\n      const fontNameParts = fontName.split(\"+\");\n      let fallbackData;\n\n      for (let i = 0; i < numFonts; i++) {\n        ttc.pos = (ttc.start || 0) + offsetTable[i];\n        const potentialHeader = readOpenTypeHeader(ttc);\n        const potentialTables = readTables(ttc, potentialHeader.numTables);\n\n        if (!potentialTables.name) {\n          throw new FormatError(\n            'TrueType Collection font must contain a \"name\" table.'\n          );","sourceCodeStart":1521,"sourceCodeEnd":1557,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/fonts.js#L1521-L1557","documentation":"Thrown by readTrueTypeCollectionHeader() when the TTC (TrueType Collection) header's majorVersion field is neither 1 nor 2. The OpenType spec defines only TTC version 1.0 and 2.0 (which adds DSIG digital signature fields); any other major version is treated as invalid.","triggerScenarios":"readTrueTypeCollectionHeader(ttc) reads ttc.getUint16() for majorVersion, and the switch falls through without matching case 1 or case 2. Called when isTrueTypeCollectionFile(font) returns true (ttcTag is 'ttcf') but the version bytes are corrupt.","commonSituations":"A file with a 'ttcf' tag but corrupt or zeroed version bytes. A font file that is not actually a TTC but happens to start with 'ttcf'. A TTC file truncated so the header is incomplete. Future TTC versions (3.0+) not yet supported by pdf.js.","solutions":["Re-save the font collection with fonttools or FontForge to produce a valid TTC version 1 or 2.","Verify the file is genuinely a TTC with ots-sanitize or fc-query before embedding.","If the font is not a collection, fix the PDF to reference the font file directly rather than wrapping it in a TTC container.","Extract individual fonts from the TTC with fonttools (ttCollection) and embed the needed font standalone."],"exampleFix":"# verify and rebuild TTC with fonttools\nfrom fontTools import ttLib\nttc = ttLib.TTCollection('broken.ttc')  # raises on truly corrupt\nttc.save('fixed.ttc')  # writes valid version-1 TTC\n\n# or extract a single font to avoid TTC entirely\nfont = ttLib.TTFont('broken.ttc', fontNumber=0)\nfont.save('single.ttf')","handlingStrategy":"validation","validationCode":"// Server-side: verify TTC header version\nfunction isValidTtc(buffer) {\n  const view = new DataView(buffer);\n  const tag = String.fromCharCode(view.getUint8(0), view.getUint8(1), view.getUint8(2), view.getUint8(3));\n  if (tag !== 'ttcf') return { ok: true, isTtc: false };  // not a TTC — fine\n  const majorVersion = view.getUint16(4);\n  return { ok: majorVersion === 1 || majorVersion === 2, isTtc: true, majorVersion };\n}","typeGuard":null,"tryCatchPattern":"try {\n  await page.render(renderParams).promise;\n} catch (err) {\n  if (err.message?.includes('Invalid TrueType Collection majorVersion')) {\n    console.error('TTC font has unsupported version; replace the embedded font collection.');\n  } else { throw err; }\n}","preventionTips":["Validate TTC files with fonttools TTCollection before embedding — it rejects invalid versions.","Rebuild TTCs with fonttools to ensure version 1.0 or 2.0 headers.","If only a single font is needed, extract it from the TTC and embed standalone."],"tags":["font","ttc","truetype-collection","font-header","format-error"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}