[api-minor] Set the disableFontFace fallback value directly in the API

At this point in time, the `apiCompatibilityParams` is essentially unused with the sole exception of the `disableFontFace` handling for Node.js environments.
Given that `isNodeJS` is a constant now (originally it was a function), we can simply set the correct fallback value for `disableFontFace` directly in the API and clean-up the code a bit here.
This commit is contained in:
Jonas Jenwald 2021-06-09 13:56:31 +02:00
parent b4c96f3bc8
commit 312326991f
3 changed files with 7 additions and 41 deletions

View file

@ -54,7 +54,6 @@ import {
NodeStandardFontDataFactory,
} from "./node_utils.js";
import { AnnotationStorage } from "./annotation_storage.js";
import { apiCompatibilityParams } from "./api_compatibility.js";
import { CanvasGraphics } from "./canvas.js";
import { GlobalWorkerOptions } from "./worker_options.js";
import { isNodeJS } from "../shared/is_node.js";
@ -176,9 +175,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
* as JavaScript. Primarily used to improve performance of font rendering, and
* when parsing PDF functions. The default value is `true`.
* @property {boolean} [disableFontFace] - By default fonts are converted to
* OpenType fonts and loaded via `@font-face` rules. If disabled, fonts will
* be rendered using a built-in font renderer that constructs the glyphs with
* primitive path commands. The default value is `false`.
* OpenType fonts and loaded via the Font Loading API or `@font-face` rules.
* If disabled, fonts will be rendered using a built-in font renderer that
* constructs the glyphs with primitive path commands.
* The default value is `false` in web environments and `true` in Node.js.
* @property {boolean} [fontExtraProperties] - Include additional properties,
* which are unused during rendering of PDF documents, when exporting the
* parsed font data from the worker-thread. This may be useful for debugging
@ -340,7 +340,8 @@ function getDocument(src) {
params.isEvalSupported = true;
}
if (typeof params.disableFontFace !== "boolean") {
params.disableFontFace = apiCompatibilityParams.disableFontFace || false;
params.disableFontFace =
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) && isNodeJS;
}
if (typeof params.ownerDocument === "undefined") {
params.ownerDocument = globalThis.document;
@ -988,8 +989,7 @@ class PDFDocumentProxy {
/**
* @type {DocumentInitParameters} A subset of the current
* {DocumentInitParameters}, which are either needed in the viewer and/or
* whose default values may be affected by the `apiCompatibilityParams`.
* {DocumentInitParameters}, which are needed in the viewer.
*/
get loadingParams() {
return this._transport.loadingParams;
@ -2911,7 +2911,6 @@ class WorkerTransport {
const params = this._params;
return shadow(this, "loadingParams", {
disableAutoFetch: params.disableAutoFetch,
disableFontFace: params.disableFontFace,
});
}
}