shaping: test that a CJK fallback follows the locale's language #96

Closed
opened 2026-10-11 07:17:59 +09:00 by natsukium · 0 comments
Owner

On Linux, felis takes its fallback faces from fontconfig's ranked list for the requested family. The motivating case is a Japanese locale: fontconfig prefers a Japanese CJK face there, while felis's old first-installed lists could pick a Simplified Chinese one. No test checks this, because the pinned test font set has no Simplified Chinese face.

What to add

  • Test font: a Simplified Chinese face in the pinned test font set (dev/flake-module.nix). The JP face there is already a pyftsubset of NotoSansCJK-VF.otf.ttc, so an SC subset from the same collection (--font-number=2) cut to the same ideograph is a few KB.
  • Language tags: a one-ideograph subset covers no orthography, so fontconfig derives no lang for it and the two faces tie (install order then puts JP first under zh-cn too). The test's rules must assign ja to the JP face and zh-cn to the SC face with <match target="scan">, standing in for the languages a full face's coverage yields.
  • Test: under a private FcConfig with lang set to ja, the fallback for an ideograph both faces cover is the JP face, and with zh-cn it is the SC face. The second assertion is what shows the order comes from the language, not from install order. Assert first that both faces load and cover the ideograph; do not assert the losing face stays in the cascade, since fallback_cascade drops a face that adds no coverage.

Scope

The test sets the language through the private config's explicit lang. The host path, where FcDefaultSubstitute takes the language from the environment, is not covered: changing the environment from parallel tests is unsafe, and that step is fontconfig's own.

On Linux, felis takes its fallback faces from fontconfig's ranked list for the requested family. The motivating case is a Japanese locale: fontconfig prefers a Japanese CJK face there, while felis's old first-installed lists could pick a Simplified Chinese one. No test checks this, because the pinned test font set has no Simplified Chinese face. ## What to add - **Test font:** a Simplified Chinese face in the pinned test font set (`dev/flake-module.nix`). The JP face there is already a `pyftsubset` of `NotoSansCJK-VF.otf.ttc`, so an SC subset from the same collection (`--font-number=2`) cut to the same ideograph is a few KB. - **Language tags:** a one-ideograph subset covers no orthography, so fontconfig derives no `lang` for it and the two faces tie (install order then puts JP first under `zh-cn` too). The test's rules must assign `ja` to the JP face and `zh-cn` to the SC face with `<match target="scan">`, standing in for the languages a full face's coverage yields. - **Test:** under a private `FcConfig` with `lang` set to `ja`, the fallback for an ideograph both faces cover is the JP face, and with `zh-cn` it is the SC face. The second assertion is what shows the order comes from the language, not from install order. Assert first that both faces load and cover the ideograph; do not assert the losing face stays in the cascade, since `fallback_cascade` drops a face that adds no coverage. ## Scope The test sets the language through the private config's explicit `lang`. The host path, where `FcDefaultSubstitute` takes the language from the environment, is not covered: changing the environment from parallel tests is unsafe, and that step is fontconfig's own.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
felis-terminal/felis#96
No description provided.