From 2161f334a03806cfab0516f43c6b472945b2339f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 26 Sep 2022 13:25:26 +0200 Subject: [PATCH] Remove the ability to pass in more than one font to the `_prepareFontLoadEvent` method (PR 10539 follow-up) After the changes in PR 10539 (which landed over three years ago) the `FontLoader.bind` method can only be called with *a single* font at a time, hence the `_prepareFontLoadEvent` method obviously don't need to support multiple fonts any more. --- src/display/font_loader.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/display/font_loader.js b/src/display/font_loader.js index 42f57a962..84449e077 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -114,7 +114,7 @@ class FontLoader { } await new Promise(resolve => { const request = this._queueLoadingCallback(resolve); - this._prepareFontLoadEvent([font], request); + this._prepareFontLoadEvent(font, request); }); // The font was, asynchronously, loaded. } @@ -218,7 +218,7 @@ class FontLoader { return shadow(this, "_loadTestFont", testFont); } - _prepareFontLoadEvent(fonts, request) { + _prepareFontLoadEvent(font, request) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { throw new Error("Not implemented: _prepareFontLoadEvent"); } @@ -299,19 +299,13 @@ class FontLoader { const rule = `@font-face {font-family:"${loadTestFontId}";src:${url}}`; this.insertRule(rule); - const names = []; - for (const font of fonts) { - names.push(font.loadedName); - } - names.push(loadTestFontId); - const div = this._document.createElement("div"); div.style.visibility = "hidden"; div.style.width = div.style.height = "10px"; div.style.position = "absolute"; div.style.top = div.style.left = "0px"; - for (const name of names) { + for (const name of [font.loadedName, loadTestFontId]) { const span = this._document.createElement("span"); span.textContent = "Hi"; span.style.fontFamily = name;