一般的linux机器是没有中文字库的,解决方案就是对linux机器安装中文字库
一、安装fontconfig
yum -y install fontconfig
这个命令执行完成之后,就可以在/usr/share文件夹里面看到fonts和fontconfig
二、添加中文字体库
从window的C:WindowsFonts里面把你需要的字体拷贝出来。比如simfang.ttf
在CentOS的/usr/share/fonts新建一个叫chinese的文件夹
然后把刚刚拷贝字体放到CentOS的/usr/share/fonts/chinese里面
修改chinese目录的权限:
chmod -R 775 /usr/share/fonts/chinese
接下来需要安装ttmkfdir来搜索目录中所有的字体信息,并汇总生成fonts.scale文件,输入命令
yum -y install ttmkfdir ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
修改字体配置文件
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>/usr/local/share/fonts/chinese</dir> <dir prefix="xdg">fonts</dir> <!-- the following element will be removed in the future --> <dir>~/.fonts</dir>
刷新内存中的字体缓存,fc-cache 看一下现在机器上已经有了刚才添加的字体。fc-list :lang=zh
现在再运行一下截图,就没问题啦~