Skip to content

Commit 873378b

Browse files
Merge pull request #20836 from Snuffleupagus/FontFaceObject-fix-asserts
Fix the `disableFontFace` and `fontExtraProperties` asserts in the `FontFaceObject` constructor (PR 20197 follow-up)
2 parents 4bae676 + 9f69617 commit 873378b

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/display/font_loader.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,19 +355,22 @@ class FontLoader {
355355
}
356356

357357
class FontFaceObject {
358+
compiledGlyphs = Object.create(null);
359+
358360
#fontData;
359361

360362
constructor(translatedData, inspectFont = null, extra, charProcOperatorList) {
361-
this.compiledGlyphs = Object.create(null);
362-
this.#fontData = translatedData;
363363
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
364-
if (typeof this.disableFontFace !== "boolean") {
365-
unreachable("disableFontFace must be available.");
366-
}
367-
if (typeof this.fontExtraProperties !== "boolean") {
368-
unreachable("fontExtraProperties must be available.");
369-
}
364+
assert(
365+
typeof translatedData.disableFontFace === "boolean",
366+
"disableFontFace must be available."
367+
);
368+
assert(
369+
typeof translatedData.fontExtraProperties === "boolean",
370+
"fontExtraProperties must be available."
371+
);
370372
}
373+
this.#fontData = translatedData;
371374
this._inspectFont = inspectFont;
372375
if (extra) {
373376
Object.assign(this, extra);
@@ -453,15 +456,15 @@ class FontFaceObject {
453456
}
454457

455458
get disableFontFace() {
456-
return this.#fontData.disableFontFace ?? false;
459+
return this.#fontData.disableFontFace;
457460
}
458461

459462
set disableFontFace(value) {
460463
shadow(this, "disableFontFace", !!value);
461464
}
462465

463466
get fontExtraProperties() {
464-
return this.#fontData.fontExtraProperties ?? false;
467+
return this.#fontData.fontExtraProperties;
465468
}
466469

467470
get isInvalidPDFjsFont() {

0 commit comments

Comments
 (0)