1. 程式人生 > >FreeBSD/Linux的中文字型美化

FreeBSD/Linux的中文字型美化

網上太多此類的文章了,且記下自己用的方法,以備日後參考!

首先當然是要挖出Windows中所使用的TrueType字型了,列表如下:

courbd.ttf
courbi.ttf
couri.ttf
cour.ttf
simsun.ttf  <-- 宋體,原本為simsun.ttc,請修改副檔名為ttf
tahomabd.ttf
tahoma.ttf
verdanab.ttf
verdanai.ttf
verdana.ttf


將上面這些檔案放到這裡:

[[email protected] /tmp] # cd /usr/share/fonts
[
[email protected] /usr/share/fonts] # mkdir local
[[email protected]
/usr/share/fonts] # cd local
[root@redhat /usr/share/fonts/local] # cp /tmp/*.ttf ./


重新整理字型快取:

[
[email protected]
/usr/share/fonts/local] # fc-cache -fv
fc-cache: "/usr/share/fonts": caching, 0 fonts, 6 dirs
fc-cache: "/usr/share/fonts/bitmap-fonts": caching, 32 fonts, 0 dirs
fc-cache: "/usr/share/fonts/zh_TW": caching, 0 fonts, 1 dirs

fc-cache: "/usr/share/fonts/zh_TW/TrueType": caching, 2 fonts, 0 dirs
fc-cache: "/usr/share/fonts/local": caching, 11 fonts, 0 dirs
fc-cache: "/usr/share/fonts/default": caching, 0 fonts, 2 dirs
fc-cache: "/usr/share/fonts/default/ghostscript": caching, 8 fonts, 0 dirs
fc-cache: "/usr/share/fonts/default/Type1": caching, 35 fonts, 0 dirs

fc-cache: "/usr/share/fonts/zh_CN": caching, 0 fonts, 1 dirs
fc-cache: "/usr/share/fonts/zh_CN/TrueType": caching, 3 fonts, 0 dirs
fc-cache: "/usr/share/fonts/bitstream-vera": caching, 10 fonts, 0 dirs
fc-cache: "/usr/X11R6/lib/X11/fonts/Type1": caching, 29 fonts, 0 dirs
fc-cache: "/usr/X11R6/lib/X11/fonts/OTF": caching, 0 fonts, 0 dirs
fc-cache: "/root/.fonts": skipping, no such directory
fc-cache: succeeded


生成fonts.dir和fonts.scale檔案:

[
[email protected]
/usr/share/fonts/local] # ttmkfdir -d ./ -o fonts.dir
[[email protected]/usr/share/fonts/local] # vi fonts.dir


記著把fonts.dir複製一份,並更名為fonts.scale

接下來我們需要修改/etc/fonts/local.conf來調整中英文顯示的優先順序:

[[email protected]/etc/fonts] # vi local.conf


內容如下:


<fontconfig><!--//
===============================
Linux Dist: Ubuntu 7.04 Feisty
===============================
fontconfig: 2.4.2-1ubuntu1
freetype: 2.2.1-5ubuntu1.1
libxft: 2.1.12-1
xorg: 7.2-0ubuntu11
==============================
file: ~/.fonts.conf
version: 20070606 final
//
--><!--// 對字型簇中的字型進行重新排序 //--><alias><family>serif</family><prefer><family>Bitstream Vera Serif</family><family>DejaVu Serif</family><family>SimSun</family><family>MingLiu</family><family>WenQuanYi Bitmap Song</family></prefer></alias><alias><family>sans-serif</family><prefer><family>Tahoma</family><family>Bitstream Vera Sans</family><family>DejaVu Sans</family><family>SimSun</family><family>MingLiu</family><family>WenQuanYi Bitmap Song</family></prefer></alias><alias><family>monospace</family><prefer><family>Bitstream Vera Sans Mono</family><family>DejaVu Sans Mono</family><family>SimSun</family><family>MingLiu</family><family>WenQuanYi Bitmap Song</family></prefer></alias><!--// 字型別名的設定-01 //--><!--// 這段的設定測試的時候發現並沒有起作用,但還是留著,作為01部分。 //--><alias><family>SimSun</family><accept><family>宋體</family></accept></alias><alias><family>NSimSun</family><accept><family>新宋體</family></accept></alias><alias><family>SimHei</family><accept><family>黑體</family></accept></alias><alias><family>Microsoft YaHei</family><accept><family>微軟雅黑</family></accept></alias><alias><family>FangSong_GB2312</family><accept><family>仿宋</family><family>仿宋_GB2312</family></accept></alias><alias><family>KaiTi_GB2312</family><accept><family>楷體</family><family>楷體_GB2312</family></accept></alias><alias><family>YouYuan</family><accept><family>幼圓</family></accept></alias><alias><family>MingLiU</family><accept><family>細明體</family></accept></alias><alias><family>PMingLiU</family><accept><family>新細明體</family></accept></alias><!--// 字型的別名設定-02 //--><!--// 下面這段設定是可以work的,所以放在後面作為02部分。 //--><match target="pattern"><test name="family"><string>宋體</string></test><edit name="family" mode="assign"><string>SimSun</string></edit></match><match target="pattern"><test name="family"><string>新宋體</string></test><edit name="family" mode="assign"><string>NSimSun</string></edit></match><match target="pattern"><test name="family"><string>細明體</string></test><edit name="family" mode="assign"><string>MingLiU</string></edit></match><match target="pattern"><test name="family"><string>新細明體</string></test><edit name="family" mode="assign"><string>PMingLiU</string></edit></match><match target="pattern"><test name="family"><string>黑體</string></test><edit name="family" mode="assign"><string>SimHei</string></edit></match><match target="pattern"><test name="family"><string>微軟雅黑</string></test><edit name="family" mode="assign"><string>Microsoft YaHei</string></edit></match><match target="pattern"><test name="family"><string>仿宋</string></test><edit name="family" mode="assign"><string>FangSong_GB2312</string></edit></match><match target="pattern"><test name="family"><string>仿宋_GB2312</string></test><edit name="family" mode="assign"><string>FangSong_GB2312</string></edit></match><match target="pattern"><test name="family"><string>楷體</string></test><edit name="family" mode="assign"><string>KaiTi_GB2312</string></edit></match><match target="pattern"><test name="family"><string>楷體_GB2312</string></test><edit name="family" mode="assign"><string>KaiTi_GB2312</string></edit></match><match target="pattern"><test name="family"><string>幼圓</string></test><edit name="family" mode="assign"><string>YouYuan</string></edit></match><!--// 所有字型關於AA、Hint、AutoHint的預設全域性設定 //--><!--// 注意沒有指定hintstyle,不希望它作為全域性設定 //--><match target="font"><edit name="hinting" mode="assign"><bool>true</bool></edit><edit name="autohint" mode="assign"><bool>true</bool></edit><edit name="antialias" mode="assign"><bool>true</bool></edit></match><!--// CJK字型關於AA、Hint、AutoHint的設定 //--><!--// 注意沒有指定hintstyle,不希望它作為全域性設定 //--><match target="font"><test name="lang" compare="contains"><string>zh</string><string>ja</string><string>ko</string></test><edit name="hinting" mode="assign"><bool>true</bool></edit><edit name="autohint" mode="assign"><bool>false</bool></edit><edit name="antialias" mode="assign"><bool>true</bool></edit></match><!--// CJK字型中hinting需要火力全開的字型 //--><!--// MingLiU/PMingLiU一定要全力hint,否則字會錯亂 //--><match target="font"><test name="family" compare="eq"><string>MingLiU</string><string>PMingLiU</string></test><edit name="hintstyle"><const>hintfull</const></edit></match><!--// 對CJK字型中8~18號的字型不做AA處理 //--><match target="font"><test name="lang" compare="contains"><string>zh</string><string>ja</string><string>ko</string></test><!--// 微軟雅黑字型需要啟用AA,故排除在外 //--><test name="family" qual="all" compare="not_eq"><string>Microsoft YaHei</string></test><test name="pixelsize" compare="more_eq"><int>8</int></test><test name="pixelsize" compare="less_eq"><int>18</int></test><edit name="antialias" mode="assign"><bool>false</bool></edit></match><!--// 禁止英文字型和CJK字型等寬 //--><match target="font"><test name="lang" compare="contains"><string>zh</string><string>ja</string><string>ko</string></test><