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://www.heiqu.com/a72989b5758771fb07cd489e244b2642.html