JAVA畫圖時常用到Font 類對象這樣的對象依賴於本地的字段。新裝的linux沒有安裝字段庫,和相應的字體。
1、fc -list查看字體庫
發現沒有安裝
2、yum -y install fontconfig安裝
3、安裝好后/usr/share目錄下多兩個目錄fonts和fontconfig
4、首先在/usr/shared/fonts目錄下新建一個目錄chinese
5、到C:\Windows\Fonts目錄下上傳你需要的字體到/usr/shared/fonts/chinese目錄下
6、修改chinese權限
chmod -R 755 /usr/share/fonts/chinese
7、接下來需要安裝ttmkfdir來搜索目錄中所有的字體信息,並匯總生成fonts.scale文件,輸入命令:
yum -y install ttmkfdir
8、最后一步就是修改字體配置文件了,首先通過編輯器打開配置文件:
vi /etc/fonts/fonts.conf
<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/share/X11/fonts/Type1</dir> <dir>/usr/share/X11/fonts/TTF</dir> <dir>/usr/local/share/fonts</dir>
<dir prefix="xdg">fonts</dir>
<dir>/usr/share/fonts/chinese<dir>
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>
9、fc-cache刷新
運行sudo fc-cache -f -v
命令刷新字體緩存
10、fc-list可以看到剛剛的配置了