@fuentis/phoenix-ui 0.0.9-alpha.612 → 0.0.9-alpha.614
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.
|
@@ -2465,17 +2465,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
2465
2465
|
// DejaVu Sans font in base64 format for jsPDF
|
|
2466
2466
|
// This font has excellent support for Serbian characters (ć, č, đ, š, ž)
|
|
2467
2467
|
// Font source: https://github.com/dejavu-fonts/dejavu-fonts
|
|
2468
|
-
// Note: Full base64 string is very large, so we'll load it dynamically from CDN
|
|
2469
2468
|
const DEJAVU_SANS = '';
|
|
2470
|
-
|
|
2471
|
-
|
|
2469
|
+
const CDN_URL = 'https://cdn.jsdelivr.net/npm/dejavu-fonts-ttf@2.37.3/ttf/DejaVuSans.ttf';
|
|
2470
|
+
const LOCAL_PATH = '/assets/fonts/DejaVuSans.ttf';
|
|
2471
|
+
async function tryFetchFont(url) {
|
|
2472
2472
|
try {
|
|
2473
|
-
const response = await fetch(
|
|
2474
|
-
if (!response.ok)
|
|
2473
|
+
const response = await fetch(url);
|
|
2474
|
+
if (!response.ok)
|
|
2475
2475
|
return null;
|
|
2476
|
-
}
|
|
2477
2476
|
const arrayBuffer = await response.arrayBuffer();
|
|
2478
|
-
// Convert to base64 using chunking to avoid stack overflow
|
|
2479
2477
|
const bytes = new Uint8Array(arrayBuffer);
|
|
2480
2478
|
let binary = '';
|
|
2481
2479
|
const chunkSize = 8192;
|
|
@@ -2483,14 +2481,23 @@ async function loadDejaVuSansFont() {
|
|
|
2483
2481
|
const chunk = bytes.subarray(i, i + chunkSize);
|
|
2484
2482
|
binary += String.fromCharCode.apply(null, Array.from(chunk));
|
|
2485
2483
|
}
|
|
2486
|
-
|
|
2487
|
-
return base64;
|
|
2484
|
+
return btoa(binary);
|
|
2488
2485
|
}
|
|
2489
|
-
catch
|
|
2490
|
-
console.warn('Failed to load DejaVu Sans font from CDN:', error);
|
|
2486
|
+
catch {
|
|
2491
2487
|
return null;
|
|
2492
2488
|
}
|
|
2493
2489
|
}
|
|
2490
|
+
// Loads DejaVu Sans font. If url is provided, uses only that URL.
|
|
2491
|
+
// Otherwise tries LOCAL_PATH first, then CDN as fallback.
|
|
2492
|
+
async function loadDejaVuSansFont(url) {
|
|
2493
|
+
if (url)
|
|
2494
|
+
return tryFetchFont(url);
|
|
2495
|
+
const local = await tryFetchFont(LOCAL_PATH);
|
|
2496
|
+
if (local)
|
|
2497
|
+
return local;
|
|
2498
|
+
console.warn('DejaVu Sans not found at local path, falling back to CDN');
|
|
2499
|
+
return tryFetchFont(CDN_URL);
|
|
2500
|
+
}
|
|
2494
2501
|
|
|
2495
2502
|
/* ----------------------------- Helpers ----------------------------- */
|
|
2496
2503
|
/**
|
|
@@ -2661,8 +2668,10 @@ async function exportRowsToPdf(columns, rows, columnTypeMap, columnTypeEnum, t,
|
|
|
2661
2668
|
else {
|
|
2662
2669
|
pdfMake.vfs = pdfFonts || {};
|
|
2663
2670
|
}
|
|
2671
|
+
// vfs was just reset to Roboto-only; remove any stale font reference so vfs and fonts stay in sync
|
|
2672
|
+
delete pdfMake.fonts?.DejaVuSans;
|
|
2664
2673
|
try {
|
|
2665
|
-
const dejaVuFont = await loadDejaVuSansFont();
|
|
2674
|
+
const dejaVuFont = await loadDejaVuSansFont(options.fontUrl);
|
|
2666
2675
|
if (dejaVuFont) {
|
|
2667
2676
|
pdfMake.fonts ??= {};
|
|
2668
2677
|
pdfMake.fonts.DejaVuSans = {
|
|
@@ -3541,7 +3550,7 @@ class TableComponent {
|
|
|
3541
3550
|
const file = this.tableConfiguration?.key
|
|
3542
3551
|
? buildFileName(this.tableConfiguration.key, 'pdf')
|
|
3543
3552
|
: buildFileName('table', 'pdf');
|
|
3544
|
-
exportRowsToPdf(this.selectedColumns, this.tableData, this.columnTypeMap, this.columnTypeEnum, (k) => this.translateService.instant(k), file).catch((error) => {
|
|
3553
|
+
exportRowsToPdf(this.selectedColumns, this.tableData, this.columnTypeMap, this.columnTypeEnum, (k) => this.translateService.instant(k), file, { fontUrl: this.tableConfiguration?.pdfFontUrl }).catch((error) => {
|
|
3545
3554
|
console.error('Failed to export PDF:', error);
|
|
3546
3555
|
});
|
|
3547
3556
|
return;
|