Linux 圖形系統透過 XFS (X Font Server) 管理字體,**會自動更新 fonts.dir 覆蓋手工修改**。安裝中文字體前,**必須先停用 xfs 服務**。
# 圖形介面
setup → 服務 → 取消 xfs 隨系統啟動
# 或命令行 (Systemd 系統)
systemctl disable xfs
systemctl stop xfs
# SysVinit 系統
chkconfig xfs off
service xfs stop
cp simsun.ttf /usr/share/fonts/default/TrueType/cd /usr/share/fonts/default/TrueType; ttmkfdir > fonts.dirfonts.dir,在 simsun.ttf -misc-SimSun-medium-r-normal--0-0-0-0-p-0-ascii-0 後追加兩行編碼映射:
simsun.ttf -misc-SimSun-medium-r-normal--0-0-0-0-p-0-gb2312.1980-0
simsun.ttf -misc-SimSun-medium-r-normal--0-0-0-0-p-0-gbk-0
cp fonts.dir fonts.scale編輯 /etc/X11/XF86Config-4 (或 xorg.conf):
Section "Files"
# FontPath "unix/:7100" # 註解掉 xfs 網路字體路徑
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
FontPath "/usr/share/fonts/default/TrueType" # 新增 TrueType 字體路徑
EndSection
Section "Module"
...
Load "xtt" # 載入 TrueType 字體模組 (FreeType)
...
EndSection
SimSun現代發行版 (Fedora 20+、Ubuntu 14.04+、CentOS 7+) 採用 **Fontconfig** 取代 XFS:
# 1. 複製字體至系統/用戶目錄
cp simsun.ttf /usr/share/fonts/ # 系統級 (需 root)
# 或
mkdir -p ~/.local/share/fonts
cp simsun.ttf ~/.local/share/fonts/ # 用戶級
# 2. 重建快取
fc-cache -fv
# 3. 驗證
fc-list :lang=zh | grep -i simsun
fc-match sans:lang=zh
Fontconfig 自動掃描目錄、解析 TTF/OTF、按語言匹配,**無需手動編輯 fonts.dir、無需停用服務、無需改 X 配置**,極大簡化流程。
fc-list 可見、fc-cache 無錯誤、重啟應用程式/etc/fonts/conf.d/10-antialias.conf、10-hinting.confwqy-zenhei、noto-fonts-cjk 等開源完整字體Linux 高併發 Socket 調優全攻略:文件描述符、端口範圍、連接追蹤、內核參數與 I/O 模型五大維度優化
Nginx SSL/TLS 設定指南:達到 Qualys SSL Labs A+ 評級
修改 Linux 預設開機執行等級:進入文字模式(Runlevel 3)
Linux 版本查看全攻略:lsb_release、/etc/os-release、uname、內核版本與發行版區別詳解
Linux 系統下 Apache Thrift 安裝全流程指南
Windows 與 Linux 動態函式庫深度解析:DLL 與 SO 移植實戰指南