上兵伐谋

“上兵伐谋,其次伐交,其次伐兵,其下攻城”。
posts - 35, comments - 32, trackbacks - 0, articles - 3

SuSE下JRE中文字体的简单设置

Posted on 2005-11-06 11:07 Kylin Bell 阅读(2339) 评论(4)  编辑 收藏 引用

SuSE默认使用方正宋体,对中文已经有比较好的支持。其fontconfig.SuSE.properties内容如下:

# @(#)linux.fontconfig.Turbo.8.0.properties 1.1 04/04/01
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
#

# Version

version=1

# Component Font Mappings

allfonts.chinese-gb18030=-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb18030-0
allfonts.chinese-gbk=-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gbk-0
allfonts.chinese-gb2312=-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb2312.1980-0
allfonts.chinese-big5=-founder-MingTiB-medium-r-normal--*-%d-*-*-*-*-big5-0
allfonts.chinese-iso10646=-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-iso10646-1

allfonts.lucida=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
allfonts.japanese-x0201=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0

serif.plain.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
serif.plain.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.plain.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.plain.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
serif.plain.latin-1=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1

serif.bold.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
serif.bold.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bold.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bold.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
serif.bold.latin-1=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1

serif.italic.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
serif.italic.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.italic.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.italic.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
serif.italic.latin-1=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1

serif.bolditalic.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
serif.bolditalic.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bolditalic.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bolditalic.korean.motif=-baeckmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
serif.bolditalic.latin-1=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1

sansserif.plain.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
sansserif.plain.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.plain.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.plain.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
sansserif.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1

sansserif.bold.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
sansserif.bold.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bold.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bold.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
sansserif.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1

sansserif.italic.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
sansserif.italic.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.italic.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.italic.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
sansserif.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1

sansserif.bolditalic.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
sansserif.bolditalic.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bolditalic.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bolditalic.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
sansserif.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1

monospaced.plain.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
monospaced.plain.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.plain.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.plain.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
monospaced.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1

monospaced.bold.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
monospaced.bold.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bold.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bold.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
monospaced.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1

monospaced.italic.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
monospaced.italic.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.italic.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.italic.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
monospaced.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1

monospaced.bolditalic.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
monospaced.bolditalic.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bolditalic.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bolditalic.korean.motif=-bekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
monospaced.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1

dialog.plain.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialog.plain.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.plain.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.plain.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialog.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1

dialog.bold.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialog.bold.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bold.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bold.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialog.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1

dialog.italic.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialog.italic.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.italic.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.italic.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialog.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1

dialog.bolditalic.japanese-x0208=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialog.bolditalic.japanese-iso10646=-misc-sazanami gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bolditalic.korean=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bolditalic.korean.motif=-baekmukttf-gulim-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialog.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1

dialoginput.plain.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialoginput.plain.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.plain.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.plain.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialoginput.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1

dialoginput.bold.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialoginput.bold.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bold.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bold.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialoginput.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1

dialoginput.italic.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialoginput.italic.japanese-so10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.italic.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.italic.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialoginput.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1

dialoginput.bolditalic.japanese-x0208=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0
dialoginput.bolditalic.japanese-iso10646=-misc-sazanami mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bolditalic.korean=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bolditalic.korean.motif=-baekmukttf-batang-medium-r-normal--*-%d-*-*-c-*-ksc5601.1987-0
dialoginput.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1


# Search Sequences

sequence.allfonts=latin-1
#sequence.allfonts.Big5=latin-1,chinese-big5
#sequence.allfonts.Big5-HKSCS=latin-1,chinese-big5
#sequence.allfonts.GB18030=latin-1,chinese-gbk,chinese-iso10646
#sequence.allfonts.GBK=latin-1,chinese-gbk
#sequence.allfonts.GB2312=latin-1,chinese-gb2312
sequence.allfonts.x-euc-jp-linux=latin-1,japanese-x0208,japanese-x0201
sequence.allfonts.UTF-8.ja.JP=latin-1,japanese-x0208,japanese-x0201,chinese-iso10646
sequence.allfonts.UTF-8.zh=latin-1,chinese-iso10646,japanese-x0208,japanese-x0201
sequence.allfonts.EUC-KR=latin-1,korean
sequence.fallback=lucida,chinese-big5,japanese-x0208,japanese-x0201,korean

# Exclusion Ranges
exclusion.japanese-x0201=0390-03d6,2200-22ef,2701-27be
exclusion.japanese-x0208=0390-03d6,2200-22ef,2701-27be

# Font File Names

filename.-misc-sazanami_gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0=/usr/X11R6/lib/X11/fonts/truetype/sazanami-gothic.ttf
filename.-misc-sazanami_mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0=/usr/X11R6/lib/X11/fonts/truetype/sazanami-mincho.ttf
filename.-misc-sazanami_gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0=/usr/X11R6/lib/X11/fonts/truetype/sazanami-gothic.ttf
filename.-misc-sazanami_mincho-medium-r-normal--*-%d-*-*-c-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/sazanami-mincho.ttf
filename.-misc-sazanami_gothic-medium-r-normal--*-%d-*-*-c-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/sazanami-gothic.ttf

filename.-baekmukttf-batang-medium-r-normal--*-%d-*-*-*-*-ksc5601.1987-0=/usr/X11R6/lib/X11/fonts/truetype/batang.ttf
filename.-baekmukttf-batang-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/batang.ttf
filename.-baekmukttf-gulim-medium-r-normal--*-%d-*-*-*-*-ksc5601.1987-0=/usr/X11R6/lib/X11/fonts/truetype/gulim.ttf
filename.-baekmukttf-gulim-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/gulim.ttf

filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb18030-0=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gbk-0=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb2312.1980-0=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf

# AWT X11 font paths
#awtfontpath.chinese-big5=/usr/X11R6/lib/X11/fonts/ttf-zh
#awtfontpath.chinese-gb2312=/usr/X11R6/lib/X11/fonts/ttf-zh
#awtfontpath.chinese-gbk=/usr/X11R6/lib/X11/fonts/ttf-zh
#awtfontpath.chinese-iso10646=/usr/X11R6/lib/X11/fonts/ttf-zh
awtfontpath.japanese-x0201=/usr/X11R6/lib/X11/fonts/truetype
awtfontpath.japanese-x0208=/usr/X11R6/lib/X11/fonts/truetype
awtfontpath.japanese-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype
awtfontpath.korean=/usr/X11R6/lib/X11/fonts/truetype


我在使用的时候,为了获得更好的显示效果,删除了系统自带的方正字体,安装了Windows下拷过来的Simsun.ttf。这个时候Java的中文将不能正常显示。幸运的是,我们只需对配置文件要做一点非常简单的改动。

在上面列出的配置文件中有如下几行:


filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb18030-0=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gbk-0=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb2312.1980-0=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/X11R6/lib/X11/fonts/truetype/FZSongTi.ttf

这几行是用来指定SongTi系列字形使用的字体文件的。所以我们只需要注释掉这几行,再把相应字形的字体文件全部指定为Simsun.ttf即可。如下:

filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/local/share/fonts/Simsun.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb18030-0=/usr/local/share/fonts/Simsun.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gbk-0=/usr/local/share/fonts/Simsun.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-gb2312.1980-0=/usr/local/share/fonts/Simsun.ttf
filename.-founder-SongTi-medium-r-normal--*-%d-*-*-*-*-iso10646-1=/usr/local/share/fonts/Simsun.ttf

这时再运行Java应用程序就可以看到非常漂亮的中文了。

Feedback

# re: SuSE下JRE中文字体的简单设置  回复  更多评论   

2005-12-19 22:39 by frank1980
请问,你所提到的这个文件在哪里?我用的是suse10.0@64bit
另外,我在/usr/local/share/fonts/中看到的不是Simsun.ttf而是simsun.ttc,为何?

# re: SuSE下JRE中文字体的简单设置  回复  更多评论   

2005-12-20 09:01 by Kylin Bell
这个文件在JAVAHOME/lib/下

最后几行的意思就是把宋体指定成你自己的字体即可
并不一定要是Simsun.ttf

# re: SuSE下JRE中文字体的简单设置  回复  更多评论   

2005-12-20 12:01 by frank1980
谢谢你的回复
估计是版本不同吧,我export之后输出JAVA_HOME="/usr/lib/jvm/java,但是还是无法找到这个文件,即使文件搜索也找不到。我是10.0的64bit版。
我将继续关注你的博客,谢谢。

# re: SuSE下JRE中文字体的简单设置  回复  更多评论   

2005-12-20 12:44 by Kylin Bell
没有这个文件就在$JAVAHOME/lib/目录下自己新建一个

或者把fontconfig.SuSE.properties.src重名名成fontconfig.SuSE.properties
只有注册用户登录后才能发表评论。