summaryrefslogtreecommitdiffstats
path: root/toolkit/components/pdfjs/content/build/pdf.worker.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--toolkit/components/pdfjs/content/build/pdf.worker.js110
1 files changed, 52 insertions, 58 deletions
diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.js b/toolkit/components/pdfjs/content/build/pdf.worker.js
index 62305d24a9..87999f64a6 100644
--- a/toolkit/components/pdfjs/content/build/pdf.worker.js
+++ b/toolkit/components/pdfjs/content/build/pdf.worker.js
@@ -1421,6 +1421,18 @@ function normalizeUnicode(str) {
return p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2);
});
}
+const FontRenderOps = {
+ BEZIER_CURVE_TO: 0,
+ MOVE_TO: 1,
+ LINE_TO: 2,
+ QUADRATIC_CURVE_TO: 3,
+ RESTORE: 4,
+ SAVE: 5,
+ SCALE: 6,
+ TRANSFORM: 7,
+ TRANSLATE: 8
+};
+exports.FontRenderOps = FontRenderOps;
/***/ }),
/* 3 */
@@ -11304,6 +11316,10 @@ class PartialEvaluator {
systemFontInfo = (0, _font_substitutions.getFontSubstitution)(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, fontName.name, standardFontName);
}
}
+ let fontMatrix = dict.getArray("FontMatrix");
+ if (!Array.isArray(fontMatrix) || fontMatrix.length !== 6 || fontMatrix.some(x => typeof x !== "number")) {
+ fontMatrix = _util.FONT_IDENTITY_MATRIX;
+ }
properties = {
type,
name: fontName.name,
@@ -11316,7 +11332,7 @@ class PartialEvaluator {
loadedName: baseDict.loadedName,
composite,
fixedPitch: false,
- fontMatrix: dict.getArray("FontMatrix") || _util.FONT_IDENTITY_MATRIX,
+ fontMatrix,
firstChar,
lastChar,
toUnicode,
@@ -30781,22 +30797,13 @@ function lookupCmap(ranges, unicode) {
}
function compileGlyf(code, cmds, font) {
function moveTo(x, y) {
- cmds.push({
- cmd: "moveTo",
- args: [x, y]
- });
+ cmds.add(_util.FontRenderOps.MOVE_TO, [x, y]);
}
function lineTo(x, y) {
- cmds.push({
- cmd: "lineTo",
- args: [x, y]
- });
+ cmds.add(_util.FontRenderOps.LINE_TO, [x, y]);
}
function quadraticCurveTo(xa, ya, x, y) {
- cmds.push({
- cmd: "quadraticCurveTo",
- args: [xa, ya, x, y]
- });
+ cmds.add(_util.FontRenderOps.QUADRATIC_CURVE_TO, [xa, ya, x, y]);
}
let i = 0;
const numberOfContours = getInt16(code, i);
@@ -30855,17 +30862,11 @@ function compileGlyf(code, cmds, font) {
}
const subglyph = font.glyphs[glyphIndex];
if (subglyph) {
- cmds.push({
- cmd: "save"
- }, {
- cmd: "transform",
- args: [scaleX, scale01, scale10, scaleY, x, y]
- });
+ cmds.add(_util.FontRenderOps.SAVE);
+ cmds.add(_util.FontRenderOps.TRANSFORM, [scaleX, scale01, scale10, scaleY, x, y]);
if (!(flags & 0x02)) {}
compileGlyf(subglyph, cmds, font);
- cmds.push({
- cmd: "restore"
- });
+ cmds.add(_util.FontRenderOps.RESTORE);
}
} while (flags & 0x20);
} else {
@@ -30955,22 +30956,13 @@ function compileGlyf(code, cmds, font) {
}
function compileCharString(charStringCode, cmds, font, glyphId) {
function moveTo(x, y) {
- cmds.push({
- cmd: "moveTo",
- args: [x, y]
- });
+ cmds.add(_util.FontRenderOps.MOVE_TO, [x, y]);
}
function lineTo(x, y) {
- cmds.push({
- cmd: "lineTo",
- args: [x, y]
- });
+ cmds.add(_util.FontRenderOps.LINE_TO, [x, y]);
}
function bezierCurveTo(x1, y1, x2, y2, x, y) {
- cmds.push({
- cmd: "bezierCurveTo",
- args: [x1, y1, x2, y2, x, y]
- });
+ cmds.add(_util.FontRenderOps.BEZIER_CURVE_TO, [x1, y1, x2, y2, x, y]);
}
const stack = [];
let x = 0,
@@ -31140,17 +31132,11 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
const bchar = stack.pop();
y = stack.pop();
x = stack.pop();
- cmds.push({
- cmd: "save"
- }, {
- cmd: "translate",
- args: [x, y]
- });
+ cmds.add(_util.FontRenderOps.SAVE);
+ cmds.add(_util.FontRenderOps.TRANSLATE, [x, y]);
let cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
- cmds.push({
- cmd: "restore"
- });
+ cmds.add(_util.FontRenderOps.RESTORE);
cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
}
@@ -31317,6 +31303,22 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
parse(charStringCode);
}
const NOOP = [];
+class Commands {
+ cmds = [];
+ add(cmd, args) {
+ if (args) {
+ if (args.some(arg => typeof arg !== "number")) {
+ warn(`Commands.add - "${cmd}" has at least one non-number arg: "${args}".`);
+ const newArgs = args.map(arg => typeof arg === "number" ? arg : 0);
+ this.cmds.push(cmd, ...newArgs);
+ } else {
+ this.cmds.push(cmd, ...args);
+ }
+ } else {
+ this.cmds.push(cmd);
+ }
+ }
+}
class CompiledFont {
constructor(fontMatrix) {
if (this.constructor === CompiledFont) {
@@ -31334,8 +31336,7 @@ class CompiledFont {
let fn = this.compiledGlyphs[glyphId];
if (!fn) {
try {
- fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
- this.compiledGlyphs[glyphId] = fn;
+ fn = this.compiledGlyphs[glyphId] = this.compileGlyph(this.glyphs[glyphId], glyphId);
} catch (ex) {
this.compiledGlyphs[glyphId] = NOOP;
if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
@@ -31363,20 +31364,13 @@ class CompiledFont {
(0, _util.warn)("Invalid fd index for glyph index.");
}
}
- const cmds = [{
- cmd: "save"
- }, {
- cmd: "transform",
- args: fontMatrix.slice()
- }, {
- cmd: "scale",
- args: ["size", "-size"]
- }];
+ const cmds = new Commands();
+ cmds.add(_util.FontRenderOps.SAVE);
+ cmds.add(_util.FontRenderOps.TRANSFORM, fontMatrix.slice());
+ cmds.add(_util.FontRenderOps.SCALE);
this.compileGlyphImpl(code, cmds, glyphId);
- cmds.push({
- cmd: "restore"
- });
- return cmds;
+ cmds.add(_util.FontRenderOps.RESTORE);
+ return cmds.cmds;
}
compileGlyphImpl() {
(0, _util.unreachable)("Children classes should implement this.");