Showing posts with label fontconfig. Show all posts
Showing posts with label fontconfig. Show all posts

Sunday, November 02, 2008

No more shitty Chinese/Japanese display font

This is sort of a follow up to my previous blog post on fontconfig, and also part of my efforts in making the EeePC a simple-to-use and pretty (in my own view) PC.

With such a small screen and fonts, complicated Chinese characters will be rendered as unintelligible white space with black dots when using Sung/Ming fonts (宋体,明体). In this case, Gothic/Hei fonts (serif equivalent to East Asian font) are very readable as it is capable to be rendered even with small font sizes. In this case, WenQuanYi's Zen Hei is the best open source Gothic/HeiTi font (and I even highlighted it in one of my post).

For this setup, I make it more simplistic: Copy a good template which specifies preferred Latin fonts (e.g. /etc/fonts/conf.d/60-latin.conf in Debian) to ~/.fonts.conf. Once that's in place: paste <family>WenQuanYi Zen Hei</family> in each <prefer> section.

Once that's in place, execute `fc-cache -fv` and restart your applications, and TADA! browsing Chinese sites on Firefox has never been more enjoyable with unified and readable text :D.

Monday, November 12, 2007

No More Hard-to-Read Chinese Text!

NEWS: Currently the font is included in the Ubuntu Hardy Heron repository! Install the "ttf-wqy-zenhei" package

Recently I have been continually fine-tuning my Ubuntu to give me the best (i.e. most comfortable) environment for me to work with. One of the major quirks is the hard to read Chinese fonts, which is due to the fact that it's pretty hard to hint SongTi (宋体) fonts.

Somehow it's pretty surprising that Ubuntu's repositories doesn't come with HeiTi (黑体) or Chinese Gothic fonts, which has thicker strokes. But luckily there's this open source, GPL'ed font foundary, Wen Quan Yi, which does provide their HeiTi variant called "Zen Hei". Basically what I do is grab the package, install the Debian package (execute `dpkg --install wqy-zenhei-0.2.15-1.deb`), adding the configuration to match the font in my /etc/fonts/local.conf file (see my previous article for details) and lastly execute `sudo fc-cache -fv`.

Once I done that and restart my applications, now I had 100% reliable and perfectly readable Chinese pages! :D

Monday, July 30, 2007

Solving unreadable Simplified Chinese text on Gentoo

It's been a while I have been facing font display issues with Simplified Chinese text in my Gentoo machine. Main reason being the fact that without special fontconfig configuration, it tends to mix Sungti (宋体) and Kaiti (楷体) fonts to display Simplify Chinese text. Not only it's aesthetically unpleasing to see two different fonts on the same line, Kaiti is extremely hard to read under small font sizes due to font hinting. Worst being sometimes you can only see a character space filled random pixels (due to the line too thin to be rendered on screen after hinting) and it's pretty annoying to enlarge your font-sizes just to read those characters.

The solution can be found in this Chinese article that I had found online. For those who aren't all that proficient in Chinese, here's my own translation to it:


Title: Font problem in Gentoo

by yangtse (?)

Q: I'm using SimSun font in my Gentoo machine. But I don't like how the English alphabets looked in SimSun, is it possible to set the English alphabets to be displayed using other fonts, while still having Chinese characters displayed using SimSun font?

A: Yes. That's how it's usually done. But most users don't use SimSun; use Uming and WenQuanYi instead.

In /etc/fonts/local.conf, configure the fonts that you wanted in the serif, sans-serif and monospace font family: Specifying your font of choice for Roman characters first, then specify the Chinese fonts that you wanted next. Then configure KDE or GNOME to use these fonts as the default display font.

Please refer to my /etc/fonts/local.conf configuration:

<?xml version="1.0"?>
<fontconfig>
<alias>
<family>serif</family>
<prefer>
<family>Bitstream Vera Serif</family>
<family>DejaVu Serif</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>Bitstream Vera Sans</family>
<family>DejaVu Sans</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>Bitstream Vera Sans Mono</family>
<family>DejaVu Sans Mono</family>
<family>AR PL ShanHeiSun Uni</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ZenKai Uni</family>
</prefer>
</alias>
<match target="font">
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
<edit mode="assign" name="autohint">
<bool>false</bool>
</edit>
<edit name="hinting">
<bool>true</bool>
</edit>
</match>
<match target="font">
<test name="family" compare="contains">
<string>Song</string>
<string>Sun</string>
<string>Kai</string>
<string>Ming</string>
</test>
<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>Kai</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 name="pixelsize" compare="less_eq">
<int>18</int>
</test>
<edit name="antialias" mode="assign">
<bool>false</bool>
</edit>
</match>
</fontconfig>

Q: Where can I find these fonts?
A: Please emerge these packages: media-fonts/wqy-bitmapfont, media-fonts/arphicfonts



Additional steps

Once you have copied and saved the above /etc/fonts/local.conf file, perform the following command to refresh the font cache:
fc-cache -fv

You'd have to restart your applications in order to see the effect.

[Original article link]