{"record":{"id":"42e2cdebfb76d632","repo":"mozilla/pdf.js","slug":"parsefdselect-unknown-format-format","errorCode":null,"errorMessage":"parseFDSelect: Unknown format \"${format}\".","messagePattern":"parseFDSelect: Unknown format \"(.+?)\"\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/cff_parser.js","lineNumber":1097,"sourceCode":"          let first = (bytes[pos++] << 8) | bytes[pos++];\n          if (i === 0 && first !== 0) {\n            warn(\n              \"parseFDSelect: The first range must have a first GID of 0\" +\n                \" -- trying to recover.\"\n            );\n            first = 0;\n          }\n          const fdIndex = bytes[pos++];\n          const next = (bytes[pos] << 8) | bytes[pos + 1];\n          for (let j = first; j < next; ++j) {\n            fdSelect.push(fdIndex);\n          }\n        }\n        // Advance past the sentinel(next).\n        pos += 2;\n        break;\n      default:\n        throw new FormatError(`parseFDSelect: Unknown format \"${format}\".`);\n    }\n    if (fdSelect.length !== length) {\n      throw new FormatError(\"parseFDSelect: Invalid font data.\");\n    }\n\n    return new CFFFDSelect(format, fdSelect);\n  }\n}\n\n// Compact Font Format\nclass CFF {\n  header = null;\n\n  names = [];\n\n  topDict = null;\n\n  strings = new CFFStrings();","sourceCodeStart":1079,"sourceCodeEnd":1115,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/cff_parser.js#L1079-L1115","documentation":"Thrown by CFFParser.parseFDSelect when the FDSelect table (CIDFont-only) has a format byte that is neither 0 nor 3 (the only defined formats). The default branch fires, indicating a corrupt FDSelect table.","triggerScenarios":"Parsing a CID-keyed CFF font whose FDSelect table begins with a format byte outside {0,3}. FDSelect maps each glyph to a Font DICT index and only formats 0 (per-glyph bytes) and 3 (ranges) are defined.","commonSituations":"Corrupt CIDFont FDSelect tables in embedded CFF2/CFF fonts; damaged font streams; output from subsetting tools that wrote an invalid FDSelect format; CFF2 fonts misrouted through the legacy CFF parser.","solutions":["Let pdf.js fall back to a system font (it catches this FormatError).","Repair or re-embed the CIDFont using fontTools (ttx) or Ghostscript.","Re-subset the font with a compliant tool if produced in-house."],"exampleFix":"// pdf.js substitutes a fallback font; observe via render promise.\ntry {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  console.warn('Render failed due to corrupt FDSelect format:', e);\n}","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  // Corrupt CIDFont FDSelect format; pdf.js falls back to a system font.\n  console.warn('Unknown FDSelect format:', e);\n}","preventionTips":["Validate FDSelect format bytes (must be 0 or 3) when authoring CIDFonts.","Re-subset CIDFonts with a compliant tool before embedding.","Accept pdf.js font substitution for untrusted CIDFont PDFs."],"tags":["font","cff","cff-parser","fdselect","cidfont","corrupt-font"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}