LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 25360|回复: 48

debian中文桌面的快速构建

[复制链接]
发表于 2005-3-9 20:45:29 | 显示全部楼层 |阅读模式
在debian的中文美化时,基本可以按照我这样的步骤来做。我也是参考了香港debian桌面安装大赛时采用的方式,步骤顺序上做了调整,并在debian和gentoo系统上测试成功。

1.第一步,产生语系(locale)
如果没有安装locales的请安装locales:
  1. #apt-get install locales
复制代码

若已经安装了locales,就重新设定语系:
  1. #dpkg-reconfiguer locales
复制代码

选择生成下列语系的数据:
  1. en_US.ISO-8859-1
  2. en_US.UTF-8
  3. zh_CN.GB2312
  4. zh_CN.UTF-8
  5. zh_CN.GBK
  6. zh_TW.BIG5
  7. zh_TW.UTF-8
复制代码

再将默认locale选择为“C”。然后用“locale -a”来查看现在系统中所有支持的语系,
  1. #locale -a
  2. C
  3. POSIX
  4. en_US.ISO-8859-1
  5. en_US.UTF-8
  6. zh_CN.GB2312
  7. zh_CN.UTF-8
  8. zh_CN.GBK
  9. zh_TW.BIG5
  10. zh_TW.UTF-8
复制代码

用“locale”查看当前所使用的语系。
  1. #locale
  2. LANG=C
  3. LC_ALL=POSIX
  4. LC_CTYPE=POSIX
  5. ...
复制代码

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

2.建议先安装firefly修正的一些包。
同样在/etc/apt/sources.list中加入源地址:
  1. deb http://debian.okey.net/debian-uo/ sid firefly
  2. 或者deb ftp://ftp.hk.debian.org/unofficial/firefly/binary-i386 ./
复制代码

更新后安装firefly-sung
  1. #apt-get update
  2. #apt-get install ttf-firefly-sung
复制代码

注意这个firefly-sung与fireflysung不是同一个文件,它是firefly修正的fontconfig,libxfs等的配置,不要搞错了。你可以事先搜索一下“firefly”这个关键字,以检查apt仓库是否探测准确:
  1. #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来安装。
  1. #apt-get install ttf-arphic-bkai00mp tf-arphic-gbsn00lp ttf-arphic-bsmi00lp
  2. ttf-arphic-gkai00mp
复制代码


但是由于中文字体笔画繁多,矢量字体加上Anti-Alias在细尺寸时反而显得模糊不清。这里我推荐使用台湾萤火虫(firefly)合并衬线后的新字体——文鼎PL新宋。
在/etc/apt/sources.list中加上新宋字体的apt仓库源:
  1. deb ftp://debian.linux.org.tw/pub/apt unstable main
  2. 或者 deb ftp://ftp.hk.debian.org/unoffical/dlot-apt unstable main
复制代码

然后更新apt repositories数据,就可以安装firefly的字体了。
  1. #apt-get update
  2. #apt-get install ttf-fireflysung
复制代码

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


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


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

重排Serif字体显示顺序:

  1. <alias>
  2.       <family>serif</family>
  3.       <prefer>
  4.          <family>DejaVu Serif</family>
  5.          <family>Bitstream Vera Serif</family>
  6.          <family>Times New Roman</family>
  7.          <family>Times</family>
  8.          <family>AR PL New Sung</family>
  9.          <family>SimSun</family>
  10.          <family>Luxi Serif</family>
  11.          <family>AR PL Mingti2L Big5</family>
  12.          <family>AR PL SungtiL GB</family>
  13.          <family>Ming(ISO10646)</family>
  14.          <family>Kochi Mincho</family>
  15.          <family>Baekmuk Batung</family>
  16.       </prefer>
  17.   </alias>

复制代码

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

重排sans-serif字体显示顺序:

  1. <alias>
  2.       <family>sans-serif</family>
  3.       <prefer>
  4.           <family>DejaVu Serif</family>
  5.           <family>Bitstream Vera Sans</family>
  6.           <family>Arial</family>
  7.           <family>Verdana</family>
  8.           <family>Helvetica</family>
  9.           <family>AR PL New Sung</family>
  10.           <family>SimSun</family>
  11.           <family>Luxi Serif</family>
  12.           <family>Ming(ISO10646)</family>
  13.           <family>AR PL kaitiM Big5</family>
  14.           <family>AR PL kaitiM GB</family>
  15.           <family>Kochi Gothic</family>
  16.           <family>Baekmuk Dotum</family>
  17.       </prefer>
  18.   </alias>
复制代码

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

重排monospace的字体显示顺序:

  1. <alias>
  2.       <family>monospace</family>
  3.       <prefer>
  4.          <family>Bitstream Vera Sans Mono</family>
  5.          <family>Courier New</family>
  6.          <family>Courier</family>
  7.          <family>AR PL New Sung</family>
  8.          <family>Ming(ISO10646)</family>
  9.          <family>Kochi Mincho</family>
  10.          <family>Baekmuk Batung</family>
  11.       </prefer>
  12.   </alias>
复制代码


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

  1. <match target="font">
  2.         <test name="family">
  3.                 <string>DejaVu Sans Mono</string>
  4.                 <string>Bitstream Vera Sans Mono</string>
  5.         </test>
  6.         ...
  7. </match>
复制代码


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

  1. <?xml version="1.0"?>
  2. <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
  3. <!-- /etc/fonts/local.conf file for local customizations -->
  4. <fontconfig>
  5. <!--
  6.   Enable sub-pixel rendering
  7.         <match target="font">
  8.                 <edit name="rgba" mode="assign"><const>rgb</const></edit>
  9.         </match>
  10. -->
  11. <!--
  12.   Add by Firefly(firefly@firefly.idv.tw)
  13. -->
  14.         <match target="font">
  15.                 <edit name="embeddedbitmap" mode="assign">
  16.                         <bool>true</bool>
  17.                 </edit>
  18.         </match>

  19. <!--
  20.   Add by Firefly(firefly@firefly.idv.tw)
  21.   Most of Asian fonts can't explain by freetype2,
  22.   so,if these fonts have dual width(half/full) and monospacing,
  23.   you need to disable globaladvance.
  24. -->
  25.         <match target="font">
  26.                 <test name="spacing" compare="more_eq">
  27.                         <const>mono</const>
  28.                 </test>
  29.                 <edit name="globaladvance" mode="assign">
  30.                         <bool>false</bool>
  31.                 </edit>
  32.         </match>

  33. <!--
  34. Add by firefly@firefly.idv.tw
  35. Artificial bold for fonts without a bold version.
  36. -->
  37.         <match target="font">
  38.                 <!-- check to see if the pattern requested > "medium" -->
  39.                 <test target="pattern" name="weight" compare="more">
  40.                         <const>medium</const>
  41.                 </test>
  42.                 <!-- pretend the font is bold now -->
  43.                 <edit name="weight" mode="assign">
  44.                         <const>bold</const>
  45.                 </edit>
  46.         </match>
  47. <!--
  48.   Add by firefly@firefly.idv.tw
  49. -->
  50.         <match target="pattern">
  51.                 <test name="lang" compare="contains">
  52.                         <string>zh-tw</string>
  53.                         <string>zh-cn</string>
  54.                         <string>zh-hk</string>
  55.                         <string>zh-mo</string>
  56.                         <string>zh-sg</string>
  57.                         <string>zh</string>
  58.                         <string>ja</string>
  59.                         <string>ko</string>
  60.                 </test>
  61.                 <edit name="hinting" mode="assign">
  62.                         <bool>true</bool>
  63.                 </edit>
  64.                 <edit name="usegamma" mode="assign">
  65.                     <if>
  66.                         <less>
  67.                                 <name>pixelsize</name>
  68.                                 <double>20</double>
  69.                         </less>
  70.                     </if>
  71.                     <bool>true</bool>
  72.                 </edit>
  73.         </match>
  74. <!--........................................................................-->       
  75.         <config>
  76. <!--
  77.   Add by Firefly (firefly@firefly.idv.tw)
  78.   Output non English/Latin family name.
  79. -->
  80.                 <familyoutput>
  81.                         <const>auto</const>
  82.                         <!--const>englishonly</const-->
  83.                         <!--const>any</const-->
  84.                 </familyoutput>
  85.         </config>
  86. <!--.......................................................................-->
  87. <!--
  88.   Add by EricNeon (ericneon@geekbone.org)
  89. Disable Chinese fonts Anti-Alias in 8px-16px.
  90. -->
  91.         <match target="font">
  92.                   <test name="pixelsize" compare="more_eq">
  93.                          <double>8</double>
  94.                 </test>
  95.                   <test name="pixelsize" compare="less_eq">
  96.                          <double>16</double>
  97.                 </test>
  98.                 <edit name="antialias">
  99.                         <bool>false</bool>
  100.                 </edit>
  101.                 <edit name="hinting">
  102.                         <bool>true</bool>
  103.                 </edit>
  104.         </match>

  105. </fontconfig>
复制代码

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

  1. case "$LANG" in
  2. zh_CN*)
  3.         /usr/bin/scim -d(或fcitx &)
  4.         XMODIFIERS=@im=scim(或fcitx)
  5.         GTK_IM_MODULE=scim(或fcitx)
  6.         ;;
  7. zh_TW*)
  8.        /usr/bin/scim -d(或fcitx &)
  9.         XMODIFIERS=@im=scim(或fcitx)
  10.         GTK_IM_MODULE=scim(或fcitx)
  11.         ;;
  12. zh_HK*)
  13.         /usr/bin/scim -d(或fcitx &)
  14.         XMODIFIERS=@im=scim(或fcitx)
  15.         GTK_IM_MODULE=scim(或fcitx)
  16.         ;;
  17. esac
  18. export XMODIFIERS GTK_IM_MODULE
  19. export LANG=zh_CN.UTF-8  (如果你没有设置locale=zh_CN.UTF-8)
  20. export G_FILENAME_ENCODING=@UTF-8
复制代码


现在你可以到你的桌面下去看看效果了,无论是使用startx还是用gdm、xdm、kdm等启动桌面,都不需要另外再设置locale和输入法。
发表于 2005-3-9 21:05:57 | 显示全部楼层
请问ttf-dejavu msttcorefonts在哪个源?
回复 支持 反对

使用道具 举报

发表于 2005-3-9 21:11:16 | 显示全部楼层
是否适用于fvwm上?
回复 支持 反对

使用道具 举报

发表于 2005-3-9 21:14:36 | 显示全部楼层
Post by 线头
是否适用于fvwm上?

正是我想问的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-9 21:16:18 | 显示全部楼层
手头没有/etc/apt/sources.list的完整文件,我现在隔壁的机器里。

同样适用fvwm和gnome、openbox、fluxbox、xfce,KDE应该也没有问题。
回复 支持 反对

使用道具 举报

发表于 2005-3-9 21:21:18 | 显示全部楼层
先谢了,等会试试
看来那个firefly字体和fontconfig是关键,从没用过firefly的patch,不是说不好,就怕补来补去的麻烦,debian怎么不把那些patch包括进去啊,真是
回复 支持 反对

使用道具 举报

发表于 2005-3-9 21:32:12 | 显示全部楼层
不错的东东。虽然没有试过。很好。加精吧。伙计们。
回复 支持 反对

使用道具 举报

发表于 2005-3-9 21:34:09 | 显示全部楼层
我给了5分
回复 支持 反对

使用道具 举报

发表于 2005-3-9 22:05:23 | 显示全部楼层
这里的

  1. /usr/bin/scim -d(或fcitx &)
  2.   XMODIFIERS=@im=scim(或fcitx)
  3. GTK_IM_MODULE=scim(或fcitx)
复制代码


是否要把 /usr/bin/scim -d(或fcitx &) 放到后面
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-9 22:33:04 | 显示全部楼层
不需要把 /usr/bin/scim -d(或fcitx &) 放到后面,这个文件只是在启动X时执行,但并不是完全按顺序执行。几个export放在最前面也一样。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表