How to use Chinese characters in Athena: (4) Install TrueType Fonts

If you have TrueType Chinese fonts, you can install them in Athena. Then you will be able to use them in your GNOME desktop, or other X Window system.

Note:

  • Part of the method mentioned here comes from Athena online help consultant, while others come from various sources of internet.
  • This method might work with the Linux version of Athena only. Sun Solaris workstations usually have different settings.

Linux has several mechanisms to utilize TrueType fonts. Depending on how and where you want to use those fonts, you will need to do some or all of the following steps.

  1. First of all, of course, find some Chinese fonts. e.g., SimSun.ttf.

    Unfortunately, sometimes even this turns out to be difficult, since we do not have a "official" Simplified Chinese font that is free to all. The government of Hong Kong SAR, on the contrary, provides a version of Ming (for ISO 10646) Traditional Chinese font for free download. You can find it here, if the link is still valid.

  2. If you're using them in gtk2 applications you only need to dump those fonts in ~/.fonts as GNOME2 uses fontconfig to deal with fonts. Changes take effect immediately.

    One thing left to ensure: ~/.fonts should be world readable. To check, type

    fs la ~/.fonts/ |grep anyuser

    In the output, if you find (and you would, probably):

    system:anyuser l

    This means only the "list" permission is granted. You need to do:

    fs sa ~/.fonts system:anyuser read

    and you may execute "fs la ~/.fonts/ |grep anyuser" again to check the result. This time you should get:

    system:anyuser rl

  3. To install these fonts for all applications, things are a bit more complicated. After doing the above settings, we need to do the following in your terminal:

    cd ~/.fonts
    ttmkfdir -o fonts.dir
    cp fonts.dir fonts.scale
    (or make a symbolic link)
    mkfontdir

    In some cases, we might need to modify the fonts.dir and fonts.scale manually. Under such circumstance, remember to modify the number in the first line of fonts.dir to match the total number of records.

    • For SimSun.ttf, the fonts.dir created by ttmkfdir has a few lines that start with ":1:" (for NSimsun). They are prone to crashes. Remove those lines.
    • Another example for changing fonts.dir is listed as follows.

    If you need to use bold/italic SimSun fonts, then you may consider doing the following:

    Add the following (32 lines total, so remember to modify the numbers in the first line of fonts.dir):

    simsun.ttf -misc-simsun-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0
    ai=0.2:simsun.ttf -misc-simsun-medium-o-normal--0-0-0-0-c-0-gb2312.1980-0
    ai=0.4:simsun.ttf -misc-simsun-medium-i-normal--0-0-0-0-c-0-gb2312.1980-0
    ab=y:simsun.ttf -misc-simsun-bold-r-normal--0-0-0-0-c-0-gb2312.1980-0
    ai=0.2:ab=y:simsun.ttf -misc-simsun-bold-o-normal--0-0-0-0-c-0-gb2312.1980-0
    ai=0.4:ab=y:simsun.ttf -misc-simsun-bold-i-normal--0-0-0-0-c-0-gb2312.1980-0
    ai=-0.4:simsun.ttf -misc-simsun-medium-ri-normal--0-0-0-0-c-0-gb2312.1980-0
    ai=-0.4:ab=y:simsun.ttf -misc-simsun-bold-ri-normal-0-0-0-0-c-0-gb2312.1980-0
    ai=-0.2:simsun.ttf -misc-simsun-medium-ro-normal--0-0-0-0-c-0-gb2312.1980-0
    ai=-0.2:ab=y:simsun.ttf -misc-simsun-bold-ro-normal-0-0-0-0-c-0-gb2312.1980-0
    sw=1:bw=0.5:simsun.ttf -misc-simsun-medium-r-normal--0-0-0-0-c-0-iso8859-1
    simsun.ttf -misc-simsun-medium-r-normal--0-0-0-0-c-0-gbk-0
    ai=0.2:simsun.ttf -misc-simsun-medium-o-normal--0-0-0-0-c-0-gbk-0
    ai=0.4:simsun.ttf -misc-simsun-medium-i-normal--0-0-0-0-c-0-gbk-0
    ab=y:simsun.ttf -misc-simsun-bold-r-normal--0-0-0-0-c-0-gbk-0
    ai=0.2:ab=y:simsun.ttf -misc-simsun-bold-o-normal--0-0-0-0-c-0-gbk-0
    ai=0.4:ab=y:simsun.ttf -misc-simsun-bold-i-normal--0-0-0-0-c-0-gbk-0
    ai=-0.4:simsun.ttf -misc-simsun-medium-ri-normal--0-0-0-0-c-0-gbk-0
    ai=-0.4:ab=y:simsun.ttf -misc-simsun-bold-ri-normal--0-0-0-0-c-0-gbk-0
    ai=-0.2:simsun.ttf -misc-simsun-medium-ro-normal--0-0-0-0-c-0-gbk-0
    ai=-0.2:ab=y:simsun.ttf -misc-simsun-bold-ro-normal--0-0-0-0-c-0-gbk-0
    simsun.ttf -misc-simsun-medium-r-normal--0-0-0-0-c-0-iso10646-1
    ai=0.2:simsun.ttf -misc-simsun-medium-o-normal--0-0-0-0-c-0-iso10646-1
    ai=0.4:simsun.ttf -misc-simsun-medium-i-normal--0-0-0-0-c-0-iso10646-1
    ab=y:simsun.ttf -misc-simsun-bold-r-normal--0-0-0-0-c-0-iso10646-1
    ai=0.2:ab=y:simsun.ttf -misc-simsun-bold-o-normal--0-0-0-0-c-0-iso10646-1
    ai=0.4:ab=y:simsun.ttf -misc-simsun-bold-i-normal--0-0-0-0-c-0-iso10646-1
    ai=-0.4:simsun.ttf -misc-simsun-medium-ri-normal--0-0-0-0-c-0-iso10646-1
    ai=-0.4:ab=y:simsun.ttf -misc-simsun-bold-ri-normal--0-0-0-0-c-0-iso10646-1
    ai=-0.2:simsun.ttf -misc-simsun-medium-ro-normal--0-0-0-0-c-0-iso10646-1
    ai=-0.2:ab=y:simsun.ttf -misc-simsun-bold-ro-normal-0-0-0-0-c-0-iso10646-1
    simsun.ttf -misc-simsun-medium-r-normal-0-0-0-0-p-0-iso8859-15

    Then we run the following:

    xset fp+ ~/.fonts
    xset fp rehash

    It's also a good idea to restart X environment after those settings, at least you might immediately find out whether it works or not...

    This should work for many programs, hopefully.

  4. But for some programs (yes, it's not over yet), such as those using XTT, we still have to make some efforts, e.g., modify the /etc/X11/XF86Config-4 or /etc/X11/XF86Config (depending on what the system actually uses).
  5. Unfortunately, it's not always possible to do that, because on the public Athena workstations, those files are not in your locker; they are local files on the particular machine you are using. This means we need root permission to access these files. Even we know the root password (using tellme root) and modified those files, they are likely be changed back after we logout. To see which files and what to change, check the Linux forums, LinuxApp board at SMTH BBS, or Google.

Having install SimSun, you will be able to display GBK fontset in your web browser or other program, such as fcitx Chinese input method. Emacs can also be configured to make use of GBK characters.

posted on Monday, October 25, 2004 11:09 PM by wenyang

Comments