{"record":{"id":"cded3784bf9e636b","repo":"mozilla/pdf.js","slug":"unknown-encoding-format-format-in-cff","errorCode":null,"errorMessage":"Unknown encoding format: ${format} in CFF","messagePattern":"Unknown encoding format: (.+?) in CFF","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/cff_parser.js","lineNumber":1044,"sourceCode":"          for (i = 1; i <= glyphsCount; i++) {\n            encoding[bytes[pos++]] = i;\n          }\n          break;\n\n        case 1:\n          const rangesCount = bytes[pos++];\n          let gid = 1;\n          for (i = 0; i < rangesCount; i++) {\n            const start = bytes[pos++];\n            const left = bytes[pos++];\n            for (let j = start; j <= start + left; j++) {\n              encoding[j] = gid++;\n            }\n          }\n          break;\n\n        default:\n          throw new FormatError(`Unknown encoding format: ${format} in CFF`);\n      }\n      const dataEnd = pos;\n      if (format & 0x80) {\n        // hasSupplement\n        // The font sanitizer does not support CFF encoding with a\n        // supplement, since the encoding is not really used to map\n        // between gid to glyph, let's overwrite what is declared in\n        // the top dictionary to let the sanitizer think the font use\n        // StandardEncoding, that's a lie but that's ok.\n        bytes[dataStart] &= 0x7f;\n        readSupplement();\n      }\n      raw = bytes.subarray(dataStart, dataEnd);\n    }\n    format &= 0x7f;\n    return new CFFEncoding(predefined, format, encoding, raw);\n  }\n","sourceCodeStart":1026,"sourceCodeEnd":1062,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/cff_parser.js#L1026-L1062","documentation":"Thrown by CFFParser.parseEncoding when the encoding table's low 7 bits of the format byte are not 0 or 1 (the only defined encoding sub-formats). The default branch fires, indicating a corrupt or non-standard encoding table in the CFF font.","triggerScenarios":"Parsing a CFF font whose encoding table format byte (after `format & 0x7f`) is neither 0 nor 1. Reached in the non-predefined path (`pos` not 0 or 1).","commonSituations":"Corrupt encoding tables in embedded CFF fonts; damaged font streams; non-standard encoding formats emitted by faulty font tools; CIDFont streams parsed through the legacy encoding path.","solutions":["Accept pdf.js's automatic fallback to a system font.","Re-embed/repair the font with fontTools or Ghostscript.","Validate CFF encoding bytes during your PDF generation step."],"exampleFix":"// pdf.js substitutes a fallback font; caller handles via render promise.\ntry {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  console.warn('Render failed due to unknown CFF encoding format:', e);\n}","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  // Corrupt CFF encoding; pdf.js falls back to a system font.\n  console.warn('Unknown CFF encoding format:', e);\n}","preventionTips":["Validate CFF encoding format bytes when authoring fonts.","Repair fonts with fontTools/Ghostscript before embedding.","Rely on pdf.js font substitution for third-party PDFs."],"tags":["font","cff","cff-parser","encoding","corrupt-font"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}