@fuentis/phoenix-ui 0.0.9-alpha.611 → 0.0.9-alpha.613
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.
|
@@ -2462,6 +2462,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
2462
2462
|
}]
|
|
2463
2463
|
}], ctorParameters: () => [{ type: i1$2.DatePipe }] });
|
|
2464
2464
|
|
|
2465
|
+
// DejaVu Sans font in base64 format for jsPDF
|
|
2466
|
+
// This font has excellent support for Serbian characters (ć, č, đ, š, ž)
|
|
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
|
+
const DEJAVU_SANS = '';
|
|
2470
|
+
// Function to load DejaVu Sans font dynamically
|
|
2471
|
+
async function loadDejaVuSansFont() {
|
|
2472
|
+
try {
|
|
2473
|
+
const response = await fetch('https://cdn.jsdelivr.net/npm/dejavu-fonts-ttf@2.37.3/ttf/DejaVuSans.ttf');
|
|
2474
|
+
if (!response.ok) {
|
|
2475
|
+
return null;
|
|
2476
|
+
}
|
|
2477
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
2478
|
+
// Convert to base64 using chunking to avoid stack overflow
|
|
2479
|
+
const bytes = new Uint8Array(arrayBuffer);
|
|
2480
|
+
let binary = '';
|
|
2481
|
+
const chunkSize = 8192;
|
|
2482
|
+
for (let i = 0; i < bytes.length; i += chunkSize) {
|
|
2483
|
+
const chunk = bytes.subarray(i, i + chunkSize);
|
|
2484
|
+
binary += String.fromCharCode.apply(null, Array.from(chunk));
|
|
2485
|
+
}
|
|
2486
|
+
const base64 = btoa(binary);
|
|
2487
|
+
return base64;
|
|
2488
|
+
}
|
|
2489
|
+
catch (error) {
|
|
2490
|
+
console.warn('Failed to load DejaVu Sans font from CDN:', error);
|
|
2491
|
+
return null;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2465
2495
|
/* ----------------------------- Helpers ----------------------------- */
|
|
2466
2496
|
/**
|
|
2467
2497
|
* Safely retrieves nested object property using dot notation.
|
|
@@ -2499,8 +2529,9 @@ function sanitizeText(v) {
|
|
|
2499
2529
|
const s = (v ?? '').toString();
|
|
2500
2530
|
const noHtml = s.replace(/<[^>]*>/g, '');
|
|
2501
2531
|
// Remove emoji characters - they don't render properly in PDF
|
|
2502
|
-
//
|
|
2503
|
-
|
|
2532
|
+
// Note: U+2600–U+26FF (Miscellaneous Symbols, e.g. ♥ ★ ♠) and U+2700–U+27BF (Dingbats) are kept
|
|
2533
|
+
// because Noto Sans supports them and they are legitimate text symbols, not emoji.
|
|
2534
|
+
const emojiRegex = /[\u{1F300}-\u{1F9FF}\u{FE00}-\u{FE0F}\u{1F900}-\u{1F9FF}\u{1F1E0}-\u{1F1FF}]/gu;
|
|
2504
2535
|
const noEmoji = noHtml.replace(emojiRegex, '');
|
|
2505
2536
|
return noEmoji
|
|
2506
2537
|
.replace(/ /g, ' ')
|
|
@@ -2585,32 +2616,6 @@ function collapseInlineSpaces(s) {
|
|
|
2585
2616
|
.replace(/[^\S\r\n]+/g, ' ')
|
|
2586
2617
|
.trim();
|
|
2587
2618
|
}
|
|
2588
|
-
/**
|
|
2589
|
-
* Loads Noto Sans font from CDN for better emoji support
|
|
2590
|
-
*/
|
|
2591
|
-
async function loadNotoSansFont() {
|
|
2592
|
-
try {
|
|
2593
|
-
// Noto Sans has better Unicode and emoji support than Roboto
|
|
2594
|
-
// Try jsDelivr CDN first (more reliable)
|
|
2595
|
-
const response = await fetch('https://cdn.jsdelivr.net/gh/google/fonts@main/ofl/notosans/NotoSans-Regular.ttf');
|
|
2596
|
-
if (!response.ok) {
|
|
2597
|
-
return null;
|
|
2598
|
-
}
|
|
2599
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
2600
|
-
const bytes = new Uint8Array(arrayBuffer);
|
|
2601
|
-
let binary = '';
|
|
2602
|
-
const chunkSize = 8192;
|
|
2603
|
-
for (let i = 0; i < bytes.length; i += chunkSize) {
|
|
2604
|
-
const chunk = bytes.subarray(i, i + chunkSize);
|
|
2605
|
-
binary += String.fromCharCode.apply(null, Array.from(chunk));
|
|
2606
|
-
}
|
|
2607
|
-
return btoa(binary);
|
|
2608
|
-
}
|
|
2609
|
-
catch (error) {
|
|
2610
|
-
console.warn('Failed to load Noto Sans font from CDN:', error);
|
|
2611
|
-
return null;
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2614
2619
|
/**
|
|
2615
2620
|
* Exports table rows to a PDF file using pdfmake.
|
|
2616
2621
|
* - Uses pdfmake which has excellent Unicode support for Serbian characters (ć, č, đ, š, ž)
|
|
@@ -2656,22 +2661,23 @@ async function exportRowsToPdf(columns, rows, columnTypeMap, columnTypeEnum, t,
|
|
|
2656
2661
|
else {
|
|
2657
2662
|
pdfMake.vfs = pdfFonts || {};
|
|
2658
2663
|
}
|
|
2664
|
+
// vfs was just reset to Roboto-only; remove any stale font reference so vfs and fonts stay in sync
|
|
2665
|
+
delete pdfMake.fonts?.DejaVuSans;
|
|
2659
2666
|
try {
|
|
2660
|
-
const
|
|
2661
|
-
if (
|
|
2667
|
+
const dejaVuFont = await loadDejaVuSansFont();
|
|
2668
|
+
if (dejaVuFont) {
|
|
2662
2669
|
pdfMake.fonts ??= {};
|
|
2663
|
-
pdfMake.fonts.
|
|
2664
|
-
normal: '
|
|
2665
|
-
bold: '
|
|
2666
|
-
italics: '
|
|
2667
|
-
bolditalics: '
|
|
2670
|
+
pdfMake.fonts.DejaVuSans = {
|
|
2671
|
+
normal: 'DejaVuSans.ttf',
|
|
2672
|
+
bold: 'DejaVuSans.ttf',
|
|
2673
|
+
italics: 'DejaVuSans.ttf',
|
|
2674
|
+
bolditalics: 'DejaVuSans.ttf',
|
|
2668
2675
|
};
|
|
2669
|
-
pdfMake.vfs['
|
|
2670
|
-
pdfMake.vfs['NotoSans-Bold.ttf'] = notoSansFont;
|
|
2676
|
+
pdfMake.vfs['DejaVuSans.ttf'] = dejaVuFont;
|
|
2671
2677
|
}
|
|
2672
2678
|
}
|
|
2673
2679
|
catch {
|
|
2674
|
-
console.warn('
|
|
2680
|
+
console.warn('DejaVuSans not loaded, fallback to Roboto');
|
|
2675
2681
|
}
|
|
2676
2682
|
/* =========================
|
|
2677
2683
|
FIXED TABLE WIDTH LOGIC
|
|
@@ -2777,7 +2783,7 @@ async function exportRowsToPdf(columns, rows, columnTypeMap, columnTypeEnum, t,
|
|
|
2777
2783
|
},
|
|
2778
2784
|
},
|
|
2779
2785
|
defaultStyle: {
|
|
2780
|
-
font: pdfMake.fonts?.
|
|
2786
|
+
font: pdfMake.fonts?.DejaVuSans ? 'DejaVuSans' : 'Roboto',
|
|
2781
2787
|
},
|
|
2782
2788
|
};
|
|
2783
2789
|
pdfMake.createPdf(docDefinition).download(fileName);
|