|
这是我自己汉化GNOME的心得体会,希望对大家有点启发。
假设你已经安装好X以及GNOME,并且以root帐号进行下面的汉化步骤。
X的字体机制:
目前,有两种带有不同特点的子系统:
- 原始的(已有 15 年以上历史)子系统被称为“核心 X 字体子系统”。由这个子系统绘制的字体不是平滑字体,它们由 X 服务器处理,名称类似:
-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1
- 新的字体子系统被称为“fontconfig”。它允许应用程序直接使用字体文件。fontconfig 经常与“Xft”库一起使用,这会允许应用程序在屏幕上绘制平滑字体。fontconfig 显示的字体更有“人情味儿”。
随着时间的推移,fontconfig/Xft 将会取代核心 X 字体子系统。目前,使用 Qt 3 或 GTK 2 工具包(包括 KDE 和 GNOME 应用程序)的应用程序使用fontconfig 和 Xft 字体子系统;其它部分程序(如 xmms 、gimp) 还在使用核心 X 字体。
Debian(包括 Redhat) 在未来可能会仅支持 fontconfig/Xft 作为默认的本地字体访问方法来取代传统的字体服务器。
注意:以上列出的字体子系统用法有两个例外。它们是 OpenOffice.org(使用它自己的字体绘制技术)和 Mozilla (使用 fontconfig,但不是GTK2)。
Debian汉化步骤简述(11个步骤):
1.在fontconfig的默认配置路径/usr/share/fonts/truetype下创建新文件夹如DIY,随后拷贝字体文件simsun.ttc,tahoma.ttf入内
注意:为了使普通用户也能用上字体,应该修改字体文件的属性
chmod 444 simsun.ttc
chmod 444 tahoma.ttf
2.安装locales,使用dpkg-reconfigure配置它,选上en_US(iso8859-1)以及zh_CN.GBK
3.配置locale为zh_CN.GBK──在/etc/environment文件里添加以下两句
LANG=zh_CN.GBK
XMODIFIERS=@im=fcitx
注意,无须再在任何shell配置文件里设置locale,因为Debian系统最好的配置对象是/etc/environment,以后我会写一篇关于Debian系统启动脚本的文章,请留意
4.dpkg-reconfigure xserver-xfree86配置X,将freetype模块去除,保留xtt模块(它比freetype的字体渲染效果要好,比如说支持粗体)
5.安装相关的工具
apt-get install defoma dfontmgr psfontmgr x-ttcidfont-conf fontconfig libxft2 libxft2-dev libpango1.0-0 zh-autoconvert ttf-arphic-bsmi00lp ttf-arphic-bkai00mp ttf-arphic-gbsn00lp ttf-arphic-gkai00mp xfonts-intl-chinese xfonts-intl-chinese-big manpages-zh
介绍如下:
Debian的特色字体配置工具:
defoma - Debian Font Manager -- automatic font configuration framework
dfontmgr - GUI frontend for defoma, DEbian FOnt MAnager
psfontmgr - PostScript font manager -- part of Defoma, Debian Font Manager
x-ttcidfont-conf - Configure TrueType and CID fonts for X
新一代的字体渲染机制xft2以及它的配置工具fontconfig:
fontconfig - generic font configuration library
libxft2 - advanced font drawing library for X
libxft2-dev - advanced font drawing library for X (development files)
libpango1.0-0 - Layout and rendering of internationalized text
自动中文编码转换工具:
zh-autoconvert - Chinese HZ/GB/BIG5/UNI/UTF7/UTF8 encodings auto-converter
GPL字体:
ttf-arphic-bsmi00lp :文鼎PL细上海宋(Big5 码)
ttf-arphic-bkai00mp :文鼎PL中楷(Big5 码)
ttf-arphic-gbsn00lp :文鼎PL简报宋(GB 码)
ttf-arphic-gkai00mp :文鼎PL简中楷(GB 码)
其他字体:
xfonts-intl-chinese - International fonts for X -- Chinese
xfonts-intl-chinese-big - International fonts for X -- Chinese big
部分中文man手册:
manpages-zh
6.使用dfontmgr注册字体文件(xtt以及xft的配置一次搞定)
有了这个强大的前端,我们可以省却手工或者使用defoma-hints工具创建hints文件的烦琐步骤,而只需按几下鼠标即可注册字体,比如说要注册simsun字体,我们按下"Register Font"按钮,按"next",随后选择/usr/share/fonts/truetype/DIY这个路径下的simsun.ttc字体文件,按下"ok";接着dfontmgr会用一系列的对话框给出该字体文件的所有信息,仔细确认一路按下"ok"即可,最后字体被注册到所有可能的字体子系统包括xfonts以及fontconfig。
随后把下面两句添加到/etc/X11/XF86Config-4文件,使xtt能使用dfontmgr注册的字体集(dfontmgr自动更新fontconfig)
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
7.安装firefly补丁(在sources.list中添加源后,dist-upgrade即可升级相关软件为firefly版本)
补充:使用debian.cn99.com的sarge源,添上ustc(中国科技大学)源即可:
# Unofficial packages
# Avaliable components: marillat rareware ustc java misc firefly
deb http://debian.ustc.edu.cn/debian-uo/ sid misc marillat rareware ustc java firefly
8.修改/etc/fonts/fonts.conf文件,使中英文独立显示(估计是调整了替代规则以及优先级)以及firefly补丁生效
这里给出参考的fonts.conf文件:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
<!--
DO NOT EDIT THIS FILE.
IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
LOCAL CHANGES BELONG IN 'local.conf'.
The intent of this standard configuration file is to be adequate for
most environments. If you have a reasonably normal environment and
have found problems with this configuration, they are probably
things that others will also want fixed. Please submit any
problems to the fontconfig bugzilla system located at fontconfig.org
Note that the normal 'make install' procedure for fontconfig is to
replace any existing fonts.conf file with the new version. Place
any local customizations in local.conf which this file references.
Keith Packard
-->
<!-- Font directory list configured on Tue Apr 22 16:09:12 EDT 2003 -->
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts/TTF</dir>
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir>
<dir>~/.fonts</dir>
<!--
*Set alias start*
-->
<!--
Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
<test qual="any" name="family">
<string>mono</string>
</test>
<edit name="family" mode="assign">
<string>monospace</string>
</edit>
</match>
<!--
Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans serif</string>
</test>
<edit name="family" mode="assign">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans</string>
</test>
<edit name="family" mode="assign">
<string>sans-serif</string>
</edit>
</match>
<!--
Mark common families with their generics so we'll get
something reasonable
-->
<!--
* Set alias END*
-->
<!--
*Define three font-sets: Sans-serif,Sans,Monospace*
-->
<!--
Serif faces
-->
<alias>
<family>Bitstream Vera Serif</family>
<family>Times</family>
<family>Times New Roman</family>
<family>Nimbus Roman No9 L</family>
<family>Luxi Serif</family>
<family>Mingliu</family>
<family>Kochi Mincho</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Baekmuk Batang</family>
<default><family>serif</family></default>
</alias>
<!--
Sans-serif faces
-->
<alias>
<family>Bitstream Vera Sans</family>
<family>Helvetica</family>
<family>Arial</family>
<family>Verdana</family>
<family>Nimbus Sans L</family>
<family>Luxi Sans</family>
<family>Tahoma</family>
<family>Simsun</family>
<family>Mingliu</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>AR PL KaitiM Big5</family>
<family>Baekmuk Dotum</family>
<default><family>sans-serif</family></default>
</alias>
<!--
Monospace faces
-->
<alias>
<family>Bitstream Vera Sans Mono</family>
<family>Courier</family>
<family>Courier New</family>
<family>Andale Mono</family>
<family>Luxi Mono</family>
<family>Nimbus Mono L</family>
<family>NSimSun</family>
<family>MingLiu</family>
<default><family>monospace</family></default>
</alias>
<!--
If the font still has no generic name, add sans-serif
-->
<match target="pattern">
<test qual="all" name="family" compare="not_eq">
<string>sans-serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>monospace</string>
</test>
<edit name="family" mode="append_last">
<string>sans-serif</string>
</edit>
</match>
<!--
Some Asian fonts misadvertise themselves as monospaced when
in fact they are dual-spaced (half and full). This makes
FreeType very confused as it forces all widths to match.
Undo this magic by disabling the width forcing code -->
<match target="font">
<test name="family"><string>GulimChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>DotumChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>BatangChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>GungsuhChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<!--
The Bitstream Vera fonts have GASP entries suggesting that hinting be
disabled below 8 ppem, but FreeType ignores those, preferring to use
the data found in the instructed hints. The initial Vera release
didn't include the right instructions in the 'prep' table. Fix this
by disabling hinting manually at smaller sizes (< 8ppem)
-->
<match target="font">
<test name="family">
<string>Bitstream Vera Sans</string>
</test>
<test name="pixelsize" compare="less">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
<match target="font">
<test name="family">
<string>Bitstream Vera Serif</string>
</test>
<test name="pixelsize" compare="less">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
<match target="font">
<test name="family">
<string>Bitstream Vera Sans Mono</string>
</test>
<test name="pixelsize" compare="less">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
<!--
Load per-user customization file
-->
<include ignore_missing="yes">~/.fonts.conf</include>
<!--
Load local system customization file
-->
<include ignore_missing="yes">local.conf</include>
<!--
Alias well known font names to available TrueType fonts
-->
<alias>
<family>Times</family>
<accept><family>Times New Roman</family></accept>
</alias>
<alias>
<family>Helvetica</family>
<accept><family>Verdana</family></accept>
</alias>
<alias>
<family>Arial</family>
<accept><family>Verdana</family></accept>
</alias>
<alias>
<family>Courier</family>
<accept><family>Courier New</family></accept>
</alias>
<!--
Check user preference to avoid bitmap fonts and replace
bitmap face names with equivalent scalable fonts
-->
<match target="pattern">
<test name="prefer_outline">
<bool>true</bool>
</test>
<test name="family">
<string>Helvetica</string>
</test>
<edit name="family" mode="prepend" binding="same">
<string>Arial</string>
</edit>
</match>
<match target="pattern">
<test name="prefer_outline">
<bool>true</bool>
</test>
<test name="family">
<string>Times</string>
</test>
<edit name="family" mode="prepend" binding="same">
<string>Times New Roman</string>
</edit>
</match>
<!--
Provide required aliases for standard names
-->
<alias>
<family>serif</family>
<prefer>
<family>Bitstream Vera Serif</family>
<family>Times New Roman</family>
<family>Nimbus Roman No9 L</family>
<family>Luxi Serif</family>
<family>Times</family>
<family>Simsun</family>
<family>Mingliu</family>
<family>Kochi Mincho</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Baekmuk Batang</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Bitstream Vera Sans</family>
<family>Verdana</family>
<family>Nimbus Sans L</family>
<family>Luxi Sans</family>
<family>Tahoma</family>
<family>Simsun</family>
<family>Mingliu</family>
<family>Arial</family>
<family>Helvetica</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>AR PL KaitiM Big5</family>
<family>Baekmuk Dotum</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Bitstream Vera Sans Mono</family>
<family>Andale Mono</family>
<family>Courier New</family>
<family>Luxi Mono</family>
<family>Nimbus Mono L</family>
<family>SimSun</family>
<family>NSimSun</family>
<family>MingLiu</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>Baekmuk Dotum</family>
</prefer>
</alias>
<!--
Artificial oblique for fonts without an italic or oblique version
-->
<match target="font">
<!-- check to see if the font is roman -->
<test name="slant">
<const>roman</const>
</test>
<!-- check to see if the pattern requested non-roman -->
<test target="pattern" name="slant" compare="not_eq">
<const>roman</const>
</test>
<!-- multiply the matrix to slant the font -->
<edit name="matrix" mode="assign">
<times>
<name>matrix</name>
<matrix><double>1</double><double>0.2</double>
<double>0</double><double>1</double>
</matrix>
</times>
</edit>
<!-- pretend the font is oblique now -->
<edit name="slant" mode="assign">
<const>oblique</const>
</edit>
</match>
<!--
This expression is added by Akito Hirai<akito@kde.gr.jp> for convenience.
It can be used to make artificial bold versions in client libraries/applications.
-->
<match target="font">
<test name="weight">
<const>medium</const>
</test>
<test target="pattern" name="weight" compare="more">
<const>medium</const>
</test>
<edit name="weight" mode="assign">
<if>
<more>
<name>spacing</name>
<const>proportional</const>
</more>
<const>demibold</const> <!-- for monospace -->
<const>bold</const> <!-- for proportional -->
</if>
</edit>
</match>
<match target="font">
<test name="pixelsize" compare="less_eq">
<double>16</double>
</test>
<test name="pixelsize" compare="more_eq">
<double>8</double>
</test>
<edit name="antialias" mode="assign">
<bool>f</bool>
</edit>
</match>
<match target="font">
<test name="size" compare="less_eq">
<double>16</double>
</test>
<test name="size" compare="more_eq">
<double>8</double>
</test>
<edit name="antialias" mode="assign">
<bool>f</bool>
</edit>
</match>
<config>
<!--
These are the default Unicode chars that are expected to be blank
in fonts. All other blank chars are assumed to be broken and
won't appear in the resulting charsets
-->
<blank>
<int>0x0020</int> <!-- SPACE -->
<int>0x00a0</int> <!-- NO-BREAK SPACE -->
<int>0x00ad</int> <!-- SOFT HYPHEN -->
<int>0x115f</int> <!-- HANGUL CHOSEONG FILLER -->
<int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
<int>0x1680</int> <!-- OGHAM SPACE MARK -->
<int>0x2000</int> <!-- EN QUAD -->
<int>0x2001</int> <!-- EM QUAD -->
<int>0x2002</int> <!-- EN SPACE -->
<int>0x2003</int> <!-- EM SPACE -->
<int>0x2004</int> <!-- THREE-PER-EM SPACE -->
<int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
<int>0x2006</int> <!-- SIX-PER-EM SPACE -->
<int>0x2007</int> <!-- FIGURE SPACE -->
<int>0x2008</int> <!-- PUNCTUATION SPACE -->
<int>0x2009</int> <!-- THIN SPACE -->
<int>0x200a</int> <!-- HAIR SPACE -->
<int>0x200b</int> <!-- ZERO WIDTH SPACE -->
<int>0x200c</int> <!-- ZERO WIDTH NON-JOINER -->
<int>0x200d</int> <!-- ZERO WIDTH JOINER -->
<int>0x200e</int> <!-- LEFT-TO-RIGHT MARK -->
<int>0x200f</int> <!-- RIGHT-TO-LEFT MARK -->
<int>0x2028</int> <!-- LINE SEPARATOR -->
<int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
<int>0x202a</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
<int>0x202b</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
<int>0x202c</int> <!-- POP DIRECTIONAL FORMATTING -->
<int>0x202d</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
<int>0x202e</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
<int>0x202f</int> <!-- NARROW NO-BREAK SPACE -->
<int>0x205f</int> <!-- MEDIUM MATHEMATICAL SPACE -->
<int>0x2060</int> <!-- WORD JOINER -->
<int>0x2061</int> <!-- FUNCTION APPLICATION -->
<int>0x2062</int> <!-- INVISIBLE TIMES -->
<int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
<int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
<int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
<int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
<int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
<int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
<int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
<int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
<int>0x3164</int> <!-- HANGUL FILLER -->
<int>0xfeff</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
<int>0xffa0</int> <!-- HALFWIDTH HANGUL FILLER -->
<int>0xfff9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
<int>0xfffa</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
<int>0xfffb</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
</blank>
<!--
Rescan configuration every 30 seconds when FcFontSetList is called
-->
<rescan>
<int>30</int>
</rescan>
</config>
</fontconfig>
9.安装fcitx,并在GNOME创建启动条目使fcitx开机启动:
cat > ~/.gnomerc << EOF
fcitx &
重启X
10.修改gnome的字体为tahoma,汉化GNOME系统
桌面首选项-->字体
11.修改gtk的配置文件,汉化gtk1,gtk2的应用程序
/etc/gtk-2.0/gtkrc:
#英文用tahoma显示,中文用simsun显示
style "user-font"
{
font_name="Tahoma,Simsun 9"
}
widget_class "*" style "default"
/etc/gtk/gtkrc.zh_CN:
style "gtk-default-zh-cn" {
fontset = "-adobe-helvetica-medium-r-normal--14-*-*-*-*-*-iso8859-1,\
-dynalab-simsun-medium-r-normal--14-*-*-*-*-*-gbk-0,fixed"
}
class "GtkWidget" style "gtk-default-zh-cn"
心得:
1. Sans-serif字体集优先级别最高
2. fcitx的字体显示使用与xft最高优先级别的字体集
3. 为了有最好的网页浏览显示,请安装firefox
4. 由于调整好了fontconfig,于是以后系统所有gtk{1,2}以及依赖xft的程序如firefox都可以使用自动使用tahoma显示英文,simsun显示中文了,只要把这些程序的中英文都选上tahoma即可
参考文献:
1.quanliking兄的"Debian 新手汉化跟我来--实战演练篇"
http://linuxsir.cn/forum.php?mod=viewthread&tid=48100
2.linuxfans的转帖"国际化、本土化和中文输出入"
http://www.linuxfans.org/nuke/mo ... iewtopic&t=3416 |
|