AIGC标识 Arch Linux / KDE:用 Windows 字体补齐中文与界面字体

适用:Arch + KDE Plasma 6,机器上有 Windows(双系统)。
结果:网页、Office 文档、终端的中文都用微软雅黑/宋体,KDE 界面用微软雅黑 + Consolas,英文排版完全不受影响。

为什么要折腾

拷完 Windows 字体后(尤其顺手拷了日文字体),网页中文会变"怪异"。原因是 /etc/fonts/conf.d/65-nonlatin.conf 里 sans-serif 的优先顺序是:

MS Gothic  →  Microsoft YaHei  →  Microsoft JhengHei  →  WenQuanYi …

浏览器做逐字回退时只按字符集查询、不带 lang,所以只要系统里有 MS Gothic,中文就被它抢走(日式字形 + 点阵笔画)。

结论:只拷需要的字体,别整目录拷。下面 10 个文件刚好够用。

一、只拷 10 个文件(68 MB)

mkdir -p ~/.local/share/fonts/windows
W=$(ls -d /run/media/$USER/*/Windows | head -1)
for f in msyh.ttc msyhbd.ttc simsun.ttc simhei.ttf consola.ttf consolab.ttf \
         segoeui.ttf segoeuib.ttf calibri.ttf calibrib.ttf; do
  cp "$W/Fonts/$f" ~/.local/share/fonts/windows/
done
fc-cache -f
字体 用途
msyh.ttc / msyhbd.ttc 微软雅黑,中文界面与网页正文
simsun.ttc 宋体 / NSimSun,中文衬线
simhei.ttf 黑体,部分文档的兜底
consola.ttf / consolab.ttf Consolas,终端与代码
segoeui.ttf / segoeuib.ttf Segoe UI,GitHub 等站点 CSS 明确点名它
calibri.ttf / calibrib.ttf Calibri,Office 文档默认

不必拷 Arial / Times New Roman / Verdana:已装的 Liberation 系列与它们度量完全兼容,自动顶替。

二、等宽场景的中文

终端和代码块里中文会落到 NSimSun(点阵宋体,丑)。一条规则解决:

cat > ~/.config/fontconfig/fonts.conf <<'X'
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="family"><string>monospace</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Noto Sans Mono CJK SC</string>
    </edit>
  </match>
</fontconfig>
X
fc-cache -f

三、KDE 界面字体

kwriteconfig6 --file kdeglobals --group General --key font  "Microsoft YaHei,10,-1,5,50,0,0,0,0,0"
kwriteconfig6 --file kdeglobals --group General --key fixed "Consolas,10,-1,5,50,0,0,0,0,0"
systemctl --user restart plasma-plasmashell

格式:字体名,字号,-1,字重,倾斜,0,0,0,0,0(5 = 常规字重)。

四、验证

fc-match "Microsoft YaHei"              # msyh.ttc
fc-match "sans-serif:charset=4e2d"      # msyh.ttc   ← 网页中文走这条
fc-match "serif:charset=4e2d"           # simsun.ttc
fc-match "monospace:charset=4e2d"       # Noto Sans Mono CJK SC
fc-match "sans-serif"                   # NotoSans-Regular.ttf  ← 英文没被污染
fc-match "Arial"                        # LiberationSans(度量兼容替代)

直接看图验证:

google-chrome-stable --headless=new --no-sandbox --screenshot=/tmp/gh.png \
  "https://github.com/lastonesky/wx_assist"

五、回滚

rm -rf ~/.local/share/fonts/windows ~/.config/fontconfig/fonts.conf
fc-cache -f
kwriteconfig6 --file kdeglobals --group General --key font ""
systemctl --user restart plasma-plasmashell

备注

  • 字体目录只放上面 10 个即可;想让某个字体临时可用就从 Windows 拷进来再 fc-cache -f。
  • 日文字体(MS Gothic / Yu Gothic 等)不要和中文混装,否则中文会被日式字形抢走。确需日文就单独拷 msmincho.ttc 等,并接受中日字形共存的取舍。
  • 已打开的 KDE 应用需重启才换字体;Firefox / Chrome 有时需重启才重建字体缓存。
  • 没有 Windows 分区时:yay -S ttf-ms-fonts(微软核心网页字体,不含雅黑/宋体)。
posted @ 2026-11-02 20:32  Easy C#  阅读(22)  评论(0)    收藏  举报