在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>mingliu</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的字體)以及mingliu的中文效果最好,所以排在所有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>mingliu</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'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和輸入法。