@softwear/latestcollectioncore 1.0.192 → 1.0.194
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/reports.d.ts +2 -0
- package/dist/reports.js +2 -1
- package/package.json +3 -3
- package/src/reports.ts +4 -1
package/dist/reports.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface GenPdfOptions {
|
|
|
32
32
|
resolveLogoUrl?: () => string | undefined;
|
|
33
33
|
isCustomPdfFont?: (fontFamily: string) => boolean;
|
|
34
34
|
getPdfFontDefinition?: (fontFamily: string) => PdfFontDefinition | undefined;
|
|
35
|
+
/** Load TTF bytes as base64 (e.g. from disk in Node). Default: fetch variant.url. */
|
|
36
|
+
loadFont?: (url: string) => Promise<string>;
|
|
35
37
|
loadImage?: (url: string) => Promise<PdfImageAsset | undefined>;
|
|
36
38
|
}
|
|
37
39
|
export declare function genPDF(layout: Layout, printBuffer: any, options?: GenPdfOptions): Promise<jsPDF>;
|
package/dist/reports.js
CHANGED
|
@@ -246,9 +246,10 @@ function embedFontsInDoc(doc, usedFontFamilies, options) {
|
|
|
246
246
|
if (def.variants.length === 0) {
|
|
247
247
|
continue;
|
|
248
248
|
}
|
|
249
|
+
const loadFont = options.loadFont || fetchFontAsBase64;
|
|
249
250
|
for (const variant of def.variants) {
|
|
250
251
|
const vfsName = `${family}-${variant.style}.ttf`;
|
|
251
|
-
const base64 = yield
|
|
252
|
+
const base64 = yield loadFont(variant.url);
|
|
252
253
|
doc.addFileToVFS(vfsName, base64);
|
|
253
254
|
doc.addFont(vfsName, family, variant.style, 'Identity-H');
|
|
254
255
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softwear/latestcollectioncore",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.194",
|
|
4
4
|
"description": "Core functions for LatestCollections applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsc -p tsconfig.json",
|
|
19
19
|
"build:watch": "tsc -p tsconfig.json --watch",
|
|
20
|
-
"test": "vitest run",
|
|
21
|
-
"test:watch": "vitest"
|
|
20
|
+
"test": "TZ=Europe/Amsterdam vitest run",
|
|
21
|
+
"test:watch": "TZ=Europe/Amsterdam vitest"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
package/src/reports.ts
CHANGED
|
@@ -42,6 +42,8 @@ export interface GenPdfOptions {
|
|
|
42
42
|
resolveLogoUrl?: () => string | undefined
|
|
43
43
|
isCustomPdfFont?: (fontFamily: string) => boolean
|
|
44
44
|
getPdfFontDefinition?: (fontFamily: string) => PdfFontDefinition | undefined
|
|
45
|
+
/** Load TTF bytes as base64 (e.g. from disk in Node). Default: fetch variant.url. */
|
|
46
|
+
loadFont?: (url: string) => Promise<string>
|
|
45
47
|
loadImage?: (url: string) => Promise<PdfImageAsset | undefined>
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -312,9 +314,10 @@ async function embedFontsInDoc(doc: jsPDF, usedFontFamilies: Set<string>, option
|
|
|
312
314
|
if (def.variants.length === 0) {
|
|
313
315
|
continue
|
|
314
316
|
}
|
|
317
|
+
const loadFont = options.loadFont || fetchFontAsBase64
|
|
315
318
|
for (const variant of def.variants) {
|
|
316
319
|
const vfsName = `${family}-${variant.style}.ttf`
|
|
317
|
-
const base64 = await
|
|
320
|
+
const base64 = await loadFont(variant.url)
|
|
318
321
|
doc.addFileToVFS(vfsName, base64)
|
|
319
322
|
doc.addFont(vfsName, family, variant.style, 'Identity-H')
|
|
320
323
|
}
|