2006-07-30 00:25 把中文Windows字型帶到 Ubuntu 上來...
看到蠻多人都會對於 Ubuntu 上的中文字型有一些意見,所以在這裡分享我的最新作法(在 Ubuntu Dapper 下)
首先,我會在 $HOME 目錄下(假設我的帳號是 ericsk,那就是 /home/ericsk)建立一個 .fonts 的目錄(不要忘記前面有個 . ),然後把 Windows 下需要的字型檔放到裡面來,我的會則會拿下列檔案來用:
arialbd.ttf arialbi.ttf ariali.ttf arial.ttf courbd.ttf courbi.ttf couri.ttf cour.ttf mingliu.ttc timesbd.ttf timesbi.ttf timesi.ttf times.ttf
這些字型檔原本都是存在 C:WINDOWSFonts 下面的。然後,再在 $HOME 目錄下建立一個 .fonts.conf 的檔案,內容如下:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- MicroSoft mingliu.ttc -->
<match target="font">
<test name="family"><string>MingLiU</string></test>
<edit name="antialias"><bool>false</bool></edit>
<edit name="hinting"><bool>true</bool></edit>
<edit name="autohint"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>MingLiU</string></test>
<test name="pixelsize" compare="more_eq"><int>17</int></test>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
</match>
<match target="font">
<test name="family"><string>細明體</string></test>
<edit name="antialias"><bool>false</bool></edit>
<edit name="hinting"><bool>true</bool></edit>
<edit name="autohint"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>細明體</string></test>
<test name="pixelsize" compare="more_eq"><int>17</int></test>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
</match>
<match target="font">
<test name="family"><string>PMingLiU</string></test>
<edit name="antialias"><bool>false</bool></edit>
<edit name="hinting"><bool>true</bool></edit>
<edit name="autohint"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>PMingLiU</string></test>
<test name="pixelsize" compare="more_eq"><int>17</int></test>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
</match>
<match target="font">
<test name="family"><string>新細明體</string></test>
<edit name="antialias"><bool>false</bool></edit>
<edit name="hinting"><bool>true</bool></edit>
<edit name="autohint"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>新細明體</string></test>
<test name="pixelsize" compare="more_eq"><int>17</int></test>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
</match>
<match target="font">
<test name="family"><string>MingLiU</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
<!-- check to see if the font is just regular -->
<test name="weight" compare="less_eq">
<int>100</int>
</test>
<!-- check to see if the pattern requests bold -->
<test target="pattern" name="weight" compare="more_eq">
<int>180</int>
</test>
<!-- set the embolden flag -->
<edit name="embolden" mode="assign">
<bool>true</bool>
</edit>
</match>
<alias>
<family>serif</family>
<prefer>
<famliy>DejaVu Serif</family>
<family>MingLiU</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<famliy>DejaVu Sans</family>
<family>MingLiU</family>
</prefer>
</alias>
</fontconfig>
這樣,再到終端機執行一次:
sudo fc-cache -f -v
然後重新啟動 X 視窗環境(最簡單的最作法是登出再登入)就可以看到效果了!
不過我目前試驗的結果,用細明體來當中文字的話好像有時候會掉字,據說是 cairo 的 bug 。


