{"record":{"id":"fc036255a80f082c","repo":"mozilla/pdf.js","slug":"unsupported-cid-string-charcode-charcode","errorCode":null,"errorMessage":"Unsupported CID string (charCode ${charCode}): \"${cid}\".","messagePattern":"Unsupported CID string \\(charCode (.+?)\\): \"(.+?)\"\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"warning","filePath":"src/core/fonts.js","lineNumber":448,"sourceCode":"}\n\n// Please refer to:\n//  - https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html\n//  - https://learn.microsoft.com/en-us/typography/opentype/spec/name#windows-language-ids\nfunction isWinNameRecord(r) {\n  return r.platform === 3 && r.encoding === 1 && r.language === 0x409;\n}\n\nfunction convertCidString(charCode, cid, shouldThrow = false) {\n  switch (cid.length) {\n    case 1:\n      return cid.charCodeAt(0);\n    case 2:\n      return (cid.charCodeAt(0) << 8) | cid.charCodeAt(1);\n  }\n  const msg = `Unsupported CID string (charCode ${charCode}): \"${cid}\".`;\n  if (shouldThrow) {\n    throw new FormatError(msg);\n  }\n  warn(msg);\n  return cid;\n}\n\n/**\n * Rebuilds the char code to glyph ID map by moving all char codes to the\n * private use area. This is done to avoid issues with various problematic\n * unicode areas where either a glyph won't be drawn or is deformed by a\n * shaper.\n * @returns {Object} Two properties:\n * 'toFontChar' - maps original char codes(the value that will be read\n * from commands such as show text) to the char codes that will be used in the\n * font that we build\n * 'charCodeToGlyphId' - maps the new font char codes to glyph ids\n */\nfunction adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId, toUnicode) {\n  const newMap = Object.create(null);","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/fonts.js#L430-L466","documentation":"Thrown (or warned) by convertCidString() when a CMap iteration yields a CID as a string whose length is neither 1 nor 2 bytes. CIDs in PDF composite fonts are 8-bit or 16-bit values; a string of length 0 or >= 3 is not representable as a valid CID.","triggerScenarios":"convertCidString(charCode, cid, true) is called when shouldThrow=true during composite font charCodeToGlyphId mapping (fonts.js:3044), and cid.length is not 1 or 2. When shouldThrow is false (default), the same condition emits warn() instead.","commonSituations":"A corrupt or non-standard CMap file that emits CID strings with unexpected lengths. A CMap encoding mismatch where the CIDSystemInfo declares a different Registry/Supplement than the actual CMap data. PDFs from legacy systems with hand-crafted CMap resources. Character codes mapped through a broken ToUnicode or CIDToGIDMap.","solutions":["Verify the PDF's CMap resource matches the font's CIDSystemInfo (Registry, Ordering, Supplement).","Rebuild the PDF with a compliant generator to ensure CMaps emit 1- or 2-byte CID strings.","If the CMap is corrupt, replace it with the correct standard CMap (e.g., Identity-H, UniJIS-UCS2-H).","Report the issue to the PDF producer; the CID string encoding is non-conformant."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// convertCidString with shouldThrow=true fires during font processing.\n// At the display API level, font loading errors surface during render:\ntry {\n  await page.render(renderParams).promise;\n} catch (err) {\n  if (err.message?.includes('Unsupported CID string')) {\n    console.warn('CMap produced an invalid CID string; some glyphs may be unmapped.');\n  } else { throw err; }\n}","preventionTips":["Ensure CMap files conform to Adobe's CMap resource specification (1- or 2-byte CID strings).","Verify CIDSystemInfo in the PDF matches the CMap resource.","Use standard CMaps (Identity-H, Identity-V, UniJIS-UCS2-H, etc.) from Adobe's repository."],"tags":["font","cmap","cid","composite-font","format-error"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}