From fec8c4c43f5bf9b7a7a1a09a0ffdc2d20f2b6e47 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 29 Jan 2021 16:29:16 +0100 Subject: [PATCH] Access `this._onUnsupportedFeature` directly in `FontFaceObject.getPathGenerator` Given that `FontFaceObject` is not exposed in the public API, but only accessed internally, there's no need to assume that a `FontFaceObject`-instance is ever initialized without `onUnsupportedFeature` being provided. This is also consistent with the `BaseFontLoader` implementation. --- src/display/font_loader.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/display/font_loader.js b/src/display/font_loader.js index 8635691e7..904168ccb 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -350,7 +350,7 @@ class FontFaceObject { isEvalSupported = true, disableFontFace = false, ignoreErrors = false, - onUnsupportedFeature = null, + onUnsupportedFeature, fontRegistry = null, } ) { @@ -405,11 +405,9 @@ class FontFaceObject { if (!this.ignoreErrors) { throw ex; } - if (this._onUnsupportedFeature) { - this._onUnsupportedFeature({ - featureId: UNSUPPORTED_FEATURES.errorFontGetPath, - }); - } + this._onUnsupportedFeature({ + featureId: UNSUPPORTED_FEATURES.errorFontGetPath, + }); warn(`getPathGenerator - ignoring character: "${ex}".`); return (this.compiledGlyphs[character] = function (c, size) {