October 2004 - Posts

How to use Chinese characters in Athena: (5) Install Chinese Input Method

Note: Fcitx and SCIM are (what I believe) popular Chinese input methods for Linux. They are maintained actively and have been updated for several times since last year. Therefore their features may have already been a little different from what I describe here. For latest news and detailed document, please refer to their homepage.

I did not manage to install an early version of SCIM successfully in Athena. I have forgotten the exact reason, but I guess either it need to copy some files to a folder which I do not have write access right, or I have not configure it properly. The result was that after the installation I cannot bring up the input banner.

Then I turned to Fcitx. Through proper configuration, it can be installed to a local folder. And then by changing the language environment, I did make it run.

Installation of Fcitx is not difficult. Read the online documents for instructions on installation, download the source files, configure, compile (Make), and install it to some place in your home direcotry (e.g., ~/fcitx).

It's not suggested to use the RPM version directly, because we need root permission to install RPM.

After installing fcitx, we need to make some setting on the locale for it to run. I use the following script:

#!/bin/bash
LANG=zh_CN.gb18030
LC_ALL=zh_CN.gb18030
LC_CTYPE=zh_CN.gb18030
KDE_LANG=zh_CN.GB18030
export LANG LC_ALL LC_CTYPE KDE_LANG
export XMODIFIERS=@im=fcitx
fcitx &
#metacity&
#exec wmaker
#exec kde
#exec gnome-session
$1
killall fcitx

Save it as cfcitx.sh, add execute permission:

chmod u+x cfcitx.sh

Then we can use this script to run those programs in which we want to input Chinese characters. For example:

cfcitx gedit&

Here gedit is an editor that supports UTF-8, which helps to display Chinese characters correctly.

posted by wenyang with 0 Comments

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 by wenyang with 0 Comments