1.查看自己的操作系统
加粗样式[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
2. 安装字体库
[root@localhost ~]# yum install fontconfig
Package fontconfig-2.13.0-4.3.el7.x86_64 already installed and latest version
Nothing to do
3.安装更新字体命令
[root@localhost ~]# mkfontscale
-bash: mkfontscale: command not found
如果该命令没有需要安装
[root@localhost ~]# yum install mkfontscale
[root@localhost ~]# mkfontscale
4.查看中文字体
[root@localhost ~]# fc-list :lang=zh
一般情况是没有的
5.新建目录
[root@localhost ~]# ls
anaconda-ks.cfg fonts.scale
jdk-8u333-linux-x64.tar.gz node-v14.13.1-linux-x64 node-v14.13.1-linux-x64.tar test
[root@localhost ~]# fc-list
可以看到很多字体但是没有中文
[root@localhost ~]# cd usr/share/fonts
-bash: cd: usr/share/fonts: No such file or directory
[root@localhost ~]# cd /usr/share/fonts
[root@localhost fonts]# ls
dejavu liberation
[root@localhost fonts]# mkdir chinese
[root@localhost fonts]# ls
chinese dejavu liberation
[root@localhost fonts]# ls
chinese dejavu liberation
[root@localhost fonts]# pwd
/usr/share/fonts
[root@localhost fonts]# cd chinese/
6.拷贝 fonts.scale 和windows上的字体到chinese文件夹中.将字体文件放在chinese目录
[root@localhost chinese]# cd ~
[root@localhost ~]# cp fonts.scale /usr/share/fonts/chinese/
7.授权,该目录及其下所有文件需要有执行权限
[root@localhost chinese]# sudo chmod -R 755 /usr/share/fonts/chinese
8.重新建立字体索引、更新缓存
cd /usr/share/fonts/Chinese
[root@localhost chinese]# mkfontscale
[root@localhost chinese]# mkfontdir
[root@localhost chinese]# fc-cache
[root@localhost chinese]#
9.查看字体是否安装成功,列出所有成功安装的字体
[root@localhost chinese]# fc-list :lang=zh
fc-list :lang=zh 注意冒号前有空格!
大功告成