Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the default value of useSystemFonts correctly, depending on disableFontFace, in the API (PR 13516 follow-up) #13587

Merged
merged 1 commit into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,14 @@ class PartialEvaluator {
return new Stream(cachedData);
}

if (!this.options.disableFontFace) {
// The symbol fonts are not consistent across platforms, always load the
// standard font data for them.
if (
this.options.useSystemFonts &&
name !== "Symbol" &&
name !== "ZapfDingbats"
) {
return null;
}
// The symbol fonts are not consistent across platforms, always load the
// standard font data for them.
if (
this.options.useSystemFonts &&
name !== "Symbol" &&
name !== "ZapfDingbats"
) {
return null;
}

const standardFontNameToFileName = getFontNameToFileMap(),
Expand Down
17 changes: 10 additions & 7 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
* Node.js. The default value is {DOMCMapReaderFactory}.
* @property {boolean} [useSystemFonts] - When `true`, fonts that aren't
* embedded in the PDF document will fallback to a system font.
* The default value is `true` in web environments and `false` in Node.js.
* The default value is `true` in web environments and `false` in Node.js;
* unless `disableFontFace === true` in which case this defaults to `false`
* regardless of the environment (to prevent completely broken fonts).
* @property {string} [standardFontDataUrl] - The URL where the standard font
* files are located. Include the trailing slash.
* @property {Object} [StandardFontDataFactory] - The factory that will be used
Expand Down Expand Up @@ -328,12 +330,6 @@ function getDocument(src) {
if (!Number.isInteger(params.maxImageSize)) {
params.maxImageSize = -1;
}
if (typeof params.useSystemFonts !== "boolean") {
params.useSystemFonts = !(
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
isNodeJS
);
}
if (typeof params.useWorkerFetch !== "boolean") {
params.useWorkerFetch =
params.CMapReaderFactory === DOMCMapReaderFactory &&
Expand All @@ -346,6 +342,13 @@ function getDocument(src) {
params.disableFontFace =
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) && isNodeJS;
}
if (typeof params.useSystemFonts !== "boolean") {
params.useSystemFonts =
!(
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
isNodeJS
) && !params.disableFontFace;
}
if (typeof params.ownerDocument === "undefined") {
params.ownerDocument = globalThis.document;
}
Expand Down