From 8611c48f9f889fb97e13f453cdb830f2a48dc445 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sat, 13 May 2023 16:15:15 +0200 Subject: [PATCH] For missing font, use a local font if it exists even if there's no standard substitution If the font foo is missing we just try lo load local(foo) and maybe we'll be lucky. --- src/core/evaluator.js | 36 +++++++++++++++++----------------- src/core/font_substitutions.js | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 4baf3ffe2759aa..2ed7a82e4d23b1 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -4197,15 +4197,15 @@ class PartialEvaluator { if (standardFontName) { file = await this.fetchStandardFontData(standardFontName); properties.isInternalFont = !!file; - if (!properties.isInternalFont && this.options.useSystemFonts) { - properties.systemFontInfo = getFontSubstitution( - this.systemFontCache, - this.idFactory, - this.options.standardFontDataUrl, - baseFontName, - standardFontName - ); - } + } + if (!properties.isInternalFont && this.options.useSystemFonts) { + properties.systemFontInfo = getFontSubstitution( + this.systemFontCache, + this.idFactory, + this.options.standardFontDataUrl, + baseFontName, + standardFontName + ); } return this.extractDataStructures(dict, dict, properties).then( newProperties => { @@ -4310,15 +4310,15 @@ class PartialEvaluator { if (standardFontName) { fontFile = await this.fetchStandardFontData(standardFontName); isInternalFont = !!fontFile; - if (!isInternalFont && this.options.useSystemFonts) { - systemFontInfo = getFontSubstitution( - this.systemFontCache, - this.idFactory, - this.options.standardFontDataUrl, - fontName.name, - standardFontName - ); - } + } + if (!isInternalFont && this.options.useSystemFonts) { + systemFontInfo = getFontSubstitution( + this.systemFontCache, + this.idFactory, + this.options.standardFontDataUrl, + fontName.name, + standardFontName + ); } } diff --git a/src/core/font_substitutions.js b/src/core/font_substitutions.js index bc576aa6d1fd3b..ec0ee7625f9ef4 100644 --- a/src/core/font_substitutions.js +++ b/src/core/font_substitutions.js @@ -378,8 +378,8 @@ function makeLocal(prepend, local) { * @param {Object} idFactory The ids factory. * @param {String} localFontPath Path to the fonts directory. * @param {String} baseFontName The font name to be substituted. - * @param {String} standardFontName The standard font name to use if the base - * font is not available. + * @param {String|undefined} standardFontName The standard font name to use + * if the base font is not available. * @returns an Object with the CSS, the loaded name, the src and the style. */ function getFontSubstitution(