Skip to content

fix: cover CJK transcripts instead of rendering tofu - #11

Open
natyang1234 wants to merge 1 commit into
veedstudio:mainfrom
natyang1234:fix/cjk-font-coverage
Open

fix: cover CJK transcripts instead of rendering tofu#11
natyang1234 wants to merge 1 commit into
veedstudio:mainfrom
natyang1234:fix/cjk-font-coverage

Conversation

@natyang1234

Copy link
Copy Markdown

The defect

Every library recipe declares a Latin webfont stack (Archivo, Playfair Display, …) with Latin system tails, and the engine resolves only the webfonts it fetches — there is no per-glyph system-font fallback. A Chinese, Japanese or Korean transcript therefore renders as tofu boxes on every caption, and probe-qa cannot tell: tofu has ink and contrast.

Found on the first real Chinese video this pipeline was given — a zh-TW birthday clip through the custom whisper provider (mlx-whisper JSON). Every caption drew as empty rectangles while lint, --verify and probe-qa all reported clean.

The fix

generate-recipe.ts now runs a deterministic font-coverage pass inside the one writer of the final document (pipeline/scripts/ensure-font-coverage.ts):

  • when the transcript contains CJK and the document's font stacks name no covering family, the matching Noto family (TC / JP / KR by script; Han without kana or hangul defaults to Traditional) is added to the existing Google Fonts css2 request and appended to each font-family list ahead of the generic keyword — the recipe's webfonts keep styling Latin, the Noto face catches only the glyphs they lack;
  • a Latin transcript, or a recipe that already names a covering family (Noto CJK / PingFang / Hiragino / Source Han / …), passes through byte-identical, keeping recipe runs deterministic for the content they were authored against;
  • no library recipe is edited.

Verification

  • Same run (hook-107-peak, zh-TW transcript): tofu before, correct Traditional Chinese after; lint + --verify + probe-qa clean (0 warn).
  • Unit tests (node --import tsx --test tests/ensure-font-coverage.test.ts, 8 passing) cover script detection, css2 URL extension, stack placement before the generic keyword, the serif/sans split, already-covered pass-through, no-link documents, and the Latin byte-identical guarantee.

Notes for reviewers

  • The TC default for bare Han is undecidable from codepoints; a recipe (or operator --module copy) that names its own CJK family always wins, so an SC-preferring deployment can override per recipe.
  • A longer-term companion would be a probe-qa tofu check (e.g. glyph-coverage assert at lint time); happy to attempt that separately if wanted.

🤖 Generated with Claude Code

Every library recipe declares a Latin webfont stack (Archivo, Playfair,
...) with Latin system tails, and the engine resolves only the webfonts
it fetches - there is no per-glyph system-font fallback. A Chinese,
Japanese or Korean transcript therefore renders as tofu boxes on every
caption, and probe-qa cannot tell: tofu has ink and contrast.

Found on the first real Chinese video this pipeline was given (a
zh-TW birthday clip through the custom whisper provider): every caption
drew as empty rectangles while all gates reported clean.

generate-recipe now runs a deterministic font-coverage pass inside the
one writer of the final document. When the transcript contains CJK and
the document's font stacks name no covering family, the matching Noto
family (TC / JP / KR by script; Han without kana or hangul defaults to
Traditional) is added to the existing Google Fonts css2 request and
appended to each font-family list ahead of the generic keyword - so the
recipe's webfonts keep styling Latin and the Noto face catches only the
glyphs they lack. A Latin transcript, or a recipe that already names a
covering family, passes through byte-identical, keeping recipe runs
deterministic for the content they were authored against.

Verified end to end: the same run renders tofu before and correct
Traditional Chinese after, with lint and probe-qa clean; unit tests
cover script detection, URL extension, stack placement, the serif/sans
split, and the byte-identical pass-throughs.

Run: node --import tsx --test tests/ensure-font-coverage.test.ts
@natyang1234
natyang1234 requested a review from a team as a code owner August 8, 2026 06:55

@jakubtyrcha jakubtyrcha left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. We plan to address fallback fonts in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants