Add CJK fonts, fontconfig priority, and locale commands
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
Executable
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# omarchy:summary=Install CJK fonts and the OmarchyCN fontconfig priority
|
||||||
|
# omarchy:examples=omarchycn font apply
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
omarchy-pkg-add noto-fonts-cjk noto-fonts-emoji
|
||||||
|
|
||||||
|
conf_dir="$HOME/.config/fontconfig/conf.d"
|
||||||
|
mkdir -p "$conf_dir"
|
||||||
|
cp "$OMARCHY_PATH/cn/fontconfig/64-omarchycn-cjk.conf" "$conf_dir/"
|
||||||
|
fc-cache -f > /dev/null
|
||||||
|
|
||||||
|
echo "CJK fonts installed, fontconfig priority applied ($conf_dir/64-omarchycn-cjk.conf)"
|
||||||
|
omarchy-cn-font-status
|
||||||
Executable
+27
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# omarchy:summary=Check Chinese font availability and fallback correctness
|
||||||
|
# omarchy:examples=omarchycn font status
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
failures=0
|
||||||
|
|
||||||
|
for family in "Noto Sans CJK SC" "Noto Serif CJK SC" "Noto Sans Mono CJK SC"; do
|
||||||
|
matched=$(fc-match --format '%{family}' "$family")
|
||||||
|
if [[ $matched == *"$family"* ]]; then
|
||||||
|
echo "PASS font: $family"
|
||||||
|
else
|
||||||
|
echo "FAIL font: $family missing (got: $matched)"
|
||||||
|
failures=$((failures + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
zh_sans=$(fc-match --format '%{family}' sans-serif:lang=zh-cn)
|
||||||
|
if [[ $zh_sans == *"CJK SC"* ]]; then
|
||||||
|
echo "PASS fallback: zh-cn sans-serif -> $zh_sans"
|
||||||
|
else
|
||||||
|
echo "FAIL fallback: zh-cn sans-serif -> $zh_sans (expected SC variant)"
|
||||||
|
failures=$((failures + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $((failures > 0 ? 1 : 0))
|
||||||
Executable
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# omarchy:summary=Generate zh_CN.UTF-8 and en_US.UTF-8 locales
|
||||||
|
# omarchy:examples=omarchycn locale apply
|
||||||
|
# omarchy:requires-sudo=true
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
for loc in "zh_CN.UTF-8 UTF-8" "en_US.UTF-8 UTF-8"; do
|
||||||
|
if ! grep -qE "^${loc% *}" /etc/locale.gen; then
|
||||||
|
echo "$loc" | sudo tee -a /etc/locale.gen > /dev/null
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
sudo locale-gen
|
||||||
|
echo "Locales available: $(locale -a | grep -cE 'zh_CN|en_US') (zh_CN/en_US variants)"
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||||
|
<fontconfig>
|
||||||
|
<!-- 中文优先落到简体中文字形,避免 fallback 到日文变体 -->
|
||||||
|
<match target="pattern">
|
||||||
|
<test name="lang" compare="contains"><string>zh-cn</string></test>
|
||||||
|
<test name="family"><string>sans-serif</string></test>
|
||||||
|
<edit name="family" mode="prepend" binding="strong"><string>Noto Sans CJK SC</string></edit>
|
||||||
|
</match>
|
||||||
|
<match target="pattern">
|
||||||
|
<test name="lang" compare="contains"><string>zh-cn</string></test>
|
||||||
|
<test name="family"><string>serif</string></test>
|
||||||
|
<edit name="family" mode="prepend" binding="strong"><string>Noto Serif CJK SC</string></edit>
|
||||||
|
</match>
|
||||||
|
<match target="pattern">
|
||||||
|
<test name="lang" compare="contains"><string>zh-cn</string></test>
|
||||||
|
<test name="family"><string>monospace</string></test>
|
||||||
|
<edit name="family" mode="prepend" binding="strong"><string>Noto Sans Mono CJK SC</string></edit>
|
||||||
|
</match>
|
||||||
|
<alias>
|
||||||
|
<family>sans-serif</family>
|
||||||
|
<prefer>
|
||||||
|
<family>Noto Sans</family>
|
||||||
|
<family>Noto Sans CJK SC</family>
|
||||||
|
<family>Noto Color Emoji</family>
|
||||||
|
</prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>serif</family>
|
||||||
|
<prefer>
|
||||||
|
<family>Noto Serif</family>
|
||||||
|
<family>Noto Serif CJK SC</family>
|
||||||
|
<family>Noto Color Emoji</family>
|
||||||
|
</prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>monospace</family>
|
||||||
|
<prefer>
|
||||||
|
<family>Noto Sans Mono CJK SC</family>
|
||||||
|
<family>Noto Color Emoji</family>
|
||||||
|
</prefer>
|
||||||
|
</alias>
|
||||||
|
</fontconfig>
|
||||||
Reference in New Issue
Block a user