Skip to content

Commit 774a538

Browse files
committed
feat(FR-2719): use language-appropriate Noto CJK font for PDF body
The previous CI build of the Korean PDF embedded WenQuanYiZenHei (a Chinese fontconfig fallback) for the body text instead of a proper Korean font. The cause was a two-part gap: 1. The release workflow installed only the single-face fonts pdf-lib needs for header/footer stamping (fonts-nanum / fonts-takao-gothic / fonts-thai-tlwg). Chromium's HTML rendering needs a different set of fonts that match what the CSS font-family list requests. 2. The CSS in styles.ts and styles-web.ts requested 'Noto Sans KR/JP' only, never 'Noto Sans CJK KR/JP/TC'. fonts-noto-cjk on Ubuntu only registers the latter family names, so even with the package installed Chromium would fall through to fontconfig's sans-serif default (WenQuanYiZenHei). Fixes: - workflow: add fonts-noto-cjk to the apt install list and run fc-cache so Chromium picks the proper CJK face when rendering HTML. - styles.ts: extend the body font-family with 'Noto Sans CJK KR/JP/TC'. Add :lang(ja) and :lang(th) overrides so the per-language <html lang> attribute selects the language-appropriate Noto CJK face (the KR/JP/TC faces differ in kanji/hanja glyph style) instead of always falling back to the Korean face. - styles-web.ts: same family extension so the docs website matches. Verified locally with pdffonts on a freshly rebuilt v26.4.7 set: ko → NotoSansCJKkr-Regular/Bold (was WenQuanYiZenHei) ja → NotoSansCJKjp-Regular/Bold (was NotoSansCJKkr fallback) th → Loma + Loma-Bold + Loma-Oblique (was WenQuanYiZenHei + partial Loma) en → NotoSansCJKkr (Latin coverage) The v26.4.7 release assets have been re-uploaded with the corrected build via `gh release upload --clobber`.
1 parent 2f17a09 commit 774a538

3 files changed

Lines changed: 43 additions & 10 deletions

File tree

.github/workflows/package.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,30 @@ jobs:
259259
- name: Install Playwright Chromium
260260
run: pnpm --filter backend.ai-webui-docs exec playwright install --with-deps chromium
261261

262-
# Install single-face CJK + Thai fonts. Ubuntu's `fonts-noto-cjk`
263-
# ships only a TTC bundle that pdf-lib/fontkit cannot embed, so we
264-
# use language-specific single-file packages whose paths are listed
265-
# in DEFAULT_CJK_FONT_CANDIDATES (pdf-renderer.ts):
266-
# - fonts-nanum → /usr/share/fonts/truetype/nanum/NanumBarunGothic.ttf (ko)
267-
# - fonts-takao-gothic → /usr/share/fonts/truetype/takao-gothic/TakaoGothic.ttf (ja)
268-
# - fonts-thai-tlwg → /usr/share/fonts/opentype/tlwg/Loma.otf or Garuda.ttf (th)
269-
# Languages whose font is missing will be reported as a failure by
262+
# PDF rendering uses two distinct font paths that need different fonts:
263+
#
264+
# 1. Body text — rendered by Chromium from HTML. Resolves the CSS
265+
# font-family (see styles.ts) via fontconfig, so it understands
266+
# .ttc collections. `fonts-noto-cjk` provides "Noto Sans CJK KR/JP/TC"
267+
# which the CSS lists as the canonical CJK body font.
268+
#
269+
# 2. Header/footer — stamped post-render by pdf-lib, which cannot embed
270+
# .ttc collections. So we additionally install language-specific
271+
# single-face packages whose paths are listed in
272+
# DEFAULT_CJK_FONT_CANDIDATES (pdf-renderer.ts):
273+
# - fonts-nanum → /usr/share/fonts/truetype/nanum/NanumBarunGothic.ttf (ko)
274+
# - fonts-takao-gothic → /usr/share/fonts/truetype/takao-gothic/TakaoGothic.ttf (ja)
275+
# - fonts-thai-tlwg → /usr/share/fonts/opentype/tlwg/Loma.otf | Garuda.ttf (th)
276+
#
277+
# Languages whose pdf-lib font is missing will be reported as a failure by
270278
# generate-pdf.ts but will not abort the other language renders.
271279
- name: Install CJK + Thai fonts (best effort)
272280
run: |
273281
sudo apt-get update
274282
sudo apt-get install -y --no-install-recommends \
283+
fonts-noto-cjk \
275284
fonts-nanum fonts-takao-gothic fonts-thai-tlwg || true
285+
fc-cache -f || true
276286
277287
# generate-pdf.ts continues past per-language failures and exits
278288
# non-zero only if *every* requested language failed. Combined with

packages/backend.ai-docs-toolkit/src/styles-web.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export function generateWebStyles(lang?: string): string {
5050
--ifm-color-emphasis-1000: #000;
5151
5252
--ifm-font-family-base: system-ui, -apple-system, "Segoe UI", Roboto,
53-
Ubuntu, Cantarell, "Noto Sans", "Noto Sans KR", "Noto Sans JP", "Noto Sans Thai",
53+
Ubuntu, Cantarell, "Noto Sans",
54+
"Noto Sans KR", "Noto Sans CJK KR",
55+
"Noto Sans JP", "Noto Sans CJK JP",
56+
"Noto Sans TC", "Noto Sans CJK TC",
57+
"Noto Sans Thai",
5458
sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
5559
--ifm-font-family-monospace: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
5660

packages/backend.ai-docs-toolkit/src/styles.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,26 @@ export function generatePdfStyles(theme: PdfTheme, lang?: string): string {
2020
2121
body {
2222
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
23-
"Noto Sans KR", "Noto Sans JP", "Noto Sans Thai",
23+
"Noto Sans KR", "Noto Sans CJK KR",
24+
"Noto Sans JP", "Noto Sans CJK JP",
25+
"Noto Sans TC", "Noto Sans CJK TC",
26+
"Noto Sans Thai",
27+
Helvetica, Arial, sans-serif;
28+
}
29+
30+
/* Per-language font priorities so Chromium picks the language-appropriate
31+
* Noto CJK face first (KR/JP/TC differ in kanji/hanja glyph style). The
32+
* <html lang="..."> attribute is set by html-builder.ts. */
33+
:lang(ja) {
34+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
35+
"Noto Sans JP", "Noto Sans CJK JP",
36+
"Noto Sans KR", "Noto Sans CJK KR",
37+
Helvetica, Arial, sans-serif;
38+
}
39+
40+
:lang(th) {
41+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
42+
"Noto Sans Thai", "Loma", "Garuda",
2443
Helvetica, Arial, sans-serif;
2544
font-size: ${theme.baseFontSize};
2645
line-height: 1.6;

0 commit comments

Comments
 (0)