There are quite a number of different ways you can set up your Linux to read and write Chinese. Most mordern Linux distributions come with Chinese font by default (at least some GB2312 fonts), and browsing Chinese web sites is no long an issue.
Here is one example of setting a Chinese system for input under Slackware 9.0.
~/.bashrc
to haveexport XMODIFIERS=@im=fcitx
unset LC_ALL
~/.Xclients
before your favorite window manager’s starts.LC_ALL=zh_CN.GB2312 fcitx
LC_ALL=zh_CN.GB2312 mlterm
LC_ALL=zh_CN.GB2312 opera
LANG=zh_CN.GB2312 mozilla
Please note that all the LC_ALL
and LANG
stuff in the above is a bit hackish. On Redhat Linux 9, you simply need LANG=zh_CN.GB2312 mlterm
to enable Chinese input via fcitx in mlterm. But somehow, it doesn’t work in Slackware 9.0, so I’m forced to use LC_ALL=zh_CN.GB2312 mlterm
to start mlterm and reset LC_ALL
in my .bashrc
so that the usual date and locale settings are still English. It is also wierd that opera must be started with LC_ALL
to receive Chinese input, while mozilla can do with only LANG
setting. I also notice some wierdness of readline
in bash
under Redhat Linux 9.0, it no longer allows 8-bit clean inputs under its default locale setting.
In short, you may always try the LANG
setting first, as it is the most non-intrusive. If that fails, then try LC_ALL
setting. If you still prefer English environment and just want Chinese input only, you may reset LC_ALL
in ~/.bashrc
.
To input Chinese on normal command line under bash
, the simple way is just
export LC_ALL=zh_CN.GB2312
This will change how ls
sorts its output too. If that doesn’t work for you, try this too:
cat > ~/.inputrc << END
set meta-flag On
set convert-meta Off
set output-meta On
END
This is a setup for readline to accept 8-bit characters. On Slackware 9.0, the ~/.inputrc
file alone works fine for me, but seems that on Redhat 9.0, the only way to do it is to set the LC_ALL
.
I used to have Cxterm as a Chinese environment, but no longer.
There is a CJK Package for Latex, and you’ll need to set up Chinese fonts for Latex separately. Most guides I found on the web are overly complex, but it’s rather simple to setup once you understand what it needs. The following is done under tetex-3.0
, but may also apply to other Latex environments.
For font installation, I use a tool called gbkfonts
(not sure about its origin, but I got one from He Bo Liang’s homepage). I use the statically compiled version without going through the compilation.
Then you’ll need a set of Chinese Truetype fonts. I use the Microsoft YaHei font from Vista. Here is an example of what I do.
Download the latest CJK package. For example, I use cjk-4.7.0.tgz. Become root and do:
TEXDIR=/usr/share/texmf-local # or you can use /usr/share/texmf
mkdir -p $TEXDIR/tex/latex
tar zxf cjk-4.7.0.tar.gz
mv cjk-4.7.0/texinput $TEXDIR/tex/latex/CJK
Copy gbkfonts
binary and your Truetype fonts to a temporary directory, become root and do the following
./gbkfonts msyh.ttf yahei # repeat it if you have more fonts
mkdir -p $TEXDIR/fonts/afm $TEXDIR/fonts/tfm $TEXDIR/fonts/type1 $TEXDIR/fonts/map/chinese
mv ./tex/latex/CJK/GB/* $TEXDIR/tex/latex/CJK/GB/
mv ./fonts/afm/chinese $TEXDIR/fonts/afm/
mv ./fonts/tfm/chinese $TEXDIR/fonts/tfm/
mv ./fonts/type1/chinese $TEXDIR/fonts/type1/
mv cjk.map $TEXDIR/fonts/map/chinese/
echo "Map cjk.map" >> /usr/share/texmf/web2c/updmap.cfg
The above installs the font metrics and the Type1 fonts with tetex and CJK, and then updates the map file setting to let it find them. You don’t even need the TTF file to be installed with tetex if you are not going to use dvipdfmx.
After the above setup, you may refresh tetex by:
texhash
updmap-sys # do this as root, or updmap as an user
For a test, you may write a Tex document like this: