Skip to content

Commit

Permalink
For missing font, use a local font if it exists even if there's no st…
Browse files Browse the repository at this point in the history
…andard substitution

If the font foo is missing we just try lo load local(foo) and maybe
we'll be lucky.
  • Loading branch information
calixteman committed May 13, 2023
1 parent e738e15 commit 8611c48
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/font_substitutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8611c48

Please sign in to comment.