Merge pull request #13587 from Snuffleupagus/useSystemFonts-default

Set the default value of `useSystemFonts` correctly, depending on `disableFontFace`, in the API (PR 13516 follow-up)
This commit is contained in:
Tim van der Meij 2021-06-19 18:55:17 +02:00 committed by GitHub
commit b9e8a3ce47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 17 deletions

View File

@ -397,7 +397,6 @@ class PartialEvaluator {
return new Stream(cachedData); return new Stream(cachedData);
} }
if (!this.options.disableFontFace) {
// The symbol fonts are not consistent across platforms, always load the // The symbol fonts are not consistent across platforms, always load the
// standard font data for them. // standard font data for them.
if ( if (
@ -407,7 +406,6 @@ class PartialEvaluator {
) { ) {
return null; return null;
} }
}
const standardFontNameToFileName = getFontNameToFileMap(), const standardFontNameToFileName = getFontNameToFileMap(),
filename = standardFontNameToFileName[name]; filename = standardFontNameToFileName[name];

View File

@ -153,7 +153,9 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
* Node.js. The default value is {DOMCMapReaderFactory}. * Node.js. The default value is {DOMCMapReaderFactory}.
* @property {boolean} [useSystemFonts] - When `true`, fonts that aren't * @property {boolean} [useSystemFonts] - When `true`, fonts that aren't
* embedded in the PDF document will fallback to a system font. * 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 * @property {string} [standardFontDataUrl] - The URL where the standard font
* files are located. Include the trailing slash. * files are located. Include the trailing slash.
* @property {Object} [StandardFontDataFactory] - The factory that will be used * @property {Object} [StandardFontDataFactory] - The factory that will be used
@ -328,12 +330,6 @@ function getDocument(src) {
if (!Number.isInteger(params.maxImageSize)) { if (!Number.isInteger(params.maxImageSize)) {
params.maxImageSize = -1; params.maxImageSize = -1;
} }
if (typeof params.useSystemFonts !== "boolean") {
params.useSystemFonts = !(
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
isNodeJS
);
}
if (typeof params.useWorkerFetch !== "boolean") { if (typeof params.useWorkerFetch !== "boolean") {
params.useWorkerFetch = params.useWorkerFetch =
params.CMapReaderFactory === DOMCMapReaderFactory && params.CMapReaderFactory === DOMCMapReaderFactory &&
@ -346,6 +342,13 @@ function getDocument(src) {
params.disableFontFace = params.disableFontFace =
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) && isNodeJS; (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") { if (typeof params.ownerDocument === "undefined") {
params.ownerDocument = globalThis.document; params.ownerDocument = globalThis.document;
} }