上兵伐谋

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

以下的解决方案来自国外的一个论坛:

When connecting to another computer using ssh, we found that it had become impossible to run X programs on the remote computer, even though the DISPLAY variable and xhost settings were set correctly. Attempting to run an X-based program remotely produced the message "Couldn't open display". Changing /etc/X11/xdm/Xservers to eliminate the "nolisten" option and editing /etc/X11/xdm/xdm-config had no effect. Finally we discovered that it was necessary to edit /etc/sysconfig/displaymanager and set two variables as shown:

    DISPLAYMANAGER_REMOTE_ACCESS="yes"
    DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN="yes".

This finally allowed the connection.

但是我的实验发现,仅仅这样设置,重新启动后发信X依然是以-nolisten tcp参数启动的。
在SuSEFirewall中打开TCP端口6000,依然不行。
再仔细研究后发现,在/etc/opt/kde3/share/config/kdm/kdmrc文件中还有关于X启动的配置,在[X-:*-Core]段中有这样两个参数:

    ServerArgsLocal=-nolisten tcp
    ServerCmd=/usr/X11R6/bin/X -br

把ServerArgsLocal参数修改为
   
ServerArgsLocal=
再试,发现Remote X已经可以正常工作了。

注:另外发现的问题,我系统中的/etc/opt/kde3/share/config/kdm/kdmrc并不是SuSEconfig所要求的格式,我把SuSEconfig提供的Sample拷过来覆盖掉kdmrc,结果发现在KDE控制中心中运行过KDM的配置后,kdmrc又被修改回来了。这个BUG可能是我手动升级到KDE 3.5.2所引起的。我想可能正是这个原因导致SuSEconfig不能正确配置X的启动参数的。

posted @ 2006-04-25 11:08 Kylin Bell 阅读(315) | 评论 (1)编辑 收藏

From the opensuse.org Web site:

Quick Setup
* Install vsftpd using YaST software management
* Enable vsftpd in xinetd. This can be done manually by editing /etc/xinetd.d/ and changing disabled = yes to disabled = no, or by using the following command
        chkconfig vsftpd on
* Start xinetd if its not running already.
        /etc/init.d/xinetd start
* Make sure that xinetd is started automatically at boot time
        chkconfig xinetd on
* Check that FTP server is working fine. By default only anonymous login is allowed. Data in /srv/ftp/ is made publicly available.
* If neccessary, adapt firewall settings. With SuSEFirewall2 add ftp to FW_SERVICES_EXT_TCP, e. g. (with SSH reachable from the internet, too)
        FW_SERVICES_EXT_TCP="ftp ssh"
* and if you need passive ftp or nat, change also resp.
        FW_LOAD_MODULES="ip_conntrack_ftp ip_nat_ftp"

vsftpd具体的配置这里就不多说了,网上有相当多这方面的资料。我遇到的问题是由于SuSEFirewall的设置问题导致FTP服务不能正常访问。
如上,需要在FW_SERVICES_EXT_TCP字段中添加ftp服务,同时要修改FW_LOAD_MODULES段为 FW_LOAD_MODULES="ip_conntrack_ftp ip_nat_ftp"才可以启用passive模式。

posted @ 2006-04-24 11:13 Kylin Bell 阅读(1505) | 评论 (1)编辑 收藏

据说是因为SCIM的设定跟程序冲突引起的,解决办法是修改arcoread的启动脚本,在最前面加入如下代码:

export GTK_IM_MODULE=xim

posted @ 2006-02-27 14:19 Kylin Bell 阅读(907) | 评论 (4)编辑 收藏

在fstab中添加如下的行:

/dev/hda10     /windows/Solaris     ufs     ro,users,ufstype=sunx86     0 0

posted @ 2006-02-25 21:19 Kylin Bell 阅读(272) | 评论 (0)编辑 收藏

刚刚在一本老书上看到的。可能有点过时,但是还是蛮有意思的。

这是一个可以用来通过内置或者外接的麦克风录制声音的录音命令脚本程序。这个程序脚本的工作原理是:使用dd命令把一段声音(以秒为单位)数据转换并保存到硬盘驱动器上。

#!/bin/sh
#recorder - record sound to disk file
#usage: record [n] soundfilename
echo -ne "recording "
echo -ne $1
echo -ne " seconds of sound to "
echo $2.au
/bin/dd bs 8k count $1 < /dev/audio >$2.au


给这个文件取一个名称,比如recorder,存盘。然后使用chmod命令把这个命令脚本程序转换为可执行的,如下所示:
# chmod +x recorder

现在,我们先使用kmix或者xmixer程序设置麦克风的输入音平。再敲入recorder和希望录音的时间(以秒为单位),如下所示:
# recorder 5 myfirstsound

命令脚本程序响应出下列信息:
recording 5 seconds of sound to myfirstsound.au
5 + 0 records in
5 + 0 records out

把这段数据文件送到音响设备就可以播放了,如下所示:
# cat myfirstsound.au > /dev/audio

posted @ 2006-01-09 11:19 Kylin Bell 阅读(633) | 评论 (0)编辑 收藏

在httpd 2.2.0后增加了proxy-ajp专供Tomcat使用。
官方文档在:http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html

The AJP proxy is a new module based on the standard Http proxy it uses AJP instead of HTTP.

<Location /examples/>
   ProxyPass ajp://localhost:8009/examples/
</Location>

而且可以很轻易的进行负载均衡:

AJP proxy and proxy balancer

It is possible to use the load balancer of the mod_proxy_balancer module.

<Proxy balancer://myCluster>
       BalancerMember ajp://localhost:8009
       BalancerMember ajp://example.org:8009
</Proxy>
<Location /examples/>
       ProxyPass balancer://myCluster/examples/
</Location>

还没来得及仔细研究,先记下来。:)

posted @ 2006-01-09 11:10 Kylin Bell 阅读(1511) | 评论 (1)编辑 收藏

正确安装mplayer需要三个包的安装:主程序,皮肤以及codecs。
这三个程序都可以从mplayer官方网站下载:www.mplayerhq.hu
当前版本是:
src:MPlayer-1.0pre7.tar.bz2
codecs:all-20050412.tar.bz2
Skin自由选择,我们以Blue-1.4.tar.bz2为例。

1、安装时先安装编码包,假设把MPlayer的解码器安装在/usr/lib/win32/中:

# mkdir /usr/lib/win32/
# bzip2 -cd all-20050412.tar.bz2 | tar xvf -
# cp all-20050412/* /usr/lib/win32/

2、安装MPlayer主程序

# bzip2 -cd MPlayer-1.0pre7.tar.bz2 | tar xvf -
# cd MPlayer-1.0pre7/

接下来是配置准备编译。

有这样几个问题需要处理:
1)MPlayer只能使用gcc3编译。
这里我的解决办法是给源码打上gcc4的补丁。下载mplayer-1.0_pre7-gcc4.patch,拷贝到源码目录。
# patch -p1 < mplayer-1.0_pre7-gcc4.patch

2)简体中文的locale为zh_CN.utf8。
首先在MPlayer源代码目录下的help目录里创建help_mp-zh_CN.h.charset文件
# cd MPlayer-1.0pre7
# echo "gb18030"> help/help_mp-zh_CN.h.charset
然后在configure的时候,追加参数--language=zh_CN --charset=utf8,就可以了。

3)为了免去字体配置的烦恼,建议使用Gtk2的GUI。实现办法是给源码打上gtk2的补丁。下载mplayer-1_0_pre7-gtk2.patch,拷贝到源码目录。
# patch -p1 < mplayer-1_0_pre7-gtk2.patch

处理好上述问题后,即可开始编译安装。configure的参数可根据自己的需要选择。请使用./configure --help获取更多的信息。一组常见的编译配置如下:
# ./configure --enable-gui --prefix=/usr/local --language=zh_CN --charset=utf8
# make
# make install

3、安装Skin。

# bzip2 -cd Blue-1.4.tar.bz2 | tar xvf - -C /usr/share/mplayer/Skin/
# mv /usr/share/mplayer/Skin/Blue/ /usr/share/mplayer/Skin/default/

注:编译安装的具体版本号和参数可能有所出入,根据自己的需要进行选择。安装完成后,还需要在用户目录下的.mplayer文件夹中增加subfont.ttf字体文件。

posted @ 2006-01-04 21:54 Kylin Bell 阅读(3393) | 评论 (4)编辑 收藏

1、准备,下载需要的文件。这里假定你已经正确安装配置好了JDK。
到Apache官方网站下载所需要的文件:
httpd-2.2.0.tar.gz
apache-tomcat-5.5.12.tar.gz
jakarta-tomcat-connectors-1.2.15-src.tar.gz
其中httpd和jakarta-tomcat-connectors为源码包,apache-tomcat为二进制包。

2、安装Apache。
代码:
# tar xzvf httpd-2.2.0.tar.gz # cd httpd-2.2.0 # ./configure --prefix=/usr/local/apache2 --enable-so # make # make install

3、安装Tomcat。
代码:
# cp apache-tomcat-5.5.12.tar.gz /usr/local/ # cd /usr/local # tar xzvf apache-tomcat-5.5.12.tar.gz # ln -s apache-tomcat-5.5.12 tomcat

4、编译生成mod_jk。
代码:
# tar xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz # cd jakarta-tomcat-connectors-1.2.15-src/jk/native # ./configure --with-apxs=/usr/local/apache2/bin/apxs # make # cp ./apache-2.0/mod_jk.so /usr/local/apache2/modules/

5、配置。
在/usr/local/apache2/conf/下面建立两个配置文件mod_jk.conf和workers.properties。

# vi mod_jk.conf
添加以下内容:
代码:
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置 JkWorkersFile /usr/local/apache2/conf/workers.properties # Where to put jk logs JkLogFile /usr/local/apache2/logs/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel info # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" # JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T" # 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理 JkMount /servlet/* worker1 JkMount /*.jsp worker1

# vi workers.properties
添加以下内容:
代码:
# Defining a worker named worker1 and of type ajp13 worker.list=worker1 # Set properties for worker1 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.socket_timeout=300

再配置httpd.conf,作以下修改:
将Listen 80 修改为 Listen 127.0.0.1:80
将ServerName 修改为 ServerName LocalHost:80
在DirectoryIndex中添加 index.jsp
我的网页放在/var/wwwroot下,所以要修改DocumentRoot
代码:
DocumentRoot "/var/wwwroot" <Directory "/var/wwwroot"> Options Includes FollowSymLinks AllowOverride None Order deny,allow Allow from all XBitHack on </Directory> <Directory "/var/wwwroot/WEB-INF"> Order deny,allow Deny from all </Directory>

增加关于加载mod_jk的语句:
代码:
LoadModule jk_module modules/mod_jk.so Include /usr/local/apache2/conf/mod_jk.conf

最后编辑Tomcat的配置文件server.xml,在HOST段中加入:
代码:
<Context path="" docBase="/var/wwwroot"
debug="0" reloadable="true" crossContext="true"/>

在/var/wwwroot下建立一个index.jsp,启动Apache和Tomcat,用浏览器访问http://localhost/,应该可以看到正确的页面了。

posted @ 2005-12-25 12:41 Kylin Bell 阅读(9421) | 评论 (3)编辑 收藏

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应用程序就可以看到非常漂亮的中文了。

posted @ 2005-11-06 11:07 Kylin Bell 阅读(2338) | 评论 (4)编辑 收藏

Sun公司的JRE(JAVA运行库)1.5.0版采用的字体设置方案跟1.4.2版的相去甚远。如果设置不当,Java程序中的中文会表现为方格。
本文给出了一般性的字体设置方法。

首先介绍一下其字体配置文件的加载方案。其加载顺序为(JavaHome指JRE的根目录,下同):
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
其中,OS字段可以是:
Windows: "98", "2000", "Me", "XP", "2003"。
Solaris:空。
Linux: "Sun", "RedHat", "Turbo", "SuSE"。
而Version字段指该OS的版本号。

在这些配置文件中,仅.properties文件是文本文件。其格式跟JRE1.4.2版的不同。文件分为几段,并在每段开始时标明。
我们需要关注的仅有两段:Component Font Mappings和Search Sequences。
前者指定字体,后者指定要使用的properties的搜索顺序。
知道了这些,配置起来就简单了。

首先,必须先把字体文件(这里用宋体Simsun.ttf)拷贝到JRE的字体目录JavaHome/lib/fonts下,然后编辑字体目录下的文件fonts.dir,把第一行的数字加1,然后在最后加一行,写上:
simsun.ttf -SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
然后保存。

然后,转到目录JavaHome/lib下,随便找一个.properties.src文件,用文本编辑器打开,并编辑如下:

# @(#)linux.fontconfig.SuSE.properties 1.2 03/10/17
#
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
#

# Version

version=1

# Component Font Mappings

serif.plain.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
serif.bold.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
serif.italic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
serif.bolditalic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
sansserif.plain.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
sansserif.bold.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
sansserif.italic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
sansserif.bolditalic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
monospaced.plain.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
monospaced.bold.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
monospaced.italic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
monospaced.bolditalic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialog.plain.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialog.bold.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialog.italic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialog.bolditalic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialoginput.plain.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialoginput.bold.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialoginput.italic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0
dialoginput.bolditalic.zh-1=-SungtiL GB-medium-r-normal--0-0-0-0-c-0-gb2312.1988-0

# Search Sequences

sequence.allfonts=zh-1

# Exclusion Ranges

# Font File Names


然后按照上面所述的文件名格式保存在这个目录下。如Redhat系统的就保存为fontconfig.RedHat.properties, WindowsXP的就保存为fontconfig.XP.properties,以此类推。

现在,启动Java程序看看,漂亮的JRE1.5的中文界面是不是出来了?

参考资料:

Sun公司对JRE1.5.0版的中文字体设置的官方说明:
http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html

posted @ 2005-11-02 20:24 Kylin Bell 阅读(1017) | 评论 (1)编辑 收藏

仅列出标题
共4页: 1 2 3 4