
是Linux没有相应中文字体的原因。
以宋体为例
1、查看linux下是否有中文字体
[root@VM-0-8-centos console]# fc-list
2、创建存放字体的文件夹
[root@VM-0-8-centos console]# cd /usr/share/fonts/
[root@VM-0-8-centos fonts]# mkdir my_fonts
3、将Windows目录中的字体复制到上面创建的文件夹中
windows中的字体目录C:\Windows\Fonts
4、安装mkfontscale
[root@VM-0-8-centos fonts]# yum install mkfontscale
error: rpmdb: BDB0113 Thread/process 26965/140312765970496 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 - (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:
Error: rpmdb open failed
和我一样安装报错是查看一下解决办法
Linux-centos使用yum命令提示Error: rpmdb open failed的解决办法
[root@VM-0-8-centos rpm]# yum install mkfontscale
5、在字体文件中执行mkfontscale
[root@VM-0-8-centos rpm]# cd /usr/share/fonts/my_fonts
[root@VM-0-8-centos my_fonts]# mkfontscale
6、查看安装的中文字体
[root@VM-0-8-centos my_fonts]# fc-list :lang=zh
/usr/share/fonts/my_fonts/SIMSUN.TTC: SimSun,宋体:style=Regular,常规
/usr/share/fonts/my_fonts/SIMHEI.TTF: SimHei:style=Normal
/usr/share/fonts/my_fonts/SIMSUN.TTC: NSimSun,新宋体:style=Regular,常规
7、扫描字体目录并生成字体信息的缓存
[root@VM-0-8-centos my_fonts]# fc-cache -fv
/usr/share/fonts: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/dejavu: caching, new cache contents: 9 fonts, 0 dirs
/usr/share/fonts/my_fonts: caching, new cache contents: 3 fonts, 0 dirs
/usr/share/X11/fonts/Type1: skipping, no such directory
/usr/share/X11/fonts/TTF: skipping, no such directory
/usr/local/share/fonts: skipping, no such directory
/root/.local/share/fonts: skipping, no such directory
/root/.fonts: skipping, no such directory
/usr/share/fonts/dejavu: skipping, looped directory detected
/usr/share/fonts/my_fonts: skipping, looped directory detected
/usr/lib/fontconfig/cache: cleaning cache directory
/root/.cache/fontconfig: not cleaning non-existent cache directory
/root/.fontconfig: not cleaning non-existent cache directory
/usr/bin/fc-cache-64: succeeded
8、重启java项目就可以了
温馨提醒
如果还不行,可以将Windows中的字体文件复制到jdk中的字体目录试试。
jdk字体目录${JAVA_HOME}/jre/lib/fonts