From ab028e80ebfa91ee7f4c6d2939b966838a2f187b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Mon, 5 Oct 2026 23:48:00 -0400 Subject: [PATCH] Keep Latin families first and read only the tagged language for CJK variants --- default/fontconfig/conf.avail/50-omarchy.conf | 103 ++++++++---------- plans/omarchycn.md | 2 +- test/shell.d/fontconfig-cjk-test.sh | 70 ++++++++++++ 3 files changed, 115 insertions(+), 60 deletions(-) create mode 100755 test/shell.d/fontconfig-cjk-test.sh diff --git a/default/fontconfig/conf.avail/50-omarchy.conf b/default/fontconfig/conf.avail/50-omarchy.conf index 11a37324..31f4bb37 100644 --- a/default/fontconfig/conf.avail/50-omarchy.conf +++ b/default/fontconfig/conf.avail/50-omarchy.conf @@ -1,20 +1,10 @@ - + - + zh @@ -23,7 +13,7 @@ - + zh-hant @@ -32,7 +22,7 @@ - + zh-hant-hk @@ -41,7 +31,7 @@ - + zh-hant-mo @@ -50,7 +40,7 @@ - + zh-hant @@ -59,7 +49,7 @@ - + zh-hans @@ -68,7 +58,7 @@ - + zh-sg @@ -77,7 +67,7 @@ - + zh-mo @@ -86,7 +76,7 @@ - + yue @@ -95,7 +85,7 @@ - + yue-hans @@ -104,7 +94,7 @@ - + yue-cn @@ -113,7 +103,7 @@ - + yue @@ -121,189 +111,184 @@ - - + - + zh-cn sans-serif - + Noto Sans CJK SC - + zh-cn serif - + Noto Serif CJK SC - + zh-cn monospace - + Noto Sans Mono CJK SC - + zh-hk sans-serif - + Noto Sans CJK HK - + zh-hk serif - + Noto Serif CJK HK - + zh-hk monospace - + Noto Sans Mono CJK HK - + zh-tw sans-serif - + Noto Sans CJK TC - + zh-tw serif - + Noto Serif CJK TC - + zh-tw monospace - + Noto Sans Mono CJK TC - + ja sans-serif - + Noto Sans CJK JP - + ja serif - + Noto Serif CJK JP - + ja monospace - + Noto Sans Mono CJK JP - + ko sans-serif - + Noto Sans CJK KR - + ko serif - + Noto Serif CJK KR - + ko monospace - + Noto Sans Mono CJK KR diff --git a/plans/omarchycn.md b/plans/omarchycn.md index 90e6388e..bd5b7710 100644 --- a/plans/omarchycn.md +++ b/plans/omarchycn.md @@ -16,7 +16,7 @@ Progress source of truth for the `omarchycn` branches of `omarchy`, `omarchy-iso - [x] T0 Branches and this list - [x] T1 China package sources (PRD 1): region state, `omarchy-region` reader, `default/region/china/pacman.sed`, applied by `omarchy-refresh-pacman` and `install/post-install/pacman.sh`; tests - [x] T2 Region choice in the installer (PRD 2): `omarchy_prompt_region` in `setup-form.sh`, ISO configurator screen, orchestrator passes `OMARCHY_REGION`, `install/config/region.sh` records it -- [ ] T3 Input method (PRD 3): rime-ice-installer patch and PKGBUILD in omarchy-pkgs, IME packages in `omarchy-other.packages`, install-time package add, user step runs the installer from bundled assets, ISO build bundles assets and the package +- [x] T3 Input method (PRD 3): rime-ice-installer patch and PKGBUILD in omarchy-pkgs, IME packages in `omarchy-other.packages`, install-time package add, user step runs the installer from bundled assets, ISO build bundles assets and the package - [ ] T4 CJK fontconfig fix (PRD 4): rebuild PR 9693 on the current base - [ ] T5 AI (PRD 5): Dim and Kimi Code for every region (rebuild PR 9694), Claude Code third-party provider setup shown only in China - [ ] T6 Developer mirrors (PRD 6): npm, PyPI/uv, Go, rustup, crates.io, RubyGems, Maven via system drop-ins under `default/region/china/` diff --git a/test/shell.d/fontconfig-cjk-test.sh b/test/shell.d/fontconfig-cjk-test.sh new file mode 100755 index 00000000..493bd8dd --- /dev/null +++ b/test/shell.d/fontconfig-cjk-test.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +if ! command -v fc-match >/dev/null || [[ $(fc-list : file) != *NotoSansCJK-Regular.ttc* ]]; then + skip "fontconfig CJK variants need fc-match and noto-fonts-cjk" + exit 0 +fi + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +{ + echo '' + echo "/usr/share/fonts$test_tmp/cache" + for conf in /etc/fonts/conf.d/*.conf; do + if [[ ${conf##*/} == "50-omarchy.conf" ]]; then + echo "$ROOT/default/fontconfig/conf.avail/50-omarchy.conf" + else + echo "$conf" + fi + done + echo '' +} >"$test_tmp/fonts.conf" +export FONTCONFIG_FILE="$test_tmp/fonts.conf" +fc-cache >/dev/null + +declare -A latin=([sans-serif]="Liberation Sans" [serif]="Liberation Serif" [monospace]="JetBrainsMono Nerd Font") +declare -A cjk=([sans-serif]="Noto Sans CJK" [serif]="Noto Serif CJK" [monospace]="Noto Sans Mono CJK") +declare -A variant=( + [zh]=SC [zh-cn]=SC [zh-sg]=SC [zh-hans]=SC [zh-hans-cn]=SC [zh-hans-hk]=SC + [zh-tw]=TC [zh-hant]=TC [zh-hant-tw]=TC + [zh-hk]=HK [zh-mo]=HK [zh-hant-hk]=HK [zh-hant-mo]=HK + [yue]=HK [yue-hk]=HK [yue-hant]=HK [yue-hant-hk]=HK [yue-hant-cn]=HK + [yue-hans]=SC [yue-hans-cn]=SC [yue-hans-hk]=SC [yue-cn]=SC + [ja]=JP [ja-jp]=JP [ko]=KR [ko-kr]=KR +) + +family() { LANG=$1 fc-match -f '%{family[0]}' "$2"; } + +for locale in C.UTF-8 zh_CN.UTF-8; do + for tag in "${!variant[@]}"; do + for generic in sans-serif serif monospace; do + actual=$(family "$locale" "$generic:lang=$tag") + [[ $actual == "${latin[$generic]}" ]] || fail "$locale $generic:lang=$tag keeps Latin in ${latin[$generic]}" "$actual" + actual=$(family "$locale" "$generic:lang=$tag:charset=9aa8") + expected="${cjk[$generic]} ${variant[$tag]}" + [[ $actual == "$expected" ]] || fail "$locale $generic:lang=$tag sets Han in $expected" "$actual" + done + done + pass "$locale: tagged CJK keeps Omarchy's Latin families and sets Han in the tag's variant" +done + +for generic in sans-serif serif monospace; do + actual=$(family zh_CN.UTF-8 "$generic") + [[ $actual == "${latin[$generic]}" ]] || fail "zh_CN untagged $generic keeps ${latin[$generic]}" "$actual" + actual=$(family zh_CN.UTF-8 "$generic:charset=9aa8") + [[ $actual == "${cjk[$generic]} SC" ]] || fail "zh_CN untagged $generic sets Han in SC" "$actual" +done +pass "a Chinese locale keeps Omarchy's Latin families and sets untagged Han in SC" + +[[ $(LANG=C.UTF-8 fc-pattern --config "sans-serif:lang=ja" family) == *'"Noto Sans CJK JP"(s)'* ]] || + fail "lang=ja binds its variant strongly, so the prefix check below can see one" +for tag in jam kok; do + actual=$(LANG=C.UTF-8 fc-pattern --config "sans-serif:lang=$tag" family) + [[ ! $actual =~ CJK\ [A-Z]+\"\(s\) ]] || fail "lang=$tag is not taken for Japanese or Korean" "$actual" +done +pass "languages that only share a prefix with ja or ko get no CJK variant"