Monday, July 16, 2007

Chinese fonts in Linux ( blur when antialias is true )

If you install your Linux box with English as the primary language, you will notice the Chinese fonts are blurred and hard to read. That is due to anti-aliasing of Chinese characters. I would NOT recommend to disable all font anti-aliasing in Font Preferences, because anti-alias is good and it makes many fonts look easier for eyes, just not Chinese characters when they are small.

The solution is so set false for Chinese fonts under a specific font size. Create a file called local.conf under /etc/fonts/ directory
vi /etc/fonts/local.conf

and copy and paste the following to the file:
<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">

<fontconfig>

<!-- Disable font alias for Chinese <= 18px -->

<match target="font">

<test qual="any" name="family" compare="eq">

<string>AR PL Mingti2L Big5</string>

<string>AR PL SungtiL Big5</string>

<string>AR PL New Sung</string>

<string>AR PL ShanHeiSun Uni</string>

<string>AR PL ZenKai Uni</string>

<string>Ming(ISO10646)</string>

<string>MingLiu</string>

<string>PMingLiu</string>

<string>Kochi Mincho</string>

<string>Baekmuk Dotum</string>

</test>

<test name="pixelsize" compare="less_eq">

<double>18</double>

</test>

<edit name="antialias">

<bool>false</bool>

</edit>

<edit name="hinting">

<bool>true</bool>

</edit>

</match>

<alias>

<family>serif</family>

<prefer>

<family>Bitstream Vera Serif</family>

<family>Times New Roman</family>

<family>Times</family>

<family>AR PL New Sung</family>

<family>AR PL ShanHeiSun Uni</family>

<family>AR PL Mingti2L Big5</family>

<family>AR PL SungtiL GB</family>

<family>SimSun</family>

</prefer>

</alias>

<alias>

<family>sans-serif</family>

<prefer>

<family>Bitstream Vera Sans</family>

<family>Arial</family>

<family>Verdana</family>

<family>Helvetica</family>

<family>AR PL New Sung</family>

<family>AR PL ShanHeiSun Uni</family>

<family>AR PL kaitiM Big5</family>

<family>AR PL kaitiM GB</family>

</prefer>

</alias>

<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>AR PL ShanHeiSun Uni</family>

</prefer>

</alias>

</fontconfig>

3 comments:

M Henri Day said...

Thanks, Gideon, for the instructions above ! On my Ubuntu 7.04 setup, I don't seem to be having any problems with the blurring of Chinese glyphs, even small sizes, but one of the problems I do have is access to certain fonts, among them my particular favourite, PMingLiu. I should therefore like to try to follow your instructions, create the file you suggest, and then copy and paste the above list to it and see if it did not provide me with a greater range of fonts from which to choose, not least in OpenOffice. Alas, my Linux knowledge does not suffice for me to create the file «local.conf» under «etc/fonts». I tried typing «sudo gedit etc/fonts» and came to an empty file, but do not know how to proceed further. If you could find the time to write a brief (not *too* brief !) tutorial, I should be very grateful indeed !...

Henri

online education degrees said...

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I' ll be subscribing to your feed and I hope you post again soon.

php: transform chinese text into jpeg « Willing wheels said...

[...] http://gideontsang.wordpress.com/2007/07/16/chinese-fonts-in-linux-blur-when-antialias-is-true/ [...]