Install Chinese Fonts
Prefer system packages. They are smaller, easier to update, and more reliable than downloading huge upstream font archives.
Quick start
Use the bundled script for repeatable installs:
CODEBLOCK0
The script:
- - detects
dnf / yum / INLINECODE2 - installs a sane default CJK font set
- refreshes fontconfig with INLINECODE3
- verifies visible families with INLINECODE4
Recommended workflow
- 1. Check whether Chinese fonts already exist.
- Install distro-packaged CJK fonts.
- Refresh font cache.
- Verify that
fontconfig can see CJK families. - Only if packages are unavailable or a specific family/version is required, fall back to upstream downloads such as Source Han Sans / 思源黑体.
Package-manager defaults
RHEL / Rocky / Alma / Anolis / CentOS 8+
Prefer Noto CJK packages:
CODEBLOCK1
Debian / Ubuntu
Prefer:
CODEBLOCK2
Verification
Check whether Chinese fonts already exist:
CODEBLOCK3
Check the specific families after installation:
CODEBLOCK4
Fallback: upstream manual install
Only use manual downloads when:
- - the distro repo lacks the needed package
- a user explicitly asks for Source Han / 思源 family
- a specific upstream version is required
Recommended source:
- - Adobe Source Han Sans releases on GitHub
Prefer language-specific archives over giant all-in-one bundles unless the user explicitly needs the full family.
After extraction, copy font files into a system font directory such as:
Then refresh cache:
CODEBLOCK5
Notes
- - On headless Linux servers, installing fonts is often enough for Chrome, Playwright, PDF renderers, screenshots, and document export to display Chinese correctly.
- If an app still shows tofu boxes after installation, restart the app after
fc-cache -f. - For system-wide installs, expect root privileges or a privileged shell.
安装中文字体
优先使用系统软件包。它们比下载庞大的上游字体归档文件更小、更易更新、更可靠。
快速开始
使用捆绑脚本进行可重复安装:
bash
bash scripts/installchinesefonts.sh --dry-run
bash scripts/installchinesefonts.sh
bash scripts/installchinesefonts.sh --verify-only
该脚本:
- - 检测 dnf / yum / apt-get
- 安装一套合理默认的中日韩字体集
- 使用 fc-cache -f 刷新字体配置
- 使用 fc-list 验证可见字体族
推荐工作流程
- 1. 检查中文字体是否已存在。
- 安装发行版打包的中日韩字体。
- 刷新字体缓存。
- 验证 fontconfig 能否识别中日韩字体族。
- 仅当软件包不可用或需要特定字体族/版本时,才回退到上游下载,例如思源黑体。
包管理器默认配置
RHEL / Rocky / Alma / Anolis / CentOS 8+
优先使用 Noto 中日韩字体包:
bash
sudo dnf -y install \
google-noto-cjk-fonts \
google-noto-sans-cjk-ttc-fonts \
google-noto-serif-cjk-ttc-fonts
sudo fc-cache -f
fc-list | grep -Ei Noto Sans CJK|Noto Serif CJK|Source Han Sans|Source Han Serif | head -40
Debian / Ubuntu
优先使用:
bash
sudo apt-get update
sudo apt-get install -y fonts-noto-cjk
sudo fc-cache -f
fc-list | grep -Ei Noto Sans CJK|Noto Serif CJK|Source Han Sans|Source Han Serif | head -40
验证
检查中文字体是否已存在:
bash
fc-list :lang=zh family file | head -20
安装后检查特定字体族:
bash
fc-list | grep -Ei Noto Sans CJK|Noto Serif CJK|Source Han Sans|Source Han Serif | head -40
回退方案:上游手动安装
仅在以下情况下使用手动下载:
- - 发行版仓库缺少所需软件包
- 用户明确要求使用思源字体族
- 需要特定的上游版本
推荐来源:
- - GitHub 上的 Adobe 思源黑体发布版
优先使用特定语言的归档文件,而非庞大的全合一捆绑包,除非用户明确需要完整字体族。
解压后,将字体文件复制到系统字体目录,例如:
- - /usr/share/fonts/
- /usr/local/share/fonts/
然后刷新缓存:
bash
fc-cache -f
注意事项
- - 在无头 Linux 服务器上,安装字体通常足以让 Chrome、Playwright、PDF 渲染器、截图和文档导出正确显示中文。
- 如果安装后应用仍显示豆腐块,请在 fc-cache -f 后重启应用。
- 对于系统级安装,需要 root 权限或特权 shell。