Example: Debian Chinese Desktop Setup (2007)
debian中文桌面的快速构建
--------------------------------------------------------------------------------

在debian的中文美化时,基本可以按照我这样的步骤来做。我也是参考了香港
debian桌面安装大赛时采用的方式,步骤顺序上做了调整,并在debian和gentoo
系统上测试成功。

1.第一步,产生语系(locale)
如果没有安装locales的请安装locales:

代码:
#apt-get install locales

若已经安装了locales,就重新设定语系:

代码:
#dpkg-reconfiguer locales

选择生成下列语系的数据:

代码:
en_US.ISO-8859-1
en_US.UTF-8
zh_CN.GB2312
zh_CN.UTF-8
zh_CN.GBK
zh_TW.BIG5
zh_TW.UTF-8

再将默认locale选择为“C”。然后用“locale -a”来查看现在系统中所有支持的语系,

代码:
#locale -a
C
POSIX
en_US.ISO-8859-1
en_US.UTF-8
zh_CN.GB2312
zh_CN.UTF-8
zh_CN.GBK
zh_TW.BIG5
zh_TW.UTF-8

用“locale”查看当前所使用的语系。

代码:
#locale
LANG=C
LC_ALL=POSIX
LC_CTYPE=POSIX
...

在产生了语系后,最好是重新启动系统。或者也可以重新登陆一次。

2.建议先安装firefly修正的一些包。
同样在/etc/apt/sources.list中加入源地址:

代码:
deb http://debian.okey.net/debian-uo/ sid firefly
或者deb ftp://ftp.hk.debian.org/unofficial/firefly/binary-i386 ./

更新后安装firefly-sung

代码:
#apt-get update
#apt-get install ttf-firefly-sung

注意这个firefly-sung与fireflysung不是同一个文件,它是firefly修正的fontconfig,
libxfs等的配置,不要搞错了。你可以事先搜索一下“firefly”这个关键字,以检查apt
仓库是否探测准确:

代码:
#apt-cache search firefly

3.安装字体
linux中最常用的中文字体是文鼎的四套中文字体:ttf-arphic-bkai00mp(文鼎PL
中楷AR PL KaitiMBig5,包含BIG5中13000个繁体字),ttf-arphic-gbsn00lp
(文鼎PL简报宋AR PL SungtiLGB,包含GB2312中7000多个简体),
ttf-arphic-bsmi00lp(文鼎PL细上海宋AR PL Mingti2L Big5)
以及ttf-arphic-gkai00mp(文鼎PL KaitiMGB,包含GB2312中7000多个简体字)。
这些字体可以直接通过apt来安装。

代码:
#apt-get install ttf-arphic-bkai00mp tf-arphic-gbsn00lp ttf-arphic-bsmi00lp
ttf-arphic-gkai00mp

但是由于中文字体笔画繁多,矢量字体加上Anti-Alias在细尺寸时反而显得模糊不清。
这里我推荐使用台湾萤火虫(firefly)合并衬线后的新字体——文鼎PL新宋。
在/etc/apt/sources.list中加上新宋字体的apt仓库源:

代码:
deb ftp://debian.linux.org.tw/pub/apt unstable main
或者 deb ftp://ftp.hk.debian.org/unoffical/dlot-apt unstable main

然后更新apt repositories数据,就可以安装firefly的字体了。

代码:
#apt-get update
#apt-get install ttf-fireflysung

为了避免造成不必要的麻烦,强烈建议首先安装fireflysung这个字体!!
接着就是安装文鼎的四个字体,自由字体中英文字体效果比较好的有Bitstream Vera Sans
字体和DejaVu字体。特别是这个DejaVu字体是fundawang提及的将在Mandrake中
采用的英文字体,我在gentoo和 dbeian中测试效果都好于Bitstream Vera字体,故推荐使用。

代码:
#apt-get install ttf-bitstream-vera ttf-dejavu

为了提高对微软平台的兼容程度,我也建议安装msttcorefonts这一套微软的英文字体。
这套字体包含了AndalMono、 ArialBlack、Arial、ComicSansMS、Georgia、Impact、
TimesNew Roman、Times、Trebuchet、Verdana和Webdings等11种字体。

代码:
#apt-get install msttcorefonts

4.设置Fontconfig这一步非常重要,也许你是安装了非常好看的字体,但是如果你不修正你的Fontconfig,
再好看的效果也不一定出来。
首先我们编辑/etc/fonts/fonts.conf这个文件,检查字体的使用顺序,把你要用的效果最好的字体放在最前面。

重排Serif字体显示顺序:

代码:
<alias>
     <family>serif</family>
     <prefer>
        <family>DejaVu Serif</family>
        <family>Bitstream Vera Serif</family>
        <family>Times New Roman</family>
        <family>Times</family>
        <family>AR PL New Sung</family>
        <family>SimSun</family>
        <family>Luxi Serif</family>
        <family>AR PL Mingti2L Big5</family>
        <family>AR PL SungtiL GB</family>
        <family>Ming(ISO10646)</family>
        <family>Kochi Mincho</family>
        <family>Baekmuk Batung</family>
     </prefer>
  </alias>

排序的关键是把效果最好的放在最前,DejaVu和Bitstream Vera的英文显示效果最好,所以
排在所有英文字体的前面,而AR PL New Sung(就是firefly的字体)以及Simsun的中文效果最好,
所以排在所有cjk字体的前面.我的技巧是直接搜索Luxi字体,在这个字体前加上自己的中文字体。

重排sans-serif字体显示顺序:
代码:
<alias>
     <family>sans-serif</family>
     <prefer>
         <family>DejaVu Serif</family>
         <family>Bitstream Vera Sans</family>
         <family>Arial</family>
         <family>Verdana</family>
         <family>Helvetica</family>
         <family>AR PL New Sung</family>
         <family>SimSun</family>
         <family>Luxi Serif</family>
         <family>Ming(ISO10646)</family>
         <family>AR PL kaitiM Big5</family>
         <family>AR PL kaitiM GB</family>
         <family>Kochi Gothic</family>
         <family>Baekmuk Dotum</family>
     </prefer>
  </alias>

Fontconfig把sans定为sans-serif的别名,所以排序的办法也是一样。

重排monospace的字体显示顺序:

代码:
<alias>
     <family>monospace</family>
     <prefer>
        <family>Bitstream Vera Sans Mono</family>
        <family>Courier New</family>
        <family>Courier</family>
        <family>AR PL New Sung</family>
        <family>Ming(ISO10646)</family>
        <family>Kochi Mincho</family>
        <family>Baekmuk Batung</family>
     </prefer>
  </alias>

接着我们来做一次模仿,请在所有写着“Bitstream Vera xxx”字样的一行前面按照这行的
写法添加自己的字体。这样做的目的是让系统在做字体的替换时做得更彻底些。例如:

代码:
<match target="font">
      <test name="family">
             <string>DejaVu Sans Mono</string>
             <string>Bitstream Vera Sans Mono</string>
      </test>
      ...
</match>

5.调整/etc/fonts/local.conf这一步也是非常重要的,因为我们要做的是关闭中文字体在
8px-16px之间时的Anti-Alias,以及加入粗体的设定。
我的locale.conf如下:

代码:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/local.conf file for local customizations -->
<fontconfig>
<!--
  Enable sub-pixel rendering
      <match target="font">
             <edit name="rgba" mode="assign"><const>rgb</const></edit>
      </match>
-->
<!--
  Add by Firefly(firefly@firefly.idv.tw)
-->
       <match target="font">
             <edit name="embeddedbitmap" mode="assign">
                    <bool>true</bool>
             </edit>
       </match>

<!--
  Add by Firefly(firefly@firefly.idv.tw)
  Most of Asian fonts can&#39;t explain by freetype2,
  so,if these fonts have dual width(half/full) and monospacing,
  you need to disable globaladvance.
-->
      <match target="font">
             <test name="spacing" compare="more_eq">
                    <const>mono</const>
             </test>
             <edit name="globaladvance" mode="assign">
                    <bool>false</bool>
             </edit>
      </match>

<!--
Add by firefly@firefly.idv.tw
Artificial bold for fonts without a bold version.
-->
      <match target="font">
             <!-- check to see if the pattern requested > "medium" -->
             <test target="pattern" name="weight" compare="more">
                    <const>medium</const>
             </test>
             <!-- pretend the font is bold now -->
             <edit name="weight" mode="assign">
                    <const>bold</const>
             </edit>
      </match>
<!--
  Add by firefly@firefly.idv.tw
-->
      <match target="pattern">
             <test name="lang" compare="contains">
                    <string>zh-tw</string>
                    <string>zh-cn</string>
                    <string>zh-hk</string>
                    <string>zh-mo</string>
                    <string>zh-sg</string>
                    <string>zh</string>
                    <string>ja</string>
                    <string>ko</string>
             </test>
             <edit name="hinting" mode="assign">
                    <bool>true</bool>
             </edit>
             <edit name="usegamma" mode="assign">
                 <if>
                    <less>
                           <name>pixelsize</name>
                           <double>20</double>
                    </less>
                 </if>
                 <bool>true</bool>
             </edit>
      </match>
<!--........................................................................-->       
      <config>
<!--
  Add by Firefly (firefly@firefly.idv.tw)
  Output non English/Latin family name.
-->
             <familyoutput>
                    <const>auto</const>
                    <!--const>englishonly</const-->
                    <!--const>any</const-->
             </familyoutput>
      </config>
<!--.......................................................................-->
<!--
  Add by EricNeon (ericneon@geekbone.org)
Disable Chinese fonts Anti-Alias in 8px-16px.
-->
      <match target="font">
               <test name="pixelsize" compare="more_eq">
                     <double>8</double>
             </test>
               <test name="pixelsize" compare="less_eq">
                     <double>16</double>
             </test>
             <edit name="antialias">
                    <bool>false</bool>
             </edit>
             <edit name="hinting">
                    <bool>true</bool>
             </edit>
      </match>

</fontconfig>

6.最后我们在/etc/X11/XSession.d/目录下创建一个X的启动文件95locale-xinput-set,
在此设定X的locale和中文输入法。

代码:
case "$LANG" in
zh_CN*)
      /usr/bin/scim -d(或fcitx &)
       XMODIFIERS=@im=scim(或fcitx)
      GTK_IM_MODULE=scim(或fcitx)
      ;;
zh_TW*)
      /usr/bin/scim -d(或fcitx &)
      XMODIFIERS=@im=scim(或fcitx)
      GTK_IM_MODULE=scim(或fcitx)
      ;;
zh_HK*)
       /usr/bin/scim -d(或fcitx &)
      XMODIFIERS=@im=scim(或fcitx)
      GTK_IM_MODULE=scim(或fcitx)
      ;;
esac
export XMODIFIERS GTK_IM_MODULE
export LANG=zh_CN.UTF-8  (如果你没有设置locale=zh_CN.UTF-8)
export G_FILENAME_ENCODING=@UTF-8

现在你可以到你的桌面下去看看效果了,无论是使用startx还是用gdm、xdm、kdm等启动桌面,
都不需要另外再设置locale和输入法。
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License