zoukankan      html  css  js  c++  java
  • Linux环境下中文字体乱码处理办法

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

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

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

        常规路径为:C:WindowsFonts

        宋体文件为: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、重启应用程序服务器后验证功能,发现已恢复正常。

  • 相关阅读:
    HDU 4122 Alice's mooncake shop
    win7 Visual Studio 2008 安装程序时出现“ 加载安装组件时遇到问题。取消安装。”处理方法
    [置顶] 《程序员,你伤不起》–读书笔记-序
    顺序查找的优化方法
    结构体的大小的计算与空间的优化--之基本类型
    poj 1836 Alignment
    HDU 4721 Food and Productivity (二分+树状数组)
    POJ 1724 最短路费用限制
    Java面试题之九
    Eclipse 支持jQuery 自动提示
  • 原文地址:https://www.cnblogs.com/xusweeter/p/6114244.html
Copyright © 2011-2022 走看看