一: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