From 02afd7187d0b33ba19fc3c71812bb3215ff97d64 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Thu, 9 Nov 2023 15:06:51 +0100 Subject: [PATCH] fix: apply `useSystemFonts: true` by default --- src/image.ts | 4 +++- src/pdfjs-serverless/rollup/plugins.ts | 2 +- src/utils.ts | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/image.ts b/src/image.ts index 6af8f04..9d072e7 100644 --- a/src/image.ts +++ b/src/image.ts @@ -107,7 +107,9 @@ async function createIsomorphicCanvasFactory( canvas.width = width; canvas.height = height; return canvas; - } else if (isNode) { + } + + if (isNode) { if (!_canvas) { throw new Error('Failed to resolve "canvas" package.'); } diff --git a/src/pdfjs-serverless/rollup/plugins.ts b/src/pdfjs-serverless/rollup/plugins.ts index 374e50b..646350c 100644 --- a/src/pdfjs-serverless/rollup/plugins.ts +++ b/src/pdfjs-serverless/rollup/plugins.ts @@ -3,7 +3,7 @@ import type { Plugin } from "rollup"; export function pdfjsTypes(): Plugin { return { - name: "pdfjs:types", + name: "pdfjs-serverless:types", async writeBundle() { const data = ` import * as PDFJS from './types/src/pdf' diff --git a/src/utils.ts b/src/utils.ts index 3513b94..cc39e19 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -15,6 +15,7 @@ export const isBrowser = typeof window !== "undefined"; * * Applies the following defaults: * - `isEvalSupported: false` + * - `useSystemFonts: true` */ export async function getDocumentProxy( data: BinaryData, @@ -24,6 +25,8 @@ export async function getDocumentProxy( const pdf = await getDocument({ data, isEvalSupported: false, + // See: https://github.com/mozilla/pdf.js/issues/4244#issuecomment-1479534301 + useSystemFonts: true, ...options, }).promise;