linux平台下java程序中文显示方框问题处理



一:COPY字体文件,生成字体索引文件
   将 c:\windows\Fonts\simsun.ttc 文件copy到linux下对应目录($JAVA_HOME/jre/lib/fonts/)
   执行下面的命令
   cd $JAVA_HOME/jre/lib/fonts/
   mkfontscale                   #该命令在当前目录下生成fonts.scale文件
   mkfontdir                     #该命令在当前目录下生成fonts.dir文件


二:修改JRE的字体配置文件($JAVA_HOME/jre/lib/fonts/fontconfig.RedHat.5.properties),不同的操作系统名字可能不一样


   找到下面这行
   allfonts.chinese-cn-iso10646=-misc-zysong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1
   修改为
   allfonts.chinese-cn-iso10646=-misc-simsun-medium-r-normal--*-%d-*-*-p-*-iso10646-1
   
   
说明:JRE配置文件确定有以下规则


Loading Font Configuration Files
To find the appropriate font configuration file for a host operating system, the following information is used:

JavaHome - the JRE's directory, as given by the "java.home" system property.
OS - a string identifying an operating system variant:
For Windows, "98", "2000", "Me", "XP", "2003".
For Solaris, empty.
For Linux, "Sun", "RedHat", "Turbo", "SuSE".
Version - a string identifying the operating system version.
The runtime uses the first of the following files it finds:

       JavaHome/lib/fontconfig.OS.Version.properties
       JavaHome/lib/fontconfig.OS.Version.bfc
       JavaHome/lib/fontconfig.OS.properties
       JavaHome/lib/fontconfig.OS.bfc
       JavaHome/lib/fontconfig.Version.properties
       JavaHome/lib/fontconfig.Version.bfc
       JavaHome/lib/fontconfig.properties
       JavaHome/lib/fontconfig.bfc
        
参考文献:
http://docs.oracle.com/javase/6/docs/technotes/guides/intl/fontconfig.html
http://linux-wiki.cn/wiki/zh-hans/Java%E7%A8%8B%E5%BA%8F%E4%B8%AD%E6%96%87%E5%AD%97%E4%BD%93%E9%85%8D%E7%BD%AE

你可能感兴趣的:(java,windows,linux,System,平台,fonts)