@pdfme/common 6.2.4-dev.6 → 6.2.4-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helper.d.ts CHANGED
@@ -2,6 +2,11 @@ import type { PDFDocument, PDFPage } from '@pdfme/pdf-lib';
2
2
  import { Template, Font, BasePdf, Plugins, BlankPdf, PdfBytes } from './types.js';
3
3
  export declare const cloneDeep: <T>(value: T) => T;
4
4
  export declare const getFallbackFontName: (font: Font) => string;
5
+ /**
6
+ * The built-in fallback font. Every call returns a new Font object around the same bytes, decoded
7
+ * once and kept for the life of the process: do not modify or transfer them (e.g. in a
8
+ * postMessage transfer list).
9
+ */
5
10
  export declare const getDefaultFont: () => Font;
6
11
  export declare const mm2pt: (mm: number) => number;
7
12
  export declare const pt2mm: (pt: number) => number;
package/dist/index.js CHANGED
@@ -373,10 +373,19 @@ var getFallbackFontName = (font) => {
373
373
  if (fallbackFontName === initial) throw Error(`[@pdfme/common] fallback flag is not found in font. true fallback flag must be only one.`);
374
374
  return fallbackFontName;
375
375
  };
376
- var getDefaultFont = () => ({ [DEFAULT_FONT_NAME]: {
377
- data: b64toUint8Array(DEFAULT_FONT_VALUE),
378
- fallback: true
379
- } });
376
+ var defaultFontData;
377
+ /**
378
+ * The built-in fallback font. Every call returns a new Font object around the same bytes, decoded
379
+ * once and kept for the life of the process: do not modify or transfer them (e.g. in a
380
+ * postMessage transfer list).
381
+ */
382
+ var getDefaultFont = () => {
383
+ if (!defaultFontData) defaultFontData = b64toUint8Array(DEFAULT_FONT_VALUE);
384
+ return { [DEFAULT_FONT_NAME]: {
385
+ data: defaultFontData,
386
+ fallback: true
387
+ } };
388
+ };
380
389
  var mm2pt = (mm) => {
381
390
  return parseFloat(String(mm)) * MM_TO_PT_RATIO;
382
391
  };