{"record":{"id":"e70b0aab5ee469e8","repo":"parallax/jsPDF","slug":"ttcf-not-supported","errorCode":null,"errorMessage":"TTCF not supported.","messagePattern":"TTCF not supported\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/libs/ttffont.js","lineNumber":33,"sourceCode":"  /************************************************************************/\n  /* function : open                                                       */\n  /* comment : Decode the encoded ttf content and create a TTFFont object. */\n  /************************************************************************/\n  TTFFont.open = function(file) {\n    return new TTFFont(file);\n  };\n  /***************************************************************/\n  /* function : TTFFont gernerator                               */\n  /* comment : Decode TTF contents are parsed, Data,             */\n  /* Subset object is created, and registerTTF function is called.*/\n  /***************************************************************/\n  function TTFFont(rawData) {\n    var data;\n    this.rawData = rawData;\n    data = this.contents = new Data(rawData);\n    this.contents.pos = 4;\n    if (data.readString(4) === \"ttcf\") {\n      throw new Error(\"TTCF not supported.\");\n    } else {\n      data.pos = 0;\n      this.parse();\n      this.subset = new Subset(this);\n      this.registerTTF();\n    }\n  }\n  /********************************************************/\n  /* function : parse                                     */\n  /* comment : TTF Parses the file contents by each table.*/\n  /********************************************************/\n  TTFFont.prototype.parse = function() {\n    this.directory = new Directory(this.contents);\n    this.head = new HeadTable(this);\n    this.name = new NameTable(this);\n    this.cmap = new CmapTable(this);\n    this.toUnicode = {};\n    this.hhea = new HheaTable(this);","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/libs/ttffont.js#L15-L51","documentation":"Thrown by the TTFFont constructor when the 4 bytes at offset 4 of the font data spell 'ttcf', identifying a TrueType Collection (.ttc) file. jsPDF's font engine only supports single-face TrueType (.ttf), so it refuses a collection outright rather than attempting partial parsing.","triggerScenarios":"Passing a .ttc font (which packages multiple TTF faces) through addFileToVFS + addFont, or directly via TTFFont.open(file). The magic bytes 'ttcf' at offset 4 are read and rejected before any table parsing.","commonSituations":"Bundling a system font that is actually a .ttc (common on macOS/Windows for CJK families like PingFang or MS Mincho); converting a .otf/.ttc without extracting a single face.","solutions":["Use a single-face .ttf file instead of a .ttc collection.","Extract one face from the .ttc using fonttools (`pyftsubset`/`ttx`) or fontforge before registering it.","Verify the font bytes are not 'ttcf' at offset 4 before calling addFont."],"exampleFix":"// before\nvar font = loadFont('NotoSans.ttc'); // collection\ndoc.addFileToVFS('NotoSans.ttf', font);\ndoc.addFont('NotoSans.ttf', 'NotoSans', 'normal');\n\n// after (extract one face to a real .ttf first)\nvar font = loadFont('NotoSans-Regular.ttf'); // single face, offset 4 != 'ttcf'\ndoc.addFileToVFS('NotoSans-Regular.ttf', font);\ndoc.addFont('NotoSans-Regular.ttf', 'NotoSans', 'normal');","handlingStrategy":"validation","validationCode":"function isSingleFaceTtf(bytes) {\n  // a .ttc has 'ttcf' at offset 4; a single .ttf has its sfnt version at offset 0\n  var s = String.fromCharCode(bytes[4], bytes[5], bytes[6], bytes[7]);\n  return s !== 'ttcf';\n}\nif (!isSingleFaceTtf(fontBytes)) {\n  throw new Error('Font is a .ttc collection; extract a single .ttf face first');\n}","typeGuard":"function isSingleFaceTtf(bytes) {\n  if (!(bytes instanceof Uint8Array) || bytes.length < 8) return false;\n  return String.fromCharCode(bytes[4], bytes[5], bytes[6], bytes[7]) !== 'ttcf';\n}","tryCatchPattern":"try {\n  doc.addFont(fontKey, family, style);\n} catch (e) {\n  if (/TTCF not supported/.test(e.message)) {\n    throw new Error('Please provide a single-face .ttf, not a .ttc collection');\n  }\n  throw e;\n}","preventionTips":["Always register single-face .ttf files, never .ttc collections.","Extract a face with fonttools/pyftsubset or fontforge before embedding.","Check offset-4 magic for 'ttcf' during your font onboarding step."],"tags":["font","ttf","ttc","validation"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}