April 03, 2009

Note for installing Traditional Chinese in Lyx (1.6.2)

I recently updated my Lyx to 1.6.2 (released on March 15, 2009)
My operation system is Linux-Fedora Core 10, but I chose to compile the source code rather than using rpm
because the default coding scheming of rpm uses simplified Chinese font "song," which caused errors
when I use for traditional Chinese fonts like uming and ukai.

so, here are the steps for the installation.

1. download, compile and install lyx-1.6.2.tar.gz (note: you should have both qt and qt-devel packages to pass the configuration_

2. download and install texlive packages (use "yum")

3. download and install CJK package (cjk-4.8.2.tar.gz). Extract the file to the directory /usr/share/texmf/tex/latex/cjk.

4. download and install CJK unifornts (including AR PL UMing and AR PL Uaki).
RPM packages are also available (try cjkunifonts-ukai and cjkunifonts-uming).
These packages give you ttc files. But this ttc or ttf files are not what Lyx recognizes. Lyx need to find tmf files. (See Paul Johnson's notes).

5. transforming the ttc files into tfm files (the most difficult part in this process).
If you read Chinese, read this guide. Below is just a brief modification of the note.

5.1  install the package "fontforge"
5.2 download and extract this package font.tar.bz2 to your local folder, say, ~/font.
5.3 copy your ttc font files to ~/font.
5.4 transform the file from uming.ttc to tfm files (this took me about 4 hours):
time fontforge -script subfonts.pe uming.ttc uming Unicode.sfd
5.5 in the folder of ~/font, create a file called "makemap" with these lines in it.
for i in *.tfm
do
cat >> uming.map << EOF
${i%.tfm} ${i%.tfm} < ${i%.tfm}.pfb
EOF
done
5.6 make this file excutable
chmod +x makemap
5.7. do:
./makemap
5.8 create another file called c70uming.fd
% This is c70song.fd for CJK package.
% created by Edward G.J. Lee
% modify by Frank Liu
\ProvidesFile{c70uming.fd}
\DeclareFontFamily{C70}{uming}{\hyphenchar \font\m@ne}
\DeclareFontShape{C70}{uming}{m}{n}{<-> CJK * uming}{}
\DeclareFontShape{C70}{uming}{bx}{n}{<-> CJKb * uming}{\CJKbold}
\endinput
5.9 create the following directories for newly created files:
mkdir -p ~/.texlive2007/texmf-var/fonts/map/dvips/CJK
mkdir -p ~/.texlive2007/texmf-var/fonts/tfm/CJK/uming
mkdir -p ~/.texlive2007/texmf-var/fonts/type1/CJK/uming
mkdir -p ~
/.texlive2007/texmf-var/tex/latex/CJK/UTF8
5.10 copy the files in ~/fonts into specified paths:
cp ~/font/uming.map ~/.texlive2007/texmf-var/fonts/map/dvips/CJK
cp ~/font/*.tfm ~/.texlive2007/texmf-var/fonts/tfm/CJK/uming
cp ~/font/*.pfb ~/.texlive2007/texmf-var/fonts/type1/CJK/uming
cp ~/font/c70uming.fd ~/.texlive2007/texmf-var/tex/latex/CJK/UTF8
5.11 do:
sudo texhash
updmap --enable Map ukai.map

6. follow the above procedule and install another font "ukai" (note, in step 5 replace "uming" with "ukai")

7. Start LyX and run Tools/Reconfigure

8. Restart Lyx and make two environmental settings:
8.1 In Document/Settings/Language, change the language to Chinese (traditional) and change encoding to Unicode CJK (utf8).
8.2 In the Document/Settings/Fonts panel, type "uming" or "ukai" in the CJK box.

Then you should be able to create Chinese documents with Lyx.