Linux环境下中文字体乱码处理办法

项目中包含了一项生成JPG图片的功能,该功能需要使用JAVA的Graphics2D动态生成图片中的文字,原来在Windows平台中没有发现问题,但是迁移至Linux平台后发现生成的中文变成了乱码。

百度发现是因为Linux下没有相应的字体引起的,解决办法如下:

1、找到Windows平台下的字体文件;

    常规路径为:C:\Windows\Fonts

    宋体文件为:simsun.ttc

    楷体文件为:simkai.ttf

2、找到Linux平台下JDK的字体目录;

    本系统路径为:/opt/IBM/WebSphere/AppServer/java_1.7_64/jre/lib/fonts

    该路径下存储了默认的字体。

[root@appsrv01 fonts]# pwd
/opt/IBM/WebSphere/AppServer/java_1.7_64/jre/lib/fonts
[root@appsrv01 fonts]# 
[root@appsrv01 fonts]# ll
total 31460
-rwxr-xr-x 1 root root     4041 Mar 24  2014 fonts.dir
-rwxr-xr-x 1 root root    75144 Mar 24  2014 LucidaBrightDemiBold.ttf
-rwxr-xr-x 1 root root    75124 Mar 24  2014 LucidaBrightDemiItalic.ttf
-rwxr-xr-x 1 root root    80856 Mar 24  2014 LucidaBrightItalic.ttf
-rwxr-xr-x 1 root root   344908 Mar 24  2014 LucidaBrightRegular.ttf
-rwxr-xr-x 1 root root   317896 Mar 24  2014 LucidaSansDemiBold.ttf
-rwxr-xr-x 1 root root   698236 Mar 24  2014 LucidaSansRegular.ttf
-rwxr-xr-x 1 root root   234068 Mar 24  2014 LucidaTypewriterBold.ttf
-rwxr-xr-x 1 root root   242700 Mar 24  2014 LucidaTypewriterRegular.ttf

3、将需要的字体拷贝至此目录即可。

[root@appsrv01 fonts]# ll
total 31460
-rwxr-xr-x 1 root root     4041 Mar 24  2014 fonts.dir
-rwxr-xr-x 1 root root    75144 Mar 24  2014 LucidaBrightDemiBold.ttf
-rwxr-xr-x 1 root root    75124 Mar 24  2014 LucidaBrightDemiItalic.ttf
-rwxr-xr-x 1 root root    80856 Mar 24  2014 LucidaBrightItalic.ttf
-rwxr-xr-x 1 root root   344908 Mar 24  2014 LucidaBrightRegular.ttf
-rwxr-xr-x 1 root root   317896 Mar 24  2014 LucidaSansDemiBold.ttf
-rwxr-xr-x 1 root root   698236 Mar 24  2014 LucidaSansRegular.ttf
-rwxr-xr-x 1 root root   234068 Mar 24  2014 LucidaTypewriterBold.ttf
-rwxr-xr-x 1 root root   242700 Mar 24  2014 LucidaTypewriterRegular.ttf
-rwxrwxr-x 1 root root 11785184 Nov 29 03:12 simkai.ttf
-rw-r--r-- 1 root root 18259888 Nov 29 03:15 simsun.ttc

 

4、重启应用程序服务器后验证功能,发现已恢复正常。

转载于:https://www.cnblogs.com/xusweeter/p/6114244.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值