前言
檢查系統已有的字型:
fc-list
如果沒有這個指令,那不僅沒有中文字型,連字型庫都沒有,那麼接下來就記錄一下在Linux中如何安裝字型庫以及中文字型。
1. 安裝字型庫
開始使用fontconfig來安裝字型庫,指令如下:
yum -y install fontconfig
2. 添加中文字型
- 在/usr/shared/fonts目錄下建立一個目錄chinese:
mkdir chinese
- 将準備好的字型上傳至/usr/shared/fonts/chinese目錄下即可:
https://share.weiyun.com/5xSgW63
- 修改chinese目錄的權限:
chmod -R 755 /usr/share/fonts/chinese
- 安裝ttmkfdir來搜尋目錄中所有的字型資訊,生成fonts.scale檔案:
yum -y install ttmkfdir
- 執行ttmkfdir指令:
ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
- 修改字型配置檔案:
vim /etc/fonts/fonts.conf
可以看到一個Font list(字型清單),把我們添加的中文字型位置加進去,輸入:wq儲存退出:

- 重新整理記憶體中的字型緩存:
fc-cache
- The End