Merge pull request #11818 from Snuffleupagus/eslint-dot-notation
Enable the `dot-notation` ESLint rule
This commit is contained in:
commit
7b23476e61
@ -75,6 +75,7 @@
|
||||
}],
|
||||
"consistent-return": "error",
|
||||
"curly": ["error", "all"],
|
||||
"dot-notation": "error",
|
||||
"eqeqeq": ["error", "always"],
|
||||
"no-caller": "error",
|
||||
"no-else-return": "error",
|
||||
|
@ -209,8 +209,8 @@ var PDFViewerApplication = {
|
||||
}
|
||||
}
|
||||
|
||||
if (!pdfTitle && info && info["Title"]) {
|
||||
pdfTitle = info["Title"];
|
||||
if (!pdfTitle && info && info.Title) {
|
||||
pdfTitle = info.Title;
|
||||
}
|
||||
|
||||
if (pdfTitle) {
|
||||
|
20
gulpfile.js
20
gulpfile.js
@ -171,7 +171,7 @@ function createWebpackConfig(defines, output) {
|
||||
var bundleDefines = builder.merge(defines, {
|
||||
BUNDLE_VERSION: versionInfo.version,
|
||||
BUNDLE_BUILD: versionInfo.commit,
|
||||
TESTING: defines.TESTING || process.env["TESTING"] === "true",
|
||||
TESTING: defines.TESTING || process.env.TESTING === "true",
|
||||
});
|
||||
var licenseHeaderLibre = fs
|
||||
.readFileSync("./src/license_header_libre.js")
|
||||
@ -414,9 +414,9 @@ function createTestSource(testsName, bot) {
|
||||
console.log();
|
||||
console.log("### Running " + testsName + " tests");
|
||||
|
||||
var PDF_TEST = process.env["PDF_TEST"] || "test_manifest.json";
|
||||
var PDF_TEST = process.env.PDF_TEST || "test_manifest.json";
|
||||
var PDF_BROWSERS =
|
||||
process.env["PDF_BROWSERS"] ||
|
||||
process.env.PDF_BROWSERS ||
|
||||
"resources/browser_manifests/browser_manifest.json";
|
||||
|
||||
if (!checkFile("test/" + PDF_BROWSERS)) {
|
||||
@ -467,7 +467,7 @@ function makeRef(done, bot) {
|
||||
console.log("### Creating reference images");
|
||||
|
||||
var PDF_BROWSERS =
|
||||
process.env["PDF_BROWSERS"] ||
|
||||
process.env.PDF_BROWSERS ||
|
||||
"resources/browser_manifests/browser_manifest.json";
|
||||
|
||||
if (!checkFile("test/" + PDF_BROWSERS)) {
|
||||
@ -1201,7 +1201,7 @@ function buildLib(defines, dir) {
|
||||
var bundleDefines = builder.merge(defines, {
|
||||
BUNDLE_VERSION: versionInfo.version,
|
||||
BUNDLE_BUILD: versionInfo.commit,
|
||||
TESTING: process.env["TESTING"] === "true",
|
||||
TESTING: process.env.TESTING === "true",
|
||||
});
|
||||
var ctx = {
|
||||
rootPath: __dirname,
|
||||
@ -1287,7 +1287,7 @@ gulp.task(
|
||||
);
|
||||
|
||||
gulp.task("testing-pre", function (done) {
|
||||
process.env["TESTING"] = "true";
|
||||
process.env.TESTING = "true";
|
||||
done();
|
||||
});
|
||||
|
||||
@ -1353,7 +1353,7 @@ gulp.task("baseline", function (done) {
|
||||
console.log();
|
||||
console.log("### Creating baseline environment");
|
||||
|
||||
var baselineCommit = process.env["BASELINE"];
|
||||
var baselineCommit = process.env.BASELINE;
|
||||
if (!baselineCommit) {
|
||||
done(new Error("Missing baseline commit. Specify the BASELINE variable."));
|
||||
return;
|
||||
@ -1552,7 +1552,7 @@ gulp.task("wintersmith", function (done) {
|
||||
|
||||
gulp.task("gh-pages-git", function (done) {
|
||||
var VERSION = getVersionJSON().version;
|
||||
var reason = process.env["PDFJS_UPDATE_REASON"];
|
||||
var reason = process.env.PDFJS_UPDATE_REASON;
|
||||
|
||||
safeSpawnSync("git", ["init"], { cwd: GH_PAGES_DIR });
|
||||
safeSpawnSync("git", ["remote", "add", "origin", REPO], {
|
||||
@ -1720,7 +1720,7 @@ gulp.task(
|
||||
gulp.series("dist-pre", function (done) {
|
||||
var distPath = DIST_DIR;
|
||||
var opts = {};
|
||||
var installPath = process.env["PDFJS_INSTALL_PATH"];
|
||||
var installPath = process.env.PDFJS_INSTALL_PATH;
|
||||
if (installPath) {
|
||||
opts.cwd = installPath;
|
||||
distPath = path.relative(installPath, distPath);
|
||||
@ -1738,7 +1738,7 @@ gulp.task(
|
||||
console.log();
|
||||
console.log("### Committing changes");
|
||||
|
||||
var reason = process.env["PDFJS_UPDATE_REASON"];
|
||||
var reason = process.env.PDFJS_UPDATE_REASON;
|
||||
// Attempt to work-around the broken link, see https://github.com/mozilla/pdf.js/issues/10391
|
||||
if (typeof reason === "string") {
|
||||
var reasonParts = /^(See )(mozilla\/pdf\.js)@tags\/(v\d+\.\d+\.\d+)\s*$/.exec(
|
||||
|
@ -473,17 +473,17 @@ const CCITTFaxDecoder = (function CCITTFaxDecoder() {
|
||||
this.source = source;
|
||||
this.eof = false;
|
||||
|
||||
this.encoding = options["K"] || 0;
|
||||
this.eoline = options["EndOfLine"] || false;
|
||||
this.byteAlign = options["EncodedByteAlign"] || false;
|
||||
this.columns = options["Columns"] || 1728;
|
||||
this.rows = options["Rows"] || 0;
|
||||
let eoblock = options["EndOfBlock"];
|
||||
this.encoding = options.K || 0;
|
||||
this.eoline = options.EndOfLine || false;
|
||||
this.byteAlign = options.EncodedByteAlign || false;
|
||||
this.columns = options.Columns || 1728;
|
||||
this.rows = options.Rows || 0;
|
||||
let eoblock = options.EndOfBlock;
|
||||
if (eoblock === null || eoblock === undefined) {
|
||||
eoblock = true;
|
||||
}
|
||||
this.eoblock = eoblock;
|
||||
this.black = options["BlackIs1"] || false;
|
||||
this.black = options.BlackIs1 || false;
|
||||
|
||||
this.codingLine = new Uint32Array(this.columns + 1);
|
||||
this.refLine = new Uint32Array(this.columns + 2);
|
||||
|
@ -725,10 +725,10 @@ class PDFDocument {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!docInfo["Custom"]) {
|
||||
docInfo["Custom"] = Object.create(null);
|
||||
if (!docInfo.Custom) {
|
||||
docInfo.Custom = Object.create(null);
|
||||
}
|
||||
docInfo["Custom"][key] = customValue;
|
||||
docInfo.Custom[key] = customValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3533,57 +3533,57 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
|
||||
// If variableArgs === false: exactly `numArgs` expected
|
||||
var getOPMap = getLookupTableFactory(function (t) {
|
||||
// Graphic state
|
||||
t["w"] = { id: OPS.setLineWidth, numArgs: 1, variableArgs: false };
|
||||
t["J"] = { id: OPS.setLineCap, numArgs: 1, variableArgs: false };
|
||||
t["j"] = { id: OPS.setLineJoin, numArgs: 1, variableArgs: false };
|
||||
t["M"] = { id: OPS.setMiterLimit, numArgs: 1, variableArgs: false };
|
||||
t["d"] = { id: OPS.setDash, numArgs: 2, variableArgs: false };
|
||||
t["ri"] = { id: OPS.setRenderingIntent, numArgs: 1, variableArgs: false };
|
||||
t["i"] = { id: OPS.setFlatness, numArgs: 1, variableArgs: false };
|
||||
t["gs"] = { id: OPS.setGState, numArgs: 1, variableArgs: false };
|
||||
t["q"] = { id: OPS.save, numArgs: 0, variableArgs: false };
|
||||
t["Q"] = { id: OPS.restore, numArgs: 0, variableArgs: false };
|
||||
t["cm"] = { id: OPS.transform, numArgs: 6, variableArgs: false };
|
||||
t.w = { id: OPS.setLineWidth, numArgs: 1, variableArgs: false };
|
||||
t.J = { id: OPS.setLineCap, numArgs: 1, variableArgs: false };
|
||||
t.j = { id: OPS.setLineJoin, numArgs: 1, variableArgs: false };
|
||||
t.M = { id: OPS.setMiterLimit, numArgs: 1, variableArgs: false };
|
||||
t.d = { id: OPS.setDash, numArgs: 2, variableArgs: false };
|
||||
t.ri = { id: OPS.setRenderingIntent, numArgs: 1, variableArgs: false };
|
||||
t.i = { id: OPS.setFlatness, numArgs: 1, variableArgs: false };
|
||||
t.gs = { id: OPS.setGState, numArgs: 1, variableArgs: false };
|
||||
t.q = { id: OPS.save, numArgs: 0, variableArgs: false };
|
||||
t.Q = { id: OPS.restore, numArgs: 0, variableArgs: false };
|
||||
t.cm = { id: OPS.transform, numArgs: 6, variableArgs: false };
|
||||
|
||||
// Path
|
||||
t["m"] = { id: OPS.moveTo, numArgs: 2, variableArgs: false };
|
||||
t["l"] = { id: OPS.lineTo, numArgs: 2, variableArgs: false };
|
||||
t["c"] = { id: OPS.curveTo, numArgs: 6, variableArgs: false };
|
||||
t["v"] = { id: OPS.curveTo2, numArgs: 4, variableArgs: false };
|
||||
t["y"] = { id: OPS.curveTo3, numArgs: 4, variableArgs: false };
|
||||
t["h"] = { id: OPS.closePath, numArgs: 0, variableArgs: false };
|
||||
t["re"] = { id: OPS.rectangle, numArgs: 4, variableArgs: false };
|
||||
t["S"] = { id: OPS.stroke, numArgs: 0, variableArgs: false };
|
||||
t["s"] = { id: OPS.closeStroke, numArgs: 0, variableArgs: false };
|
||||
t["f"] = { id: OPS.fill, numArgs: 0, variableArgs: false };
|
||||
t["F"] = { id: OPS.fill, numArgs: 0, variableArgs: false };
|
||||
t.m = { id: OPS.moveTo, numArgs: 2, variableArgs: false };
|
||||
t.l = { id: OPS.lineTo, numArgs: 2, variableArgs: false };
|
||||
t.c = { id: OPS.curveTo, numArgs: 6, variableArgs: false };
|
||||
t.v = { id: OPS.curveTo2, numArgs: 4, variableArgs: false };
|
||||
t.y = { id: OPS.curveTo3, numArgs: 4, variableArgs: false };
|
||||
t.h = { id: OPS.closePath, numArgs: 0, variableArgs: false };
|
||||
t.re = { id: OPS.rectangle, numArgs: 4, variableArgs: false };
|
||||
t.S = { id: OPS.stroke, numArgs: 0, variableArgs: false };
|
||||
t.s = { id: OPS.closeStroke, numArgs: 0, variableArgs: false };
|
||||
t.f = { id: OPS.fill, numArgs: 0, variableArgs: false };
|
||||
t.F = { id: OPS.fill, numArgs: 0, variableArgs: false };
|
||||
t["f*"] = { id: OPS.eoFill, numArgs: 0, variableArgs: false };
|
||||
t["B"] = { id: OPS.fillStroke, numArgs: 0, variableArgs: false };
|
||||
t.B = { id: OPS.fillStroke, numArgs: 0, variableArgs: false };
|
||||
t["B*"] = { id: OPS.eoFillStroke, numArgs: 0, variableArgs: false };
|
||||
t["b"] = { id: OPS.closeFillStroke, numArgs: 0, variableArgs: false };
|
||||
t.b = { id: OPS.closeFillStroke, numArgs: 0, variableArgs: false };
|
||||
t["b*"] = { id: OPS.closeEOFillStroke, numArgs: 0, variableArgs: false };
|
||||
t["n"] = { id: OPS.endPath, numArgs: 0, variableArgs: false };
|
||||
t.n = { id: OPS.endPath, numArgs: 0, variableArgs: false };
|
||||
|
||||
// Clipping
|
||||
t["W"] = { id: OPS.clip, numArgs: 0, variableArgs: false };
|
||||
t.W = { id: OPS.clip, numArgs: 0, variableArgs: false };
|
||||
t["W*"] = { id: OPS.eoClip, numArgs: 0, variableArgs: false };
|
||||
|
||||
// Text
|
||||
t["BT"] = { id: OPS.beginText, numArgs: 0, variableArgs: false };
|
||||
t["ET"] = { id: OPS.endText, numArgs: 0, variableArgs: false };
|
||||
t["Tc"] = { id: OPS.setCharSpacing, numArgs: 1, variableArgs: false };
|
||||
t["Tw"] = { id: OPS.setWordSpacing, numArgs: 1, variableArgs: false };
|
||||
t["Tz"] = { id: OPS.setHScale, numArgs: 1, variableArgs: false };
|
||||
t["TL"] = { id: OPS.setLeading, numArgs: 1, variableArgs: false };
|
||||
t["Tf"] = { id: OPS.setFont, numArgs: 2, variableArgs: false };
|
||||
t["Tr"] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false };
|
||||
t["Ts"] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false };
|
||||
t["Td"] = { id: OPS.moveText, numArgs: 2, variableArgs: false };
|
||||
t["TD"] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false };
|
||||
t["Tm"] = { id: OPS.setTextMatrix, numArgs: 6, variableArgs: false };
|
||||
t.BT = { id: OPS.beginText, numArgs: 0, variableArgs: false };
|
||||
t.ET = { id: OPS.endText, numArgs: 0, variableArgs: false };
|
||||
t.Tc = { id: OPS.setCharSpacing, numArgs: 1, variableArgs: false };
|
||||
t.Tw = { id: OPS.setWordSpacing, numArgs: 1, variableArgs: false };
|
||||
t.Tz = { id: OPS.setHScale, numArgs: 1, variableArgs: false };
|
||||
t.TL = { id: OPS.setLeading, numArgs: 1, variableArgs: false };
|
||||
t.Tf = { id: OPS.setFont, numArgs: 2, variableArgs: false };
|
||||
t.Tr = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false };
|
||||
t.Ts = { id: OPS.setTextRise, numArgs: 1, variableArgs: false };
|
||||
t.Td = { id: OPS.moveText, numArgs: 2, variableArgs: false };
|
||||
t.TD = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false };
|
||||
t.Tm = { id: OPS.setTextMatrix, numArgs: 6, variableArgs: false };
|
||||
t["T*"] = { id: OPS.nextLine, numArgs: 0, variableArgs: false };
|
||||
t["Tj"] = { id: OPS.showText, numArgs: 1, variableArgs: false };
|
||||
t["TJ"] = { id: OPS.showSpacedText, numArgs: 1, variableArgs: false };
|
||||
t.Tj = { id: OPS.showText, numArgs: 1, variableArgs: false };
|
||||
t.TJ = { id: OPS.showSpacedText, numArgs: 1, variableArgs: false };
|
||||
t["'"] = { id: OPS.nextLineShowText, numArgs: 1, variableArgs: false };
|
||||
t['"'] = {
|
||||
id: OPS.nextLineSetSpacingShowText,
|
||||
@ -3592,62 +3592,62 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
|
||||
};
|
||||
|
||||
// Type3 fonts
|
||||
t["d0"] = { id: OPS.setCharWidth, numArgs: 2, variableArgs: false };
|
||||
t["d1"] = {
|
||||
t.d0 = { id: OPS.setCharWidth, numArgs: 2, variableArgs: false };
|
||||
t.d1 = {
|
||||
id: OPS.setCharWidthAndBounds,
|
||||
numArgs: 6,
|
||||
variableArgs: false,
|
||||
};
|
||||
|
||||
// Color
|
||||
t["CS"] = { id: OPS.setStrokeColorSpace, numArgs: 1, variableArgs: false };
|
||||
t["cs"] = { id: OPS.setFillColorSpace, numArgs: 1, variableArgs: false };
|
||||
t["SC"] = { id: OPS.setStrokeColor, numArgs: 4, variableArgs: true };
|
||||
t["SCN"] = { id: OPS.setStrokeColorN, numArgs: 33, variableArgs: true };
|
||||
t["sc"] = { id: OPS.setFillColor, numArgs: 4, variableArgs: true };
|
||||
t["scn"] = { id: OPS.setFillColorN, numArgs: 33, variableArgs: true };
|
||||
t["G"] = { id: OPS.setStrokeGray, numArgs: 1, variableArgs: false };
|
||||
t["g"] = { id: OPS.setFillGray, numArgs: 1, variableArgs: false };
|
||||
t["RG"] = { id: OPS.setStrokeRGBColor, numArgs: 3, variableArgs: false };
|
||||
t["rg"] = { id: OPS.setFillRGBColor, numArgs: 3, variableArgs: false };
|
||||
t["K"] = { id: OPS.setStrokeCMYKColor, numArgs: 4, variableArgs: false };
|
||||
t["k"] = { id: OPS.setFillCMYKColor, numArgs: 4, variableArgs: false };
|
||||
t.CS = { id: OPS.setStrokeColorSpace, numArgs: 1, variableArgs: false };
|
||||
t.cs = { id: OPS.setFillColorSpace, numArgs: 1, variableArgs: false };
|
||||
t.SC = { id: OPS.setStrokeColor, numArgs: 4, variableArgs: true };
|
||||
t.SCN = { id: OPS.setStrokeColorN, numArgs: 33, variableArgs: true };
|
||||
t.sc = { id: OPS.setFillColor, numArgs: 4, variableArgs: true };
|
||||
t.scn = { id: OPS.setFillColorN, numArgs: 33, variableArgs: true };
|
||||
t.G = { id: OPS.setStrokeGray, numArgs: 1, variableArgs: false };
|
||||
t.g = { id: OPS.setFillGray, numArgs: 1, variableArgs: false };
|
||||
t.RG = { id: OPS.setStrokeRGBColor, numArgs: 3, variableArgs: false };
|
||||
t.rg = { id: OPS.setFillRGBColor, numArgs: 3, variableArgs: false };
|
||||
t.K = { id: OPS.setStrokeCMYKColor, numArgs: 4, variableArgs: false };
|
||||
t.k = { id: OPS.setFillCMYKColor, numArgs: 4, variableArgs: false };
|
||||
|
||||
// Shading
|
||||
t["sh"] = { id: OPS.shadingFill, numArgs: 1, variableArgs: false };
|
||||
t.sh = { id: OPS.shadingFill, numArgs: 1, variableArgs: false };
|
||||
|
||||
// Images
|
||||
t["BI"] = { id: OPS.beginInlineImage, numArgs: 0, variableArgs: false };
|
||||
t["ID"] = { id: OPS.beginImageData, numArgs: 0, variableArgs: false };
|
||||
t["EI"] = { id: OPS.endInlineImage, numArgs: 1, variableArgs: false };
|
||||
t.BI = { id: OPS.beginInlineImage, numArgs: 0, variableArgs: false };
|
||||
t.ID = { id: OPS.beginImageData, numArgs: 0, variableArgs: false };
|
||||
t.EI = { id: OPS.endInlineImage, numArgs: 1, variableArgs: false };
|
||||
|
||||
// XObjects
|
||||
t["Do"] = { id: OPS.paintXObject, numArgs: 1, variableArgs: false };
|
||||
t["MP"] = { id: OPS.markPoint, numArgs: 1, variableArgs: false };
|
||||
t["DP"] = { id: OPS.markPointProps, numArgs: 2, variableArgs: false };
|
||||
t["BMC"] = { id: OPS.beginMarkedContent, numArgs: 1, variableArgs: false };
|
||||
t["BDC"] = {
|
||||
t.Do = { id: OPS.paintXObject, numArgs: 1, variableArgs: false };
|
||||
t.MP = { id: OPS.markPoint, numArgs: 1, variableArgs: false };
|
||||
t.DP = { id: OPS.markPointProps, numArgs: 2, variableArgs: false };
|
||||
t.BMC = { id: OPS.beginMarkedContent, numArgs: 1, variableArgs: false };
|
||||
t.BDC = {
|
||||
id: OPS.beginMarkedContentProps,
|
||||
numArgs: 2,
|
||||
variableArgs: false,
|
||||
};
|
||||
t["EMC"] = { id: OPS.endMarkedContent, numArgs: 0, variableArgs: false };
|
||||
t.EMC = { id: OPS.endMarkedContent, numArgs: 0, variableArgs: false };
|
||||
|
||||
// Compatibility
|
||||
t["BX"] = { id: OPS.beginCompat, numArgs: 0, variableArgs: false };
|
||||
t["EX"] = { id: OPS.endCompat, numArgs: 0, variableArgs: false };
|
||||
t.BX = { id: OPS.beginCompat, numArgs: 0, variableArgs: false };
|
||||
t.EX = { id: OPS.endCompat, numArgs: 0, variableArgs: false };
|
||||
|
||||
// (reserved partial commands for the lexer)
|
||||
t["BM"] = null;
|
||||
t["BD"] = null;
|
||||
t["true"] = null;
|
||||
t["fa"] = null;
|
||||
t["fal"] = null;
|
||||
t["fals"] = null;
|
||||
t["false"] = null;
|
||||
t["nu"] = null;
|
||||
t["nul"] = null;
|
||||
t["null"] = null;
|
||||
t.BM = null;
|
||||
t.BD = null;
|
||||
t.true = null;
|
||||
t.fa = null;
|
||||
t.fal = null;
|
||||
t.fals = null;
|
||||
t.false = null;
|
||||
t.nu = null;
|
||||
t.nul = null;
|
||||
t.null = null;
|
||||
});
|
||||
|
||||
const MAX_INVALID_PATH_OPS = 20;
|
||||
|
@ -1447,13 +1447,13 @@ var Font = (function FontClosure() {
|
||||
function readTables(file, numTables) {
|
||||
const tables = Object.create(null);
|
||||
tables["OS/2"] = null;
|
||||
tables["cmap"] = null;
|
||||
tables["head"] = null;
|
||||
tables["hhea"] = null;
|
||||
tables["hmtx"] = null;
|
||||
tables["maxp"] = null;
|
||||
tables["name"] = null;
|
||||
tables["post"] = null;
|
||||
tables.cmap = null;
|
||||
tables.head = null;
|
||||
tables.hhea = null;
|
||||
tables.hmtx = null;
|
||||
tables.maxp = null;
|
||||
tables.name = null;
|
||||
tables.post = null;
|
||||
|
||||
for (let i = 0; i < numTables; i++) {
|
||||
const table = readTableEntry(file);
|
||||
@ -1548,12 +1548,12 @@ var Font = (function FontClosure() {
|
||||
const potentialHeader = readOpenTypeHeader(ttc);
|
||||
const potentialTables = readTables(ttc, potentialHeader.numTables);
|
||||
|
||||
if (!potentialTables["name"]) {
|
||||
if (!potentialTables.name) {
|
||||
throw new FormatError(
|
||||
'TrueType Collection font must contain a "name" table.'
|
||||
);
|
||||
}
|
||||
const nameTable = readNameTable(potentialTables["name"]);
|
||||
const nameTable = readNameTable(potentialTables.name);
|
||||
|
||||
for (let j = 0, jj = nameTable.length; j < jj; j++) {
|
||||
for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
|
||||
@ -2591,10 +2591,10 @@ var Font = (function FontClosure() {
|
||||
// OpenType font (skip composite fonts with non-default glyph mapping).
|
||||
if (
|
||||
(header.version === "OTTO" && !isComposite) ||
|
||||
!tables["head"] ||
|
||||
!tables["hhea"] ||
|
||||
!tables["maxp"] ||
|
||||
!tables["post"]
|
||||
!tables.head ||
|
||||
!tables.hhea ||
|
||||
!tables.maxp ||
|
||||
!tables.post
|
||||
) {
|
||||
// No major tables: throwing everything at `CFFFont`.
|
||||
cffFile = new Stream(tables["CFF "].data);
|
||||
@ -2605,20 +2605,20 @@ var Font = (function FontClosure() {
|
||||
return this.convert(name, cff, properties);
|
||||
}
|
||||
|
||||
delete tables["glyf"];
|
||||
delete tables["loca"];
|
||||
delete tables["fpgm"];
|
||||
delete tables["prep"];
|
||||
delete tables.glyf;
|
||||
delete tables.loca;
|
||||
delete tables.fpgm;
|
||||
delete tables.prep;
|
||||
delete tables["cvt "];
|
||||
this.isOpenType = true;
|
||||
} else {
|
||||
if (!tables["loca"]) {
|
||||
if (!tables.loca) {
|
||||
throw new FormatError('Required "loca" table is not found');
|
||||
}
|
||||
if (!tables["glyf"]) {
|
||||
if (!tables.glyf) {
|
||||
warn('Required "glyf" table is not found -- trying to recover.');
|
||||
// Note: We use `sanitizeGlyphLocations` to add dummy glyf data below.
|
||||
tables["glyf"] = {
|
||||
tables.glyf = {
|
||||
tag: "glyf",
|
||||
data: new Uint8Array(0),
|
||||
};
|
||||
@ -2626,11 +2626,11 @@ var Font = (function FontClosure() {
|
||||
this.isOpenType = false;
|
||||
}
|
||||
|
||||
if (!tables["maxp"]) {
|
||||
if (!tables.maxp) {
|
||||
throw new FormatError('Required "maxp" table is not found');
|
||||
}
|
||||
|
||||
font.pos = (font.start || 0) + tables["maxp"].offset;
|
||||
font.pos = (font.start || 0) + tables.maxp.offset;
|
||||
var version = font.getInt32();
|
||||
const numGlyphs = font.getUint16();
|
||||
// Glyph 0 is duplicated and appended.
|
||||
@ -2643,14 +2643,14 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
var maxFunctionDefs = 0;
|
||||
var maxSizeOfInstructions = 0;
|
||||
if (version >= 0x00010000 && tables["maxp"].length >= 22) {
|
||||
if (version >= 0x00010000 && tables.maxp.length >= 22) {
|
||||
// maxZones can be invalid
|
||||
font.pos += 8;
|
||||
var maxZones = font.getUint16();
|
||||
if (maxZones > 2) {
|
||||
// reset to 2 if font has invalid maxZones
|
||||
tables["maxp"].data[14] = 0;
|
||||
tables["maxp"].data[15] = 2;
|
||||
tables.maxp.data[14] = 0;
|
||||
tables.maxp.data[15] = 2;
|
||||
}
|
||||
font.pos += 4;
|
||||
maxFunctionDefs = font.getUint16();
|
||||
@ -2658,18 +2658,18 @@ var Font = (function FontClosure() {
|
||||
maxSizeOfInstructions = font.getUint16();
|
||||
}
|
||||
|
||||
tables["maxp"].data[4] = numGlyphsOut >> 8;
|
||||
tables["maxp"].data[5] = numGlyphsOut & 255;
|
||||
tables.maxp.data[4] = numGlyphsOut >> 8;
|
||||
tables.maxp.data[5] = numGlyphsOut & 255;
|
||||
|
||||
var hintsValid = sanitizeTTPrograms(
|
||||
tables["fpgm"],
|
||||
tables["prep"],
|
||||
tables.fpgm,
|
||||
tables.prep,
|
||||
tables["cvt "],
|
||||
maxFunctionDefs
|
||||
);
|
||||
if (!hintsValid) {
|
||||
delete tables["fpgm"];
|
||||
delete tables["prep"];
|
||||
delete tables.fpgm;
|
||||
delete tables.prep;
|
||||
delete tables["cvt "];
|
||||
}
|
||||
|
||||
@ -2677,31 +2677,27 @@ var Font = (function FontClosure() {
|
||||
// sidebearings information for numGlyphs in the maxp table
|
||||
sanitizeMetrics(
|
||||
font,
|
||||
tables["hhea"],
|
||||
tables["hmtx"],
|
||||
tables.hhea,
|
||||
tables.hmtx,
|
||||
numGlyphsOut,
|
||||
dupFirstEntry
|
||||
);
|
||||
|
||||
if (!tables["head"]) {
|
||||
if (!tables.head) {
|
||||
throw new FormatError('Required "head" table is not found');
|
||||
}
|
||||
|
||||
sanitizeHead(
|
||||
tables["head"],
|
||||
numGlyphs,
|
||||
isTrueType ? tables["loca"].length : 0
|
||||
);
|
||||
sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
|
||||
|
||||
var missingGlyphs = Object.create(null);
|
||||
if (isTrueType) {
|
||||
var isGlyphLocationsLong = int16(
|
||||
tables["head"].data[50],
|
||||
tables["head"].data[51]
|
||||
tables.head.data[50],
|
||||
tables.head.data[51]
|
||||
);
|
||||
var glyphsInfo = sanitizeGlyphLocations(
|
||||
tables["loca"],
|
||||
tables["glyf"],
|
||||
tables.loca,
|
||||
tables.glyf,
|
||||
numGlyphs,
|
||||
isGlyphLocationsLong,
|
||||
hintsValid,
|
||||
@ -2712,30 +2708,30 @@ var Font = (function FontClosure() {
|
||||
|
||||
// Some fonts have incorrect maxSizeOfInstructions values, so we use
|
||||
// the computed value instead.
|
||||
if (version >= 0x00010000 && tables["maxp"].length >= 22) {
|
||||
tables["maxp"].data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
|
||||
tables["maxp"].data[27] = glyphsInfo.maxSizeOfInstructions & 255;
|
||||
if (version >= 0x00010000 && tables.maxp.length >= 22) {
|
||||
tables.maxp.data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
|
||||
tables.maxp.data[27] = glyphsInfo.maxSizeOfInstructions & 255;
|
||||
}
|
||||
}
|
||||
if (!tables["hhea"]) {
|
||||
if (!tables.hhea) {
|
||||
throw new FormatError('Required "hhea" table is not found');
|
||||
}
|
||||
|
||||
// Sanitizer reduces the glyph advanceWidth to the maxAdvanceWidth
|
||||
// Sometimes it's 0. That needs to be fixed
|
||||
if (tables["hhea"].data[10] === 0 && tables["hhea"].data[11] === 0) {
|
||||
tables["hhea"].data[10] = 0xff;
|
||||
tables["hhea"].data[11] = 0xff;
|
||||
if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) {
|
||||
tables.hhea.data[10] = 0xff;
|
||||
tables.hhea.data[11] = 0xff;
|
||||
}
|
||||
|
||||
// Extract some more font properties from the OpenType head and
|
||||
// hhea tables; yMin and descent value are always negative.
|
||||
var metricsOverride = {
|
||||
unitsPerEm: int16(tables["head"].data[18], tables["head"].data[19]),
|
||||
yMax: int16(tables["head"].data[42], tables["head"].data[43]),
|
||||
yMin: signedInt16(tables["head"].data[38], tables["head"].data[39]),
|
||||
ascent: int16(tables["hhea"].data[4], tables["hhea"].data[5]),
|
||||
descent: signedInt16(tables["hhea"].data[6], tables["hhea"].data[7]),
|
||||
unitsPerEm: int16(tables.head.data[18], tables.head.data[19]),
|
||||
yMax: int16(tables.head.data[42], tables.head.data[43]),
|
||||
yMin: signedInt16(tables.head.data[38], tables.head.data[39]),
|
||||
ascent: int16(tables.hhea.data[4], tables.hhea.data[5]),
|
||||
descent: signedInt16(tables.hhea.data[6], tables.hhea.data[7]),
|
||||
};
|
||||
|
||||
// PDF FontDescriptor metrics lie -- using data from actual font.
|
||||
@ -2743,12 +2739,12 @@ var Font = (function FontClosure() {
|
||||
this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
|
||||
|
||||
// The 'post' table has glyphs names.
|
||||
if (tables["post"]) {
|
||||
readPostScriptTable(tables["post"], properties, numGlyphs);
|
||||
if (tables.post) {
|
||||
readPostScriptTable(tables.post, properties, numGlyphs);
|
||||
}
|
||||
|
||||
// The original 'post' table is not needed, replace it.
|
||||
tables["post"] = {
|
||||
tables.post = {
|
||||
tag: "post",
|
||||
data: createPostTable(properties),
|
||||
};
|
||||
@ -2783,7 +2779,7 @@ var Font = (function FontClosure() {
|
||||
// Most of the following logic in this code branch is based on the
|
||||
// 9.6.6.4 of the PDF spec.
|
||||
var cmapTable = readCmapTable(
|
||||
tables["cmap"],
|
||||
tables.cmap,
|
||||
font,
|
||||
this.isSymbolicFont,
|
||||
properties.hasEncoding
|
||||
@ -2916,7 +2912,7 @@ var Font = (function FontClosure() {
|
||||
// Converting glyphs and ids into font's cmap table
|
||||
var newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId);
|
||||
this.toFontChar = newMapping.toFontChar;
|
||||
tables["cmap"] = {
|
||||
tables.cmap = {
|
||||
tag: "cmap",
|
||||
data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphsOut),
|
||||
};
|
||||
@ -2951,15 +2947,15 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
|
||||
// Re-creating 'name' table
|
||||
if (!tables["name"]) {
|
||||
tables["name"] = {
|
||||
if (!tables.name) {
|
||||
tables.name = {
|
||||
tag: "name",
|
||||
data: createNameTable(this.name),
|
||||
};
|
||||
} else {
|
||||
// ... using existing 'name' table as prototype
|
||||
var namePrototype = readNameTable(tables["name"]);
|
||||
tables["name"].data = createNameTable(name, namePrototype);
|
||||
var namePrototype = readNameTable(tables.name);
|
||||
tables.name.data = createNameTable(name, namePrototype);
|
||||
}
|
||||
|
||||
var builder = new OpenTypeFileBuilder(header.version);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1188,13 +1188,13 @@ var JpxImage = (function JpxImageClosure() {
|
||||
var codeblockIncluded = false;
|
||||
var firstTimeInclusion = false;
|
||||
var valueReady;
|
||||
if (codeblock["included"] !== undefined) {
|
||||
if (codeblock.included !== undefined) {
|
||||
codeblockIncluded = !!readBits(1);
|
||||
} else {
|
||||
// reading inclusion tree
|
||||
precinct = codeblock.precinct;
|
||||
var inclusionTree, zeroBitPlanesTree;
|
||||
if (precinct["inclusionTree"] !== undefined) {
|
||||
if (precinct.inclusionTree !== undefined) {
|
||||
inclusionTree = precinct.inclusionTree;
|
||||
} else {
|
||||
// building inclusion and zero bit-planes trees
|
||||
@ -1264,7 +1264,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
while (queue.length > 0) {
|
||||
var packetItem = queue.shift();
|
||||
codeblock = packetItem.codeblock;
|
||||
if (codeblock["data"] === undefined) {
|
||||
if (codeblock.data === undefined) {
|
||||
codeblock.data = [];
|
||||
}
|
||||
codeblock.data.push({
|
||||
@ -1302,7 +1302,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
if (blockWidth === 0 || blockHeight === 0) {
|
||||
continue;
|
||||
}
|
||||
if (codeblock["data"] === undefined) {
|
||||
if (codeblock.data === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
5832
src/core/metrics.js
5832
src/core/metrics.js
File diff suppressed because it is too large
Load Diff
@ -21,11 +21,11 @@ import { getLookupTableFactory } from "./core_utils.js";
|
||||
* fonts and their acronyms.
|
||||
*/
|
||||
const getStdFontMap = getLookupTableFactory(function (t) {
|
||||
t["ArialNarrow"] = "Helvetica";
|
||||
t.ArialNarrow = "Helvetica";
|
||||
t["ArialNarrow-Bold"] = "Helvetica-Bold";
|
||||
t["ArialNarrow-BoldItalic"] = "Helvetica-BoldOblique";
|
||||
t["ArialNarrow-Italic"] = "Helvetica-Oblique";
|
||||
t["ArialBlack"] = "Helvetica";
|
||||
t.ArialBlack = "Helvetica";
|
||||
t["ArialBlack-Bold"] = "Helvetica-Bold";
|
||||
t["ArialBlack-BoldItalic"] = "Helvetica-BoldOblique";
|
||||
t["ArialBlack-Italic"] = "Helvetica-Oblique";
|
||||
@ -33,26 +33,26 @@ const getStdFontMap = getLookupTableFactory(function (t) {
|
||||
t["Arial-Black-Bold"] = "Helvetica-Bold";
|
||||
t["Arial-Black-BoldItalic"] = "Helvetica-BoldOblique";
|
||||
t["Arial-Black-Italic"] = "Helvetica-Oblique";
|
||||
t["Arial"] = "Helvetica";
|
||||
t.Arial = "Helvetica";
|
||||
t["Arial-Bold"] = "Helvetica-Bold";
|
||||
t["Arial-BoldItalic"] = "Helvetica-BoldOblique";
|
||||
t["Arial-Italic"] = "Helvetica-Oblique";
|
||||
t["Arial-BoldItalicMT"] = "Helvetica-BoldOblique";
|
||||
t["Arial-BoldMT"] = "Helvetica-Bold";
|
||||
t["Arial-ItalicMT"] = "Helvetica-Oblique";
|
||||
t["ArialMT"] = "Helvetica";
|
||||
t.ArialMT = "Helvetica";
|
||||
t["Courier-Bold"] = "Courier-Bold";
|
||||
t["Courier-BoldItalic"] = "Courier-BoldOblique";
|
||||
t["Courier-Italic"] = "Courier-Oblique";
|
||||
t["CourierNew"] = "Courier";
|
||||
t.CourierNew = "Courier";
|
||||
t["CourierNew-Bold"] = "Courier-Bold";
|
||||
t["CourierNew-BoldItalic"] = "Courier-BoldOblique";
|
||||
t["CourierNew-Italic"] = "Courier-Oblique";
|
||||
t["CourierNewPS-BoldItalicMT"] = "Courier-BoldOblique";
|
||||
t["CourierNewPS-BoldMT"] = "Courier-Bold";
|
||||
t["CourierNewPS-ItalicMT"] = "Courier-Oblique";
|
||||
t["CourierNewPSMT"] = "Courier";
|
||||
t["Helvetica"] = "Helvetica";
|
||||
t.CourierNewPSMT = "Courier";
|
||||
t.Helvetica = "Helvetica";
|
||||
t["Helvetica-Bold"] = "Helvetica-Bold";
|
||||
t["Helvetica-BoldItalic"] = "Helvetica-BoldOblique";
|
||||
t["Helvetica-BoldOblique"] = "Helvetica-BoldOblique";
|
||||
@ -61,18 +61,18 @@ const getStdFontMap = getLookupTableFactory(function (t) {
|
||||
t["Symbol-Bold"] = "Symbol";
|
||||
t["Symbol-BoldItalic"] = "Symbol";
|
||||
t["Symbol-Italic"] = "Symbol";
|
||||
t["TimesNewRoman"] = "Times-Roman";
|
||||
t.TimesNewRoman = "Times-Roman";
|
||||
t["TimesNewRoman-Bold"] = "Times-Bold";
|
||||
t["TimesNewRoman-BoldItalic"] = "Times-BoldItalic";
|
||||
t["TimesNewRoman-Italic"] = "Times-Italic";
|
||||
t["TimesNewRomanPS"] = "Times-Roman";
|
||||
t.TimesNewRomanPS = "Times-Roman";
|
||||
t["TimesNewRomanPS-Bold"] = "Times-Bold";
|
||||
t["TimesNewRomanPS-BoldItalic"] = "Times-BoldItalic";
|
||||
t["TimesNewRomanPS-BoldItalicMT"] = "Times-BoldItalic";
|
||||
t["TimesNewRomanPS-BoldMT"] = "Times-Bold";
|
||||
t["TimesNewRomanPS-Italic"] = "Times-Italic";
|
||||
t["TimesNewRomanPS-ItalicMT"] = "Times-Italic";
|
||||
t["TimesNewRomanPSMT"] = "Times-Roman";
|
||||
t.TimesNewRomanPSMT = "Times-Roman";
|
||||
t["TimesNewRomanPSMT-Bold"] = "Times-Bold";
|
||||
t["TimesNewRomanPSMT-BoldItalic"] = "Times-BoldItalic";
|
||||
t["TimesNewRomanPSMT-Italic"] = "Times-Italic";
|
||||
@ -83,19 +83,19 @@ const getStdFontMap = getLookupTableFactory(function (t) {
|
||||
* a standard fonts without glyph data.
|
||||
*/
|
||||
const getNonStdFontMap = getLookupTableFactory(function (t) {
|
||||
t["Calibri"] = "Helvetica";
|
||||
t.Calibri = "Helvetica";
|
||||
t["Calibri-Bold"] = "Helvetica-Bold";
|
||||
t["Calibri-BoldItalic"] = "Helvetica-BoldOblique";
|
||||
t["Calibri-Italic"] = "Helvetica-Oblique";
|
||||
t["CenturyGothic"] = "Helvetica";
|
||||
t.CenturyGothic = "Helvetica";
|
||||
t["CenturyGothic-Bold"] = "Helvetica-Bold";
|
||||
t["CenturyGothic-BoldItalic"] = "Helvetica-BoldOblique";
|
||||
t["CenturyGothic-Italic"] = "Helvetica-Oblique";
|
||||
t["ComicSansMS"] = "Comic Sans MS";
|
||||
t.ComicSansMS = "Comic Sans MS";
|
||||
t["ComicSansMS-Bold"] = "Comic Sans MS-Bold";
|
||||
t["ComicSansMS-BoldItalic"] = "Comic Sans MS-BoldItalic";
|
||||
t["ComicSansMS-Italic"] = "Comic Sans MS-Italic";
|
||||
t["LucidaConsole"] = "Courier";
|
||||
t.LucidaConsole = "Courier";
|
||||
t["LucidaConsole-Bold"] = "Courier-Bold";
|
||||
t["LucidaConsole-BoldItalic"] = "Courier-BoldOblique";
|
||||
t["LucidaConsole-Italic"] = "Courier-Oblique";
|
||||
@ -116,103 +116,103 @@ const getNonStdFontMap = getLookupTableFactory(function (t) {
|
||||
t["MS-PMincho-Bold"] = "MS PMincho-Bold";
|
||||
t["MS-PMincho-BoldItalic"] = "MS PMincho-BoldItalic";
|
||||
t["MS-PMincho-Italic"] = "MS PMincho-Italic";
|
||||
t["NuptialScript"] = "Times-Italic";
|
||||
t["SegoeUISymbol"] = "Helvetica";
|
||||
t["Wingdings"] = "ZapfDingbats";
|
||||
t.NuptialScript = "Times-Italic";
|
||||
t.SegoeUISymbol = "Helvetica";
|
||||
t.Wingdings = "ZapfDingbats";
|
||||
t["Wingdings-Regular"] = "ZapfDingbats";
|
||||
});
|
||||
|
||||
const getSerifFonts = getLookupTableFactory(function (t) {
|
||||
t["Adobe Jenson"] = true;
|
||||
t["Adobe Text"] = true;
|
||||
t["Albertus"] = true;
|
||||
t["Aldus"] = true;
|
||||
t["Alexandria"] = true;
|
||||
t["Algerian"] = true;
|
||||
t.Albertus = true;
|
||||
t.Aldus = true;
|
||||
t.Alexandria = true;
|
||||
t.Algerian = true;
|
||||
t["American Typewriter"] = true;
|
||||
t["Antiqua"] = true;
|
||||
t["Apex"] = true;
|
||||
t["Arno"] = true;
|
||||
t["Aster"] = true;
|
||||
t["Aurora"] = true;
|
||||
t["Baskerville"] = true;
|
||||
t["Bell"] = true;
|
||||
t["Bembo"] = true;
|
||||
t.Antiqua = true;
|
||||
t.Apex = true;
|
||||
t.Arno = true;
|
||||
t.Aster = true;
|
||||
t.Aurora = true;
|
||||
t.Baskerville = true;
|
||||
t.Bell = true;
|
||||
t.Bembo = true;
|
||||
t["Bembo Schoolbook"] = true;
|
||||
t["Benguiat"] = true;
|
||||
t.Benguiat = true;
|
||||
t["Berkeley Old Style"] = true;
|
||||
t["Bernhard Modern"] = true;
|
||||
t["Berthold City"] = true;
|
||||
t["Bodoni"] = true;
|
||||
t.Bodoni = true;
|
||||
t["Bauer Bodoni"] = true;
|
||||
t["Book Antiqua"] = true;
|
||||
t["Bookman"] = true;
|
||||
t.Bookman = true;
|
||||
t["Bordeaux Roman"] = true;
|
||||
t["Californian FB"] = true;
|
||||
t["Calisto"] = true;
|
||||
t["Calvert"] = true;
|
||||
t["Capitals"] = true;
|
||||
t["Cambria"] = true;
|
||||
t["Cartier"] = true;
|
||||
t["Caslon"] = true;
|
||||
t["Catull"] = true;
|
||||
t["Centaur"] = true;
|
||||
t.Calisto = true;
|
||||
t.Calvert = true;
|
||||
t.Capitals = true;
|
||||
t.Cambria = true;
|
||||
t.Cartier = true;
|
||||
t.Caslon = true;
|
||||
t.Catull = true;
|
||||
t.Centaur = true;
|
||||
t["Century Old Style"] = true;
|
||||
t["Century Schoolbook"] = true;
|
||||
t["Chaparral"] = true;
|
||||
t.Chaparral = true;
|
||||
t["Charis SIL"] = true;
|
||||
t["Cheltenham"] = true;
|
||||
t.Cheltenham = true;
|
||||
t["Cholla Slab"] = true;
|
||||
t["Clarendon"] = true;
|
||||
t["Clearface"] = true;
|
||||
t["Cochin"] = true;
|
||||
t["Colonna"] = true;
|
||||
t.Clarendon = true;
|
||||
t.Clearface = true;
|
||||
t.Cochin = true;
|
||||
t.Colonna = true;
|
||||
t["Computer Modern"] = true;
|
||||
t["Concrete Roman"] = true;
|
||||
t["Constantia"] = true;
|
||||
t.Constantia = true;
|
||||
t["Cooper Black"] = true;
|
||||
t["Corona"] = true;
|
||||
t["Ecotype"] = true;
|
||||
t["Egyptienne"] = true;
|
||||
t["Elephant"] = true;
|
||||
t["Excelsior"] = true;
|
||||
t["Fairfield"] = true;
|
||||
t.Corona = true;
|
||||
t.Ecotype = true;
|
||||
t.Egyptienne = true;
|
||||
t.Elephant = true;
|
||||
t.Excelsior = true;
|
||||
t.Fairfield = true;
|
||||
t["FF Scala"] = true;
|
||||
t["Folkard"] = true;
|
||||
t["Footlight"] = true;
|
||||
t["FreeSerif"] = true;
|
||||
t.Folkard = true;
|
||||
t.Footlight = true;
|
||||
t.FreeSerif = true;
|
||||
t["Friz Quadrata"] = true;
|
||||
t["Garamond"] = true;
|
||||
t["Gentium"] = true;
|
||||
t["Georgia"] = true;
|
||||
t["Gloucester"] = true;
|
||||
t.Garamond = true;
|
||||
t.Gentium = true;
|
||||
t.Georgia = true;
|
||||
t.Gloucester = true;
|
||||
t["Goudy Old Style"] = true;
|
||||
t["Goudy Schoolbook"] = true;
|
||||
t["Goudy Pro Font"] = true;
|
||||
t["Granjon"] = true;
|
||||
t.Granjon = true;
|
||||
t["Guardian Egyptian"] = true;
|
||||
t["Heather"] = true;
|
||||
t["Hercules"] = true;
|
||||
t.Heather = true;
|
||||
t.Hercules = true;
|
||||
t["High Tower Text"] = true;
|
||||
t["Hiroshige"] = true;
|
||||
t.Hiroshige = true;
|
||||
t["Hoefler Text"] = true;
|
||||
t["Humana Serif"] = true;
|
||||
t["Imprint"] = true;
|
||||
t.Imprint = true;
|
||||
t["Ionic No. 5"] = true;
|
||||
t["Janson"] = true;
|
||||
t["Joanna"] = true;
|
||||
t["Korinna"] = true;
|
||||
t["Lexicon"] = true;
|
||||
t.Janson = true;
|
||||
t.Joanna = true;
|
||||
t.Korinna = true;
|
||||
t.Lexicon = true;
|
||||
t["Liberation Serif"] = true;
|
||||
t["Linux Libertine"] = true;
|
||||
t["Literaturnaya"] = true;
|
||||
t["Lucida"] = true;
|
||||
t.Literaturnaya = true;
|
||||
t.Lucida = true;
|
||||
t["Lucida Bright"] = true;
|
||||
t["Melior"] = true;
|
||||
t["Memphis"] = true;
|
||||
t["Miller"] = true;
|
||||
t["Minion"] = true;
|
||||
t["Modern"] = true;
|
||||
t.Melior = true;
|
||||
t.Memphis = true;
|
||||
t.Miller = true;
|
||||
t.Minion = true;
|
||||
t.Modern = true;
|
||||
t["Mona Lisa"] = true;
|
||||
t["Mrs Eaves"] = true;
|
||||
t["MS Serif"] = true;
|
||||
@ -220,48 +220,48 @@ const getSerifFonts = getLookupTableFactory(function (t) {
|
||||
t["New York"] = true;
|
||||
t["Nimbus Roman"] = true;
|
||||
t["NPS Rawlinson Roadway"] = true;
|
||||
t["NuptialScript"] = true;
|
||||
t["Palatino"] = true;
|
||||
t["Perpetua"] = true;
|
||||
t["Plantin"] = true;
|
||||
t.NuptialScript = true;
|
||||
t.Palatino = true;
|
||||
t.Perpetua = true;
|
||||
t.Plantin = true;
|
||||
t["Plantin Schoolbook"] = true;
|
||||
t["Playbill"] = true;
|
||||
t.Playbill = true;
|
||||
t["Poor Richard"] = true;
|
||||
t["Rawlinson Roadway"] = true;
|
||||
t["Renault"] = true;
|
||||
t["Requiem"] = true;
|
||||
t["Rockwell"] = true;
|
||||
t["Roman"] = true;
|
||||
t.Renault = true;
|
||||
t.Requiem = true;
|
||||
t.Rockwell = true;
|
||||
t.Roman = true;
|
||||
t["Rotis Serif"] = true;
|
||||
t["Sabon"] = true;
|
||||
t["Scala"] = true;
|
||||
t["Seagull"] = true;
|
||||
t["Sistina"] = true;
|
||||
t["Souvenir"] = true;
|
||||
t["STIX"] = true;
|
||||
t.Sabon = true;
|
||||
t.Scala = true;
|
||||
t.Seagull = true;
|
||||
t.Sistina = true;
|
||||
t.Souvenir = true;
|
||||
t.STIX = true;
|
||||
t["Stone Informal"] = true;
|
||||
t["Stone Serif"] = true;
|
||||
t["Sylfaen"] = true;
|
||||
t["Times"] = true;
|
||||
t["Trajan"] = true;
|
||||
t.Sylfaen = true;
|
||||
t.Times = true;
|
||||
t.Trajan = true;
|
||||
t["Trinité"] = true;
|
||||
t["Trump Mediaeval"] = true;
|
||||
t["Utopia"] = true;
|
||||
t.Utopia = true;
|
||||
t["Vale Type"] = true;
|
||||
t["Bitstream Vera"] = true;
|
||||
t["Vera Serif"] = true;
|
||||
t["Versailles"] = true;
|
||||
t["Wanted"] = true;
|
||||
t["Weiss"] = true;
|
||||
t.Versailles = true;
|
||||
t.Wanted = true;
|
||||
t.Weiss = true;
|
||||
t["Wide Latin"] = true;
|
||||
t["Windsor"] = true;
|
||||
t["XITS"] = true;
|
||||
t.Windsor = true;
|
||||
t.XITS = true;
|
||||
});
|
||||
|
||||
const getSymbolsFonts = getLookupTableFactory(function (t) {
|
||||
t["Dingbats"] = true;
|
||||
t["Symbol"] = true;
|
||||
t["ZapfDingbats"] = true;
|
||||
t.Dingbats = true;
|
||||
t.Symbol = true;
|
||||
t.ZapfDingbats = true;
|
||||
});
|
||||
|
||||
// Glyph map for well-known standard fonts. Sometimes Ghostscript uses CID
|
||||
|
@ -566,7 +566,7 @@ var Type1Parser = (function Type1ParserClosure() {
|
||||
var subrs = [],
|
||||
charstrings = [];
|
||||
var privateData = Object.create(null);
|
||||
privateData["lenIV"] = 4;
|
||||
privateData.lenIV = 4;
|
||||
var program = {
|
||||
subrs: [],
|
||||
charstrings: [],
|
||||
@ -601,7 +601,7 @@ var Type1Parser = (function Type1ParserClosure() {
|
||||
length = this.readInt();
|
||||
this.getToken(); // read in 'RD' or '-|'
|
||||
data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
|
||||
lenIV = program.properties.privateData["lenIV"];
|
||||
lenIV = program.properties.privateData.lenIV;
|
||||
encoded = this.readCharStrings(data, lenIV);
|
||||
this.nextChar();
|
||||
token = this.getToken(); // read in 'ND' or '|-'
|
||||
@ -622,7 +622,7 @@ var Type1Parser = (function Type1ParserClosure() {
|
||||
length = this.readInt();
|
||||
this.getToken(); // read in 'RD' or '-|'
|
||||
data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
|
||||
lenIV = program.properties.privateData["lenIV"];
|
||||
lenIV = program.properties.privateData.lenIV;
|
||||
encoded = this.readCharStrings(data, lenIV);
|
||||
this.nextChar();
|
||||
token = this.getToken(); // read in 'NP' or '|'
|
||||
|
@ -376,7 +376,7 @@ class PDFNodeStreamRangeReader extends BaseRangeReader {
|
||||
}
|
||||
this._httpHeaders[property] = value;
|
||||
}
|
||||
this._httpHeaders["Range"] = `bytes=${start}-${end - 1}`;
|
||||
this._httpHeaders.Range = `bytes=${start}-${end - 1}`;
|
||||
|
||||
const handleResponse = response => {
|
||||
if (response.statusCode === 404) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
const isNodeJS =
|
||||
typeof process === "object" &&
|
||||
process + "" === "[object process]" &&
|
||||
!process.versions["nw"] &&
|
||||
!process.versions["electron"];
|
||||
!process.versions.nw &&
|
||||
!process.versions.electron;
|
||||
|
||||
export { isNodeJS };
|
||||
|
@ -46,7 +46,7 @@ function group(stats, groupBy) {
|
||||
if (vals[key] === undefined) {
|
||||
vals[key] = [];
|
||||
}
|
||||
vals[key].push(curStat["time"]);
|
||||
vals[key].push(curStat.time);
|
||||
}
|
||||
return vals;
|
||||
}
|
||||
@ -58,14 +58,14 @@ function group(stats, groupBy) {
|
||||
function flatten(stats) {
|
||||
var rows = [];
|
||||
stats.forEach(function (curStat) {
|
||||
curStat["stats"].forEach(function (s) {
|
||||
curStat.stats.forEach(function (s) {
|
||||
rows.push({
|
||||
browser: curStat["browser"],
|
||||
page: curStat["page"],
|
||||
pdf: curStat["pdf"],
|
||||
round: curStat["round"],
|
||||
stat: s["name"],
|
||||
time: s["end"] - s["start"],
|
||||
browser: curStat.browser,
|
||||
page: curStat.page,
|
||||
pdf: curStat.pdf,
|
||||
round: curStat.round,
|
||||
stat: s.name,
|
||||
time: s.end - s.start,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -191,7 +191,7 @@ function examineRefImages() {
|
||||
server.port +
|
||||
"/test/resources/reftest-analyzer.html#web=/test/eq.log";
|
||||
var config = Object.assign({}, sessions[0].config);
|
||||
config["headless"] = false;
|
||||
config.headless = false;
|
||||
var browser = WebBrowser.create(config);
|
||||
browser.start(startUrl);
|
||||
}
|
||||
@ -271,7 +271,7 @@ function startRefTest(masterMode, showRefImages) {
|
||||
|
||||
startTime = Date.now();
|
||||
startServer();
|
||||
server.hooks["POST"].push(refTestPostHandler);
|
||||
server.hooks.POST.push(refTestPostHandler);
|
||||
onAllSessionsClosed = finalize;
|
||||
|
||||
startBrowsers("/test/test_slave.html", function (session) {
|
||||
@ -692,7 +692,7 @@ function refTestPostHandler(req, res) {
|
||||
function startUnitTest(testUrl, name) {
|
||||
var startTime = Date.now();
|
||||
startServer();
|
||||
server.hooks["POST"].push(unitTestPostHandler);
|
||||
server.hooks.POST.push(unitTestPostHandler);
|
||||
onAllSessionsClosed = function () {
|
||||
stopServer();
|
||||
var numRuns = 0,
|
||||
|
@ -1116,15 +1116,15 @@ describe("api", function () {
|
||||
var promise = pdfDocument.getMetadata();
|
||||
promise
|
||||
.then(function ({ info, metadata, contentDispositionFilename }) {
|
||||
expect(info["Title"]).toEqual("Basic API Test");
|
||||
expect(info.Title).toEqual("Basic API Test");
|
||||
// Custom, non-standard, information dictionary entries.
|
||||
expect(info["Custom"]).toEqual(undefined);
|
||||
expect(info.Custom).toEqual(undefined);
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info["PDFFormatVersion"]).toEqual("1.7");
|
||||
expect(info["IsLinearized"]).toEqual(false);
|
||||
expect(info["IsAcroFormPresent"]).toEqual(false);
|
||||
expect(info["IsXFAPresent"]).toEqual(false);
|
||||
expect(info["IsCollectionPresent"]).toEqual(false);
|
||||
expect(info.PDFFormatVersion).toEqual("1.7");
|
||||
expect(info.IsLinearized).toEqual(false);
|
||||
expect(info.IsAcroFormPresent).toEqual(false);
|
||||
expect(info.IsXFAPresent).toEqual(false);
|
||||
expect(info.IsCollectionPresent).toEqual(false);
|
||||
|
||||
expect(metadata instanceof Metadata).toEqual(true);
|
||||
expect(metadata.get("dc:title")).toEqual("Basic API Test");
|
||||
@ -1142,11 +1142,11 @@ describe("api", function () {
|
||||
return pdfDoc.getMetadata();
|
||||
})
|
||||
.then(function ({ info, metadata, contentDispositionFilename }) {
|
||||
expect(info["Creator"]).toEqual("TeX");
|
||||
expect(info["Producer"]).toEqual("pdfeTeX-1.21a");
|
||||
expect(info["CreationDate"]).toEqual("D:20090401163925-07'00'");
|
||||
expect(info.Creator).toEqual("TeX");
|
||||
expect(info.Producer).toEqual("pdfeTeX-1.21a");
|
||||
expect(info.CreationDate).toEqual("D:20090401163925-07'00'");
|
||||
// Custom, non-standard, information dictionary entries.
|
||||
const custom = info["Custom"];
|
||||
const custom = info.Custom;
|
||||
expect(typeof custom === "object" && custom !== null).toEqual(true);
|
||||
|
||||
expect(custom["PTEX.Fullbanner"]).toEqual(
|
||||
@ -1154,11 +1154,11 @@ describe("api", function () {
|
||||
"Version 3.141592-1.21a-2.2 (Web2C 7.5.4) kpathsea version 3.5.6"
|
||||
);
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info["PDFFormatVersion"]).toEqual("1.4");
|
||||
expect(info["IsLinearized"]).toEqual(false);
|
||||
expect(info["IsAcroFormPresent"]).toEqual(false);
|
||||
expect(info["IsXFAPresent"]).toEqual(false);
|
||||
expect(info["IsCollectionPresent"]).toEqual(false);
|
||||
expect(info.PDFFormatVersion).toEqual("1.4");
|
||||
expect(info.IsLinearized).toEqual(false);
|
||||
expect(info.IsAcroFormPresent).toEqual(false);
|
||||
expect(info.IsXFAPresent).toEqual(false);
|
||||
expect(info.IsCollectionPresent).toEqual(false);
|
||||
|
||||
expect(metadata).toEqual(null);
|
||||
expect(contentDispositionFilename).toEqual(null);
|
||||
@ -1176,11 +1176,11 @@ describe("api", function () {
|
||||
})
|
||||
.then(function ({ info, metadata, contentDispositionFilename }) {
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info["PDFFormatVersion"]).toEqual(null);
|
||||
expect(info["IsLinearized"]).toEqual(false);
|
||||
expect(info["IsAcroFormPresent"]).toEqual(false);
|
||||
expect(info["IsXFAPresent"]).toEqual(false);
|
||||
expect(info["IsCollectionPresent"]).toEqual(false);
|
||||
expect(info.PDFFormatVersion).toEqual(null);
|
||||
expect(info.IsLinearized).toEqual(false);
|
||||
expect(info.IsAcroFormPresent).toEqual(false);
|
||||
expect(info.IsXFAPresent).toEqual(false);
|
||||
expect(info.IsCollectionPresent).toEqual(false);
|
||||
|
||||
expect(metadata).toEqual(null);
|
||||
expect(contentDispositionFilename).toEqual(null);
|
||||
|
@ -47,7 +47,7 @@ describe("node_stream", function () {
|
||||
response.end(`File ${request.url} not found!`);
|
||||
return;
|
||||
}
|
||||
if (!request.headers["range"]) {
|
||||
if (!request.headers.range) {
|
||||
const contentLength = stat.size;
|
||||
const stream = fs.createReadStream(filePath);
|
||||
response.writeHead(200, {
|
||||
@ -57,7 +57,7 @@ describe("node_stream", function () {
|
||||
});
|
||||
stream.pipe(response);
|
||||
} else {
|
||||
const [start, end] = request.headers["range"]
|
||||
const [start, end] = request.headers.range
|
||||
.split("=")[1]
|
||||
.split("-")
|
||||
.map(x => {
|
||||
|
@ -19,7 +19,7 @@ var TestReporter = function (browser, appPath) {
|
||||
}
|
||||
}
|
||||
};
|
||||
json["browser"] = browser;
|
||||
json.browser = browser;
|
||||
r.send(JSON.stringify(json));
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ var TestReporter = function (browser, appPath) {
|
||||
description,
|
||||
};
|
||||
if (typeof error !== "undefined") {
|
||||
message["error"] = error;
|
||||
message.error = error;
|
||||
}
|
||||
send("/submit_task_results", message);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ describe("unicode", function () {
|
||||
});
|
||||
|
||||
it("should not normalize standard characters", function () {
|
||||
expect(NormalizedUnicodes["A"]).toEqual(undefined);
|
||||
expect(NormalizedUnicodes.A).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -163,7 +163,7 @@ WebServer.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = req.headers["range"];
|
||||
var range = req.headers.range;
|
||||
if (range && !disableRangeRequests) {
|
||||
var rangesMatches = /^bytes=(\d+)\-(\d+)?/.exec(range);
|
||||
if (!rangesMatches) {
|
||||
@ -344,11 +344,11 @@ WebServer.prototype = {
|
||||
// http://localhost:8888/test/unit/unit_test.html?spec=Cross-origin
|
||||
function crossOriginHandler(req, res) {
|
||||
if (req.url === "/test/pdfs/basicapi.pdf?cors=withCredentials") {
|
||||
res.setHeader("Access-Control-Allow-Origin", req.headers["origin"]);
|
||||
res.setHeader("Access-Control-Allow-Origin", req.headers.origin);
|
||||
res.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
}
|
||||
if (req.url === "/test/pdfs/basicapi.pdf?cors=withoutCredentials") {
|
||||
res.setHeader("Access-Control-Allow-Origin", req.headers["origin"]);
|
||||
res.setHeader("Access-Control-Allow-Origin", req.headers.origin);
|
||||
}
|
||||
}
|
||||
|
||||
|
34
web/app.js
34
web/app.js
@ -263,41 +263,35 @@ const PDFViewerApplication = {
|
||||
const hashParams = parseQueryString(hash),
|
||||
waitOn = [];
|
||||
|
||||
if (
|
||||
"disableworker" in hashParams &&
|
||||
hashParams["disableworker"] === "true"
|
||||
) {
|
||||
if ("disableworker" in hashParams && hashParams.disableworker === "true") {
|
||||
waitOn.push(loadFakeWorker());
|
||||
}
|
||||
if ("disablerange" in hashParams) {
|
||||
AppOptions.set("disableRange", hashParams["disablerange"] === "true");
|
||||
AppOptions.set("disableRange", hashParams.disablerange === "true");
|
||||
}
|
||||
if ("disablestream" in hashParams) {
|
||||
AppOptions.set("disableStream", hashParams["disablestream"] === "true");
|
||||
AppOptions.set("disableStream", hashParams.disablestream === "true");
|
||||
}
|
||||
if ("disableautofetch" in hashParams) {
|
||||
AppOptions.set(
|
||||
"disableAutoFetch",
|
||||
hashParams["disableautofetch"] === "true"
|
||||
hashParams.disableautofetch === "true"
|
||||
);
|
||||
}
|
||||
if ("disablefontface" in hashParams) {
|
||||
AppOptions.set(
|
||||
"disableFontFace",
|
||||
hashParams["disablefontface"] === "true"
|
||||
);
|
||||
AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
|
||||
}
|
||||
if ("disablehistory" in hashParams) {
|
||||
AppOptions.set("disableHistory", hashParams["disablehistory"] === "true");
|
||||
AppOptions.set("disableHistory", hashParams.disablehistory === "true");
|
||||
}
|
||||
if ("webgl" in hashParams) {
|
||||
AppOptions.set("enableWebGL", hashParams["webgl"] === "true");
|
||||
AppOptions.set("enableWebGL", hashParams.webgl === "true");
|
||||
}
|
||||
if ("verbosity" in hashParams) {
|
||||
AppOptions.set("verbosity", hashParams["verbosity"] | 0);
|
||||
AppOptions.set("verbosity", hashParams.verbosity | 0);
|
||||
}
|
||||
if ("textlayer" in hashParams) {
|
||||
switch (hashParams["textlayer"]) {
|
||||
switch (hashParams.textlayer) {
|
||||
case "off":
|
||||
AppOptions.set("textLayerMode", TextLayerMode.DISABLE);
|
||||
break;
|
||||
@ -305,7 +299,7 @@ const PDFViewerApplication = {
|
||||
case "shadow":
|
||||
case "hover":
|
||||
const viewer = this.appConfig.viewerContainer;
|
||||
viewer.classList.add("textLayer-" + hashParams["textlayer"]);
|
||||
viewer.classList.add("textLayer-" + hashParams.textlayer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -313,7 +307,7 @@ const PDFViewerApplication = {
|
||||
AppOptions.set("pdfBug", true);
|
||||
AppOptions.set("fontExtraProperties", true);
|
||||
|
||||
const enabled = hashParams["pdfbug"].split(",");
|
||||
const enabled = hashParams.pdfbug.split(",");
|
||||
waitOn.push(loadAndEnablePDFBug(enabled));
|
||||
}
|
||||
// It is not possible to change locale for the (various) extension builds.
|
||||
@ -322,7 +316,7 @@ const PDFViewerApplication = {
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
|
||||
"locale" in hashParams
|
||||
) {
|
||||
AppOptions.set("locale", hashParams["locale"]);
|
||||
AppOptions.set("locale", hashParams.locale);
|
||||
}
|
||||
|
||||
return Promise.all(waitOn).catch(reason => {
|
||||
@ -1004,7 +998,7 @@ const PDFViewerApplication = {
|
||||
// To prevent displaying a partially filled loading bar permanently, we
|
||||
// hide it when no data has been loaded during a certain amount of time.
|
||||
const disableAutoFetch = this.pdfDocument
|
||||
? this.pdfDocument.loadingParams["disableAutoFetch"]
|
||||
? this.pdfDocument.loadingParams.disableAutoFetch
|
||||
: AppOptions.get("disableAutoFetch");
|
||||
|
||||
if (disableAutoFetch && percent) {
|
||||
@ -1287,7 +1281,7 @@ const PDFViewerApplication = {
|
||||
|
||||
let pdfTitle;
|
||||
|
||||
const infoTitle = info && info["Title"];
|
||||
const infoTitle = info && info.Title;
|
||||
if (infoTitle) {
|
||||
pdfTitle = infoTitle;
|
||||
}
|
||||
|
@ -519,10 +519,7 @@ class BaseViewer {
|
||||
|
||||
// In addition to 'disableAutoFetch' being set, also attempt to reduce
|
||||
// resource usage when loading *very* long/large documents.
|
||||
if (
|
||||
pdfDocument.loadingParams["disableAutoFetch"] ||
|
||||
pagesCount > 7500
|
||||
) {
|
||||
if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
|
||||
// XXX: Printing is semi-broken with auto fetch disabled.
|
||||
this._pagesCapability.resolve();
|
||||
return;
|
||||
|
@ -118,8 +118,8 @@ class PDFDocumentProperties {
|
||||
// just update the dialog immediately to avoid redundant lookups.
|
||||
if (
|
||||
this.fieldData &&
|
||||
currentPageNumber === this.fieldData["_currentPageNumber"] &&
|
||||
pagesRotation === this.fieldData["_pagesRotation"]
|
||||
currentPageNumber === this.fieldData._currentPageNumber &&
|
||||
pagesRotation === this.fieldData._pagesRotation
|
||||
) {
|
||||
this._updateUI();
|
||||
return;
|
||||
@ -186,11 +186,11 @@ class PDFDocumentProperties {
|
||||
return this._parseFileSize(length);
|
||||
})
|
||||
.then(fileSize => {
|
||||
if (fileSize === this.fieldData["fileSize"]) {
|
||||
if (fileSize === this.fieldData.fileSize) {
|
||||
return; // The fileSize has already been correctly set.
|
||||
}
|
||||
const data = Object.assign(Object.create(null), this.fieldData);
|
||||
data["fileSize"] = fileSize;
|
||||
data.fileSize = fileSize;
|
||||
|
||||
freezeFieldData(data);
|
||||
this._updateUI();
|
||||
|
@ -228,8 +228,8 @@ class PDFLinkService {
|
||||
if ("search" in params) {
|
||||
this.eventBus.dispatch("findfromurlhash", {
|
||||
source: this,
|
||||
query: params["search"].replace(/"/g, ""),
|
||||
phraseSearch: params["phrase"] === "true",
|
||||
query: params.search.replace(/"/g, ""),
|
||||
phraseSearch: params.phrase === "true",
|
||||
});
|
||||
}
|
||||
// borrowing syntax from "Parameters for Opening PDF Files"
|
||||
|
@ -66,7 +66,7 @@ function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
|
||||
this.printContainer = printContainer;
|
||||
this.l10n = l10n || NullL10n;
|
||||
this.disableCreateObjectURL =
|
||||
pdfDocument.loadingParams["disableCreateObjectURL"];
|
||||
pdfDocument.loadingParams.disableCreateObjectURL;
|
||||
this.currentPage = -1;
|
||||
// The temporary canvas where renderPage paints one page at a time.
|
||||
this.scratchCanvas = document.createElement("canvas");
|
||||
|
Loading…
Reference in New Issue
Block a user