mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-05 05:47:23 +02:00
Merge pull request #20911 from Snuffleupagus/CompiledFont-fix-NOOP
Change the `NOOP` fallback, in `CompiledFont`, to return a TypedArray
This commit is contained in:
commit
b1172bbede
@ -20,6 +20,7 @@ import {
|
|||||||
FeatureTest,
|
FeatureTest,
|
||||||
FONT_IDENTITY_MATRIX,
|
FONT_IDENTITY_MATRIX,
|
||||||
FormatError,
|
FormatError,
|
||||||
|
shadow,
|
||||||
unreachable,
|
unreachable,
|
||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
@ -736,8 +737,6 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|||||||
parse(charStringCode);
|
parse(charStringCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
const NOOP = "";
|
|
||||||
|
|
||||||
class Commands {
|
class Commands {
|
||||||
cmds = [];
|
cmds = [];
|
||||||
|
|
||||||
@ -774,12 +773,13 @@ class Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPath() {
|
getPath() {
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
if (
|
||||||
|
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
||||||
|
FeatureTest.isFloat16ArraySupported
|
||||||
|
) {
|
||||||
return new Float16Array(this.cmds);
|
return new Float16Array(this.cmds);
|
||||||
}
|
}
|
||||||
return new (
|
return new Float32Array(this.cmds);
|
||||||
FeatureTest.isFloat16ArraySupported ? Float16Array : Float32Array
|
|
||||||
)(this.cmds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,6 +797,17 @@ class CompiledFont {
|
|||||||
this.compiledCharCodeToGlyphId = Object.create(null);
|
this.compiledCharCodeToGlyphId = Object.create(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get NOOP() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"NOOP",
|
||||||
|
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
||||||
|
FeatureTest.isFloat16ArraySupported
|
||||||
|
? new Float16Array(0)
|
||||||
|
: new Float32Array(0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
getPathJs(unicode) {
|
getPathJs(unicode) {
|
||||||
const { charCode, glyphId } = lookupCmap(this.cmap, unicode);
|
const { charCode, glyphId } = lookupCmap(this.cmap, unicode);
|
||||||
let fn = this.compiledGlyphs[glyphId],
|
let fn = this.compiledGlyphs[glyphId],
|
||||||
@ -805,7 +816,7 @@ class CompiledFont {
|
|||||||
try {
|
try {
|
||||||
fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
|
fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
fn = NOOP; // Avoid attempting to re-compile a corrupt glyph.
|
fn = CompiledFont.NOOP; // Avoid attempting to re-compile a corrupt glyph.
|
||||||
|
|
||||||
compileEx = ex;
|
compileEx = ex;
|
||||||
}
|
}
|
||||||
@ -821,7 +832,7 @@ class CompiledFont {
|
|||||||
|
|
||||||
compileGlyph(code, glyphId) {
|
compileGlyph(code, glyphId) {
|
||||||
if (!code?.length || code[0] === 14) {
|
if (!code?.length || code[0] === 14) {
|
||||||
return NOOP;
|
return CompiledFont.NOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
let fontMatrix = this.fontMatrix;
|
let fontMatrix = this.fontMatrix;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user