mozilla/pdf.js · error · Error

cmap files were not found

Error message

cmap files were not found

What it means

The `cmaps` gulp task compresses Adobe text CMaps from `external/cmaps` into binary `.bcmap` files under `external/bcmaps`. As a sanity check it tests for a known sentinel file (`external/cmaps/UniJIS-UCS2-H`); if that file is absent, the directory does not contain the Adobe CMap resources, so the task aborts rather than producing an empty/partial bcmap set. The error message points the user at the upstream source.

Source

Thrown at gulpfile.mjs:1301

      .src(`${L10N_DIR}/${glob}/viewer.ftl`, {
        base: L10N_DIR,
        encoding: false,
      })
      .pipe(gulp.dest(VIEWER_LOCALE_OUTPUT)),
  ]);
});

gulp.task("cmaps", async function () {
  const CMAP_INPUT = "external/cmaps";
  const VIEWER_CMAP_OUTPUT = "external/bcmaps";

  console.log("\n### Building cmaps");

  // Testing a file that usually present.
  if (!checkFile(CMAP_INPUT + "/UniJIS-UCS2-H")) {
    console.log("./external/cmaps has no cmap files, download them from:");
    console.log("  https://github.com/adobe-type-tools/cmap-resources");
    throw new Error("cmap files were not found");
  }

  // Remove old bcmap files.
  fs.readdirSync(VIEWER_CMAP_OUTPUT).forEach(function (file) {
    if (/\.bcmap$/i.test(file)) {
      fs.unlinkSync(VIEWER_CMAP_OUTPUT + "/" + file);
    }
  });

  const { compressCmaps } =
    await import("./external/cmapscompress/compress.mjs");
  compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
});

function preprocessCSS(source, defines) {
  const outName = getTempFile("~preprocess", ".css");
  preprocess(source, outName, defines);
  const out = fs.readFileSync(outName).toString();

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Download Adobe CMap resources from https://github.com/adobe-type-tools/cmap-resources and place the text CMaps into `external/cmaps/` (ensure `UniJIS-UCS2-H` is present).
  2. Verify with `ls external/cmaps/UniJIS-UCS2-H` before running `gulp cmaps`.
  3. If you don't need CJK font support in your build, skip the `cmaps` task entirely.
  4. Re-extract a truncated archive (the sentinel file missing usually means the whole set is incomplete).
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs';
function preflightCmaps() {
  if (!existsSync('external/cmaps/UniJIS-UCS2-H')) {
    throw new Error('external/cmaps missing; download from https://github.com/adobe-type-tools/cmap-resources');
  }
}

Prevention

When it happens

Trigger: Fresh clone where `external/cmaps` was never populated; the cmap-resources archive was downloaded but extracted to the wrong path; a git operation removed the files; the directory exists but `UniJIS-UCS2-H` specifically is missing (incomplete download).

Common situations: First-time build of a distro package that needs CJK font support; CI that doesn't pre-fetch cmap resources; a contributor following old docs that omit the download step.

Related errors


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/27fe0aedb73303d8. Report an issue: GitHub.