{"record":{"id":"5de619a7dfd47337","repo":"mozilla/pdf.js","slug":"invalid-font-name","errorCode":null,"errorMessage":"invalid font name","messagePattern":"invalid font name","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":4605,"sourceCode":"      );\n      // - Workaround for cases where e.g. fontNameStr = 'Arial' and\n      //   baseFontStr = 'Arial,Bold' (needed when no font file is embedded).\n      //\n      // - Workaround for cases where e.g. fontNameStr = 'wg09np' and\n      //   baseFontStr = 'Wingdings-Regular' (fixes issue7454.pdf).\n      if (\n        fontNameStr &&\n        baseFontStr &&\n        (baseFontStr.startsWith(fontNameStr) ||\n          (!isKnownFontName(fontNameStr) && isKnownFontName(baseFontStr)))\n      ) {\n        fontName = null;\n      }\n      fontName ||= baseFont;\n    }\n\n    if (!(fontName instanceof Name)) {\n      throw new FormatError(\"invalid font name\");\n    }\n\n    let fontFile, fontFileN, subtype, length1, length2, length3;\n    try {\n      for (const n of [\"FontFile\", \"FontFile2\", \"FontFile3\"]) {\n        fontFile = descriptor.get(n);\n        if (fontFile) {\n          fontFileN = n;\n          break;\n        }\n      }\n\n      if (fontFile) {\n        if (!(fontFile instanceof BaseStream)) {\n          throw new FormatError(\"FontFile should be a stream\");\n        } else {\n          if (fontFile.isAsync) {\n            const bytes = await fontFile.asyncGetBytes();","sourceCodeStart":4587,"sourceCodeEnd":4623,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L4587-L4623","documentation":"Thrown by translateFont() after all font-name resolution attempts (descriptor /FontName, BaseFont-derived name, known-font-name heuristics) fail to produce a Name object for the font. Every code path that assigns fontName has run and none yielded a valid Name, so the font cannot be loaded because glyph metrics and file lookup depend on a name. This is the final, unrecoverable guard before font-file fetching.","triggerScenarios":"A font dictionary whose /FontDescriptor lacks /FontName, whose /BaseFont is not a Name, and where none of the heuristics (startsWith, isKnownFontName) recovered a usable name. Fires at the end of the name-resolution block in translateFont().","commonSituations":"Severely malformed font dictionaries, often from corrupt or hand-built PDFs. Also occurs when a font subsetting tool stripped identifying names but left the structure otherwise intact. Rarely encountered with mainstream PDF producers.","solutions":["Repair the PDF with Ghostscript (gs -sDEVICE=pdfwrite -dPDFSETTINGS=/default) to rebuild font metadata.","If authoring, ensure at least one of /FontDescriptor >> /FontName or /BaseFont is a valid Name.","Isolate the page with stopAtErrors: true; the rest of the document will render with fallback fonts.","If you control the consumer app, surface a user-visible warning that a font could not be identified and text may be substituted."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport });\n} catch (e) {\n  if (e.name === 'FormatError' && /invalid font name/.test(e.message)) {\n    // no resolvable font name — PDF.js cannot load this font\n  } else throw e;\n}","preventionTips":["Ensure at least one of /FontDescriptor >> /FontName or /BaseFont is a valid Name on every font.","Repair heavily stripped PDFs with Ghostscript to rebuild font metadata.","Use per-page try/catch so one unidentifiable font does not abort the whole document."],"tags":["pdf","font","font-name","format-error"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}