This document may contain examples in another language or script.

Use accesskey "n" to jump to the internal navigation links at any point. Right now you can

 
ishida >> writing

Automatic font assignment for CJK text

Some browsers apply the fonts listed in the user font preferences to the display of HTML Unicode text in Traditional Chinese, Simplified Chinese, Japanese and Korean, depending on the setting of the lang/xml:lang attribute. Note that this is not specified in the HTML specification, and, of course, doesn't apply where explicit styling is applied.

I wrote a test for this. The test assumes that different default fonts are assigned in the browser's font preferences for Simplified Chinese, Traditional Chinese, Japanese, and Korean (so that you can tell the difference). The test is written in XHTML 1.0 and served as text/html.

Here is a summary of the results of some brief testing of mainstream browsers on Windows XP. I may update this as additional information becomes available.

Results

nonezhzh-CNzh-Hanszh-TWzh-HKzh-Hantjako
Firefox 0.9.3JASCSCSCTCTCSCJAKO
Mozilla 1.7.2JASCSCSCTCTCSCJAKO
IE 6.0JASCSCJATCSCJAJAKO
Navigator 7.1XSCSCSCTCSCSCJAKO
Opera 7.54KOKOKOKOKOKOKOKOKO

The titles across the top indicate the language attribute declared for a paragraph containing Han text. The results show which font was applied. JA = Japanese, SC = Simplified Chinese, TC = Traditional Chinese, KO = Korean, X = a totally different font.

Points of note

Opera doesn't play this game at all.

The default Han font for Firefox and IE is Japanese, but for Netscape it is a completely different font than any set for the CJK languages.

zh-Hans and zh-Hant take on the zh font in Firefox, Netscape and Mozilla, but are not recognised at all in IE and take the Japanese default. Note that there is a bugfix in place for Mozilla that will handle zh-Hans and zh-Hant properly.

IE uses a Simplified Chinese font for zh-HK.

Tip: how to make it work on Firefox, Mozilla and Netscape

If you are desperate to make this work, and can't wait for the fix in (I believe) the next version of Mozilla, you can try this hack.

Open the 'res' subdirectory of your mozilla installation directory and find the file langGroups.properties. Open the file and add the two lines:

zh-hans=zh-CN
zh-hant=zh-TW

Links

Author: Richard Ishida.

Valid XHTML 1.0!
Valid CSS!
Encoded in UTF-8!

Content created 13 July, 2004. Last update 2004-08-09 21:11 GMT