2006年3月3日

Put Chinese fonts in front of Japanese fonts in fontconfig
中文字型优先,日文字型靠后

On Debian systems, when both Chinese and Japanese fonts are installed, the Japanese fonts will have the priority being used in front of the Chinese ones. The result is that the Serif and Sans-Serif fonts will be totally messed with ugly Japanese glyphs under a Chinese locale. You would think that fontconfig can select the right fonts accroding the current locale. :(



The solution? Using a ~/.fonts.conf file to set Chinese font as the preferred one for Serif and Sans-Serif. Direct editing /etc/fonts/fonts.conf will has your settings reset on upgrade. For a system-wised customization, do it in /etc/fonts/local.conf, this is on a Debian box.



Another advantage on using ~/.fonts.conf is that you might have users using different locales (hint: Japanese) on the same box. You don't want to interfere with other people's fonts.



修改 ~/.fonts.conf 文件,提高中文字型在系统字型中的优先次序。
简单来说,/etc/fonts/fonts.conf 会先加载我们的 ~/.fonts.conf ,然后才设定系统字型(Serif, Sans-Serif)的组合字型的优先次序。我们先设定了,系统的就在我们屁股后面了。



Use the following command to find out fonts that fontconfig knows:

使用以下命令列出系统中的字型:


$ fc-list




<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- ~/.fonts.conf file to configure user font access -->
<fontconfig>
<alias>
<family>serif</family>
<prefer>
<family>Bitstream Vera Serif</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL ShanHeiSun Uni MBE</family>
</prefer>
</alias>

<alias>
<family>sans-serif</family>
<prefer>
<family>Bitstream Vera Sans</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL ShanHeiSun Uni MBE</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Bitstream Vera Sans Mono</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL ShanHeiSun Uni MBE</family>
</prefer>
</alias>
</fontconfig>


We put the Bitsteam serie fonts in front of our Chinese fonts because we don't want to see westen alphabetic glyphs from our Chinese fonts.