星期一, 6月 04, 2007

換上了 opendesktop-fonts 及 DejaVu

幾年來一直沿用2004年的字型設定, 除了因為自己懶外, 也是沒有需要。Gentoo 由 2005.0 > 2005.1 > 2006.0 > 2006.1 > 2007.0 的升級都沒有出現過什么意外, 也就不會去去動那些設定檔。這段時間看到了 DejaVu fontsopendesktop-fonts 字型的相繼推出, 才想到也是時候更新一下了。

現在的 fontconfig 多了兩目錄以增加設定的彈性, 見 /etc/fonts :
conf.d {啟用的設定檔}
conf.avail {全部可用的設定檔}

其中 conf.d 的內容多是 conf.avail 的 soft link, 連結了就代表啟用, 刪掉了連結就是停用, 方便吧 ?! 更多關於 conf.d 設定檔的說明可以查看 /etc/fonts/conf.avail/README

conf.d/README

Each file in this directory is a fontconfig configuration file. Fontconfig
scans this directory, loading all files of the form [0-9][0-9]*. These files
are normally installed in ../conf.avail and then symlinked here, allowing
them to be easily installed and then enabled/disabled by adjusting the
symlinks.

The files are loaded in numeric order, the structure of the configuration
has led to the following conventions in usage:

Files begining with: Contain:

00 through 09 Font directories
10 through 19 system rendering defaults (AA, etc)
10-autohint.conf
10-no-sub-pixel.conf
10-sub-pixel-bgr.conf
10-sub-pixel-rgb.conf
10-sub-pixel-vbgr.conf
10-sub-pixel-vrgb.conf
10-unhinted.conf
20 through 29 font rendering options
20-fix-globaladvance.conf
20-lohit-gujarati.conf
20-unhint-small-vera.conf
30 through 39 family substitution
30-urw-aliases.conf
30-amt-aliases.conf
40 through 49 generic identification, map family->generic
40-generic-id.conf
49-sansserif.conf
50 through 59 alternate config file loading
50-user.conf Load ~/.fonts.conf
51-local.conf Load local.conf
60 through 69 generic aliases
60-latin.conf
65-fonts-persian.conf
65-nonlatin.conf
69-unifont.conf
70 through 79 select font (adjust which fonts are available)
70-no-bitmaps.conf
70-yes-bitmaps.conf
80 through 89 match target="scan" (modify scanned patterns)
80-delicious.conf
90 through 98 font synthesis
90-synthetic.conf


從 50-user.conf 及 51-local.conf 的說明得知, 固有的 ~/.fonts.conf 及 /etc/fonts/local.conf 設定檔還是有效的, 所以我 2004 年的那個設定檔也一直有效, Linux 真的很可愛呢 :)

新的設定 "借用" 了 ubuntu 的設定檔, 所以很快便完成了更新。下面貼上我的 local.conf 內容, 留意套用前需確保安裝了以下字型 :
opendesktop-fonts
arphic-uming
wqy-bitmapfont
DejaVu fonts

<fontconfig>
<alias>
<family>MingLiU</family>
<accept><family>AR PL New Sung</family></accept>

</alias>
<alias>
<family>細明體</family>
<accept><family>AR PL New Sung</family></accept>

</alias>
<alias>
<family>PMingLiU</family>
<accept><family>AR PL New Sung</family></accept>

</alias>
<alias>
<family>新細明體</family>
<accept><family>AR PL New Sung</family></accept>

</alias>
<alias>
<family>SimSun</family>
<accept><family>WenQuanYi Bitmap Song</family></accept>

</alias>
<alias>
<family>宋体</family>
<accept><family>WenQuanYi Bitmap Song</family></accept>

</alias>
<alias>
<family>標楷體</family>
<accept><family>AR PL ZenKai Uni</family></accept>

</alias>

<alias>
<family>serif</family>
<prefer>
<family>DejaVu Serif</family>

<family>Bitstream Vera Serif</family>
<family>AR PL New Sung</family>
<family>AR PL ShanHeiSun Uni</family>
<family>WenQuanYi Bitmap Song</family>

<family>AR PL ZenKai Uni</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>

<prefer>
<family>DejaVu Sans</family>
<family>Bitstream Vera Sans</family>
<family>AR PL New Sung</family>

<family>AR PL ShanHeiSun Uni</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ZenKai Uni</family>
</prefer>

</alias>
<alias>
<family>monospace</family>
<prefer>
<family>DejaVu Sans Mono</family>

<family>Bitstream Vera Sans Mono</family>
<family>AR PL New Sung Mono</family>
<family>AR PL ShanHeiSun Uni</family>
<family>WenQuanYi Bitmap Song</family>

<family>AR PL ZenKai Uni</family>
</prefer>
</alias>

<match target="font" >
<test name="family" compare="contains" >

<string>Song</string>
<string>Sun</string>
<string>Kai</string>
<string>Ming</string>

</test>
<!-- check to see if the font is just regular -->
<test name="weight" compare="less_eq">
<int>100</int>
</test>
<test compare="more_eq" target="pattern" name="weight" >

<int>180</int>
</test>
<edit mode="assign" name="embolden" >
<bool>true</bool>
</edit>

</match>

<match target="font" >
<test name="family" compare="contains" >
<string>Song</string>
<string>Sun</string>

<string>Ming</string>
</test>
<edit name="globaladvance">
<bool>false</bool>
</edit>

<edit name="spacing">
<int>0</int>
</edit>
<edit name="hinting">
<bool>true</bool>

</edit>
<edit name="autohint">
<bool>false</bool>
</edit>
<edit name="antialias" mode="assign">

<bool>true</bool>
</edit>
<test compare="more_eq" name="pixelsize">
<double>9</double>
</test>

<test compare="less_eq" name="pixelsize">
<double>16</double>
</test>
<edit name="antialias" mode="assign" >
<bool>false</bool>

</edit>
</match>
</fontconfig>


下面是兩張前后比較圖, 首先是舊版的 fireflysung :



然后是 opendesktop-fonts 的效果 :



新版的 opendesktop-fonts 字體橫了, 不像以往的瘦瘦高高, 現在是方方正正, 更像新細明體。而DejaVu 就沒有看出那裡跟 Bitstream 不一樣 :P

Linux 字型設定是比較深入的技巧, 沒有經過 2003-2004 或更早的中文設定的磨練過的話可能會較難上手, 所以希望下次再由理論開始講講。

2 則留言:

Hydonsingore 提到...

本來Bitstream Vera只包含英文字母和很少量的符號而已,DejaVu則增加了很多拉丁字母(像是áāûøþß)和其他的符號,而且在包含種類和每個字的外觀方面都持續有在改進。

semson 提到...

謝謝Hydonsingore的指教, 剛才看了DejaVu的主頁, 說 "maintaining the original look and feel", 這也就解析了常用字看不分別的原因了。