From 843769bf774a3a8838d8af849dc32d4b2fb26422 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, 24 Aug 2026 19:25:53 -0400 Subject: [PATCH] Add CJK fonts, fontconfig priority, and locale commands Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp --- bin/omarchy-cn-font-apply | 15 ++++++++++ bin/omarchy-cn-font-status | 27 ++++++++++++++++++ bin/omarchy-cn-locale-apply | 15 ++++++++++ cn/fontconfig/64-omarchycn-cjk.conf | 43 +++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100755 bin/omarchy-cn-font-apply create mode 100755 bin/omarchy-cn-font-status create mode 100755 bin/omarchy-cn-locale-apply create mode 100644 cn/fontconfig/64-omarchycn-cjk.conf diff --git a/bin/omarchy-cn-font-apply b/bin/omarchy-cn-font-apply new file mode 100755 index 00000000..098b1b88 --- /dev/null +++ b/bin/omarchy-cn-font-apply @@ -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 diff --git a/bin/omarchy-cn-font-status b/bin/omarchy-cn-font-status new file mode 100755 index 00000000..e51a0c91 --- /dev/null +++ b/bin/omarchy-cn-font-status @@ -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)) diff --git a/bin/omarchy-cn-locale-apply b/bin/omarchy-cn-locale-apply new file mode 100755 index 00000000..b51d28f3 --- /dev/null +++ b/bin/omarchy-cn-locale-apply @@ -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)" diff --git a/cn/fontconfig/64-omarchycn-cjk.conf b/cn/fontconfig/64-omarchycn-cjk.conf new file mode 100644 index 00000000..195674fb --- /dev/null +++ b/cn/fontconfig/64-omarchycn-cjk.conf @@ -0,0 +1,43 @@ + + + + + + zh-cn + sans-serif + Noto Sans CJK SC + + + zh-cn + serif + Noto Serif CJK SC + + + zh-cn + monospace + Noto Sans Mono CJK SC + + + sans-serif + + Noto Sans + Noto Sans CJK SC + Noto Color Emoji + + + + serif + + Noto Serif + Noto Serif CJK SC + Noto Color Emoji + + + + monospace + + Noto Sans Mono CJK SC + Noto Color Emoji + + +