Linux环境下"Font font = new Font("黑体", Font.BOLD, 18)"[BufferedImage~Graphics~drawS...

Linux环境下"Font font = new Font("黑体", Font.BOLD, 18)"[BufferedImage~Graphics~drawString]中文乱码,windows下不会乱码,但在linux下nginx和tomcat部署后出现乱码、方框、问号等等,不能认清楚!!!


先说说系统:

Microsoft Windows [版本 10.0.10586]
(c) 2015 Microsoft Corporation。保留所有权利。

----------------------------------------------------------------------

CentOS release 6.5 (Final)
Kernel \r on an \m

----------------------------------------------------tomcat 8.0.28

好了,说怎么解决的吧步骤:

1:查看CentOS下”/usr/share/fonts“目录,查看新的系统则为空目录;无目录可手动创建fonts。

2:打开”C:\Windows\WinSxS\amd64_microsoft-windows-font-truetype-simsunb_31bf3856ad364e35_10.0.10586.0_none_1d80224ec6470747“等目录下,找到自己需要的字体的目录,那个文件夹也是见名知意了;

3:之后把挑选的字体,可以建个文件夹,一次传到Xftp等上传到服务器的”/usr/share/fonts“的目录下;

4:进入"cd /usr/share/fonts/windowsFonts"文件夹,注:windowsFonts为我挑选字体目录:

有楷体,黑体,简宋体,微软雅黑等,最后附上!

5:最后在此目录下,执行"#fc-cache -fv",扫描字体目录并生成字体信息的缓存,然后应用程序就可以"立即"使用这些新安装的字体;

6:最终还是要重启tomcat了,字体生效!

执行命令 fc-cache -fv:

[root@timespacexstar windowsFonts]# fc-cache -fv
/usr/share/fonts: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/windowsFonts: caching, new cache contents: 8 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/.fonts: skipping, no such directory
/var/cache/fontconfig: cleaning cache directory
/root/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded

root@iZ234iuy39uZ:/usr/share/fonts/windowsFonts# fc-cache -fv
/usr/share/fonts: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 6 fonts, 0 dirs
/usr/share/fonts/windowsFonts: caching, new cache contents: 8 fonts, 0 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/root/.local/share/fonts: skipping, no such directory
/root/.fonts: skipping, no such directory
/usr/share/fonts: caching, new cache contents: 0 fonts, 2 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/root/.local/share/fonts: skipping, no such directory
/root/.fonts: skipping, no such directory
/var/cache/fontconfig: cleaning cache directory
/root/.cache/fontconfig: not cleaning non-existent cache directory
/root/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded

包涵字体:

[root@timespacexstar windowsFonts]# ll
total 77796
-rw-r--r-- 1 root root 16299048 Jan 31 17:43 msyhbd.ttc
-rw-r--r-- 1 root root 23608184 Jan 31 17:43 msyh.ttc
-rw-r--r-- 1 root root  9751720 Jan 31 17:45 simhei.ttf
-rw-r--r-- 1 root root 11785184 Jan 31 17:46 simkai.ttf
-rw-r--r-- 1 root root 18209004 Jan 31 17:47 simsun.ttc

windowsFonts字体

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值