koto's Site # 😜 Knowing me Search Posts Tags Dates Friends Settings

适用于 Noto Sans CJK VF 的 variants prefer fontconfig

适用于 Noto Sans CJK VF 的 variants prefer fontconfig, 或许其它 VF 也能参考。

2026-06-09 13:53:00 (UTC) 6 mins 16 s

Tagged with:

If every single character in this post looks like nothing but square boxes (or with a cross in it) to you, then you should either install a Chinese font or get yourself a Chinese language pack.

适用于 Noto Sans CJK VF 的 variants prefer fontconfig, 或许其它 Variable Font 也能参考。

本文是方便笨人在新系统上和 fontconfig xml 激烈地自由搏斗写的,所以写的比较放飞自我感情真挚,请务必小心 judge.

如果你还不知道这些 variants 到底有什么区别,恭喜你,你要么是系统语言是 CJK 其中任一,要么是维护者好心帮你写好了,要么就要考虑去验光和挂个眼科的号了。以防你的视力情况真的很迫不容缓或者你只是好奇,以下是快速对比表:

需要注意的是本站全局有跟随本地化的语言设定, 这可能会影响到字体的渲染。以防万一,我添加了 lang 指定为英文的行,用于测试 fallback 字形。

无衬线字体
不指定 lang:门上插刀,直字拐弯,天上平板,船顶漏雨。
英文 lang:门上插刀,直字拐弯,天上平板,船顶漏雨。
大陆简体:门上插刀,直字拐弯,天上平板,船顶漏雨。
香港繁体:门上插刀,直字拐弯,天上平板,船顶漏雨。
台湾繁体:门上插刀,直字拐弯,天上平板,船顶漏雨。
日本字形:门上插刀,直字拐弯,天上平板,船顶漏雨。
韩国字形:门上插刀,直字拐弯,天上平板,船顶漏雨。
衬线字体
不指定 lang:门上插刀,直字拐弯,天上平板,船顶漏雨。
英文 lang:门上插刀,直字拐弯,天上平板,船顶漏雨。
大陆简体:门上插刀,直字拐弯,天上平板,船顶漏雨。
香港繁体:门上插刀,直字拐弯,天上平板,船顶漏雨。
台湾繁体:门上插刀,直字拐弯,天上平板,船顶漏雨。
日本字形:门上插刀,直字拐弯,天上平板,船顶漏雨。
韩国字形:门上插刀,直字拐弯,天上平板,船顶漏雨。
等宽字体
不指定 lang:门上插刀,直字拐弯,天上平板,船顶漏雨。
英文 lang:门上插刀,直字拐弯,天上平板,船顶漏雨。
大陆简体:门上插刀,直字拐弯,天上平板,船顶漏雨。
香港繁体:门上插刀,直字拐弯,天上平板,船顶漏雨。
台湾繁体:门上插刀,直字拐弯,天上平板,船顶漏雨。
日本字形:门上插刀,直字拐弯,天上平板,船顶漏雨。
韩国字形:门上插刀,直字拐弯,天上平板,船顶漏雨。

部分看起来可能很像 🤓 的刁钻读者可能要问那 zh-sg 和 zh-my 去哪里了,很遗憾,那种东西并不存在(新加坡和马来西亚分别于 1976 年和 1981 年转为全面采用中国大陆的《简化字总表》,常见字形差异均来自于不同 Font 之使用。Noto Sans CJK 和其上游项目 Source Han Sans 思源黑体均不提供面向 SG 和 MY 的 variant)。

总之你应该能看到区别,如果没有发现区别请截图邀请你的视力 5.2 的朋友一起来看,如果还是没有的话应该是你之前就把 fontconfig 配糠了。

有需要的话,写入以下按道理应该位于 /etc/fonts/conf.d/ (system-wide) 或者 ~/.config/fontconfig/conf.d/ (user-wide) 的文件内容,同时按需调整 prefer 顺序和文件名 (最好是 9x- 开头,5x- 开头也可以,其他的话也不是不行,就是会让我看着感觉浑身上下都有巨蟹蛛在爬)。

/etc/fonts/conf.d/99-noto-cjk-prefer.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family" compare="contains">
<string>Noto Sans CJK </string>
</test>
<edit name="family" mode="prepend">
<string>Noto Sans CJK SC</string>
<string>Noto Sans CJK TC</string>
<string>Noto Sans CJK HK</string>
<string>Noto Sans CJK JP</string>
<string>Noto Sans CJK KR</string>
</edit>
</match>
<match target="pattern">
<test name="family" compare="contains">
<string>Noto Sans Mono CJK </string>
</test>
<edit name="family" mode="prepend">
<string>Noto Sans Mono CJK SC</string>
<string>Noto Sans Mono CJK TC</string>
<string>Noto Sans Mono CJK HK</string>
<string>Noto Sans Mono CJK JP</string>
<string>Noto Sans Mono CJK KR</string>
</edit>
</match>
<match target="pattern">
<test name="family" compare="contains">
<string>Noto Serif CJK </string>
</test>
<edit name="family" mode="prepend">
<string>Noto Serif CJK SC</string>
<string>Noto Serif CJK TC</string>
<string>Noto Serif CJK HK</string>
<string>Noto Serif CJK JP</string>
<string>Noto Serif CJK KR</string>
</edit>
</match>
</fontconfig>

可能需要也可能不需要运行的刷新 fontconfig 缓存的命令:

Terminal window
fc-cache -frv

可能需要也可能不需要运行的检查自由搏击比赛结果的命令:

Terminal window
fc-match -sa sans-serif | grep 'Noto Sans CJK'
fc-match -sa monospace | grep 'Noto Sans Mono CJK'
fc-match -sa serif | grep 'Noto Serif CJK'

如果你觉得结算画面太长了:

Terminal window
fc-match -sa sans-serif | grep 'Noto Sans CJK' | grep "Regular"
fc-match -sa monospace | grep 'Noto Sans Mono CJK' | grep "Regular"
fc-match -sa serif | grep 'Noto Serif CJK' | grep "Regular"
# 适用于 Noto Sans CJK VF 的 variants prefer fontconfig