Bundle Noto Sans (Regular/Bold/Italic/BoldItalic) under resources/static/fonts/ as the default PDF face — it covers Latin, Cyrillic, Greek, Arabic, Thai and Hindi out of the box, replacing the limited DejaVu Sans fallback. Move all @font-face declarations into app.pdf.partials.fonts and include it from every invoice/estimate/payment/report template, dropping per-template font-family hardcodes and the conditional Thai locale include.
Introduce FontService + FontController to download static Noto Sans CJK packages (zh, zh_CN, ja, ko) from life888888/cjk-fonts-ttf on demand. GeneratesPdfTrait::ensureFontsForLocale primes the family before rendering and the partial emits @font-face rules for installed packages so dompdf resolves them through standard CSS — no separate registerFont() instance required. Static TTFs are mandatory because dompdf's PHP-Font-Lib does not parse variable fonts (fvar/gvar tables), which is why Google Fonts' NotoSansTC[wght].ttf rendered empty boxes.
Expose status/install via /api/v1/fonts/status and /api/v1/fonts/{package}/install with matching FONTS_STATUS / FONTS_INSTALL constants in scripts-v2/api/endpoints.ts. Flip DOMPDF_ENABLE_REMOTE default to true for remote asset loading.
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
{{-- Bundled Noto Sans — covers Latin, Cyrillic, Greek, Arabic, Thai, Hindi, and most scripts --}}
|
|
<style type="text/css">
|
|
@font-face {
|
|
font-family: 'NotoSans';
|
|
font-style: normal;
|
|
font-weight: normal;
|
|
src: url("{{ resource_path('static/fonts/NotoSans-Regular.ttf') }}") format('truetype');
|
|
}
|
|
|
|
@font-face {
|
|
font-family: 'NotoSans';
|
|
font-style: normal;
|
|
font-weight: bold;
|
|
src: url("{{ resource_path('static/fonts/NotoSans-Bold.ttf') }}") format('truetype');
|
|
}
|
|
|
|
@font-face {
|
|
font-family: 'NotoSans';
|
|
font-style: italic;
|
|
font-weight: normal;
|
|
src: url("{{ resource_path('static/fonts/NotoSans-Italic.ttf') }}") format('truetype');
|
|
}
|
|
|
|
@font-face {
|
|
font-family: 'NotoSans';
|
|
font-style: italic;
|
|
font-weight: bold;
|
|
src: url("{{ resource_path('static/fonts/NotoSans-BoldItalic.ttf') }}") format('truetype');
|
|
}
|
|
|
|
{{-- On-demand CJK @font-face rules (only emitted for installed packages). --}}
|
|
{!! implode("\n", app(\App\Services\FontService::class)->getInstalledFontFaces()) !!}
|
|
|
|
body {
|
|
font-family: {!! app(\App\Services\FontService::class)->getFontFamilyChain() !!};
|
|
}
|
|
</style>
|