jump to navigation

LaTeX and CJK, how to use the TrueType fonts December 26, 2005

Posted by Chen Yufei in LaTeX.

First I should tell you that I am using SUSE Linux 10 and teTeX 3.0 which comes from the SUSE Linux CD set, and I am not sure whether the steps I discribed below works for other TeX distribution. You may change something to get things work correct.

  1. Get the TrueType fonts.(May be you have done this.) This shouldn’t be difficult. You can find some free TT fonts on CTAN. One thing should be noticed is that if you want to get Unicode support, you should get the Cyberbit.ttf(it’s free, more details about Unicode and CJK, click here, I didn’t use it since it’s a little troublesome, when needed I use iconv to convert).
  2. Download gbkfonts.(Other versions, see here, thanks to the authors) I think it should also be able to work on other TT fonts other than Chinese TT fonts. I didn’t test it. If it doesn’t work on other TT fonts like Korean, Japanese TT fonts, you may have to use ttf2afm and some other programs. Read the pdfTeX manual for details.
  3. Uncompress gbkfonts you just downloaded. Copy the file “go“, “gbkfonts-glibc” to /usr/local/bin, change the file name “gbkfonts-glibc” to “gbkfonts“. Edit the script go, find these lines like “gbkfonts ${opts[*]} $dir/FZSongTi.ttf song“, change it to the fonts name you want use. Then “cd /usr/local/share/texmf”(if you run the program in your locale texmf directory, you need to move less files later), type “go yourfonts directory“(need to have the write right in this directory), wait… and the program will create the afm, tfm, type1, enc files and some other configuration files for divpdfm, pdftex and dvips.
  4. Some articles talking about using CJK and TrueType fonts stops here. Of course you need “mktexlsr”, but things just don’t work on my system. You can now make some test, if things don’t work, read on. Below are additional steps I did on my system to get things work. I had a look at my texmf.cfg(in TEXMF/web2c, you may need to change the variable TEXMF to let TeX search local TEXMF first) and check out some path on my TeX system. Then first create the map files directory: “mkdir /usr/local/texmf/fonts/map/{dvips,dvipdfm,pdftex}”(using bash), mv all the map files gbkfonts created to the corresponding direcrory. Then create the enc files directory “mkdir /usr/local/texmf/fonts/enc/dvips“, mv the directory which contains enc files in the directory “dvips” just created here. You should keep the directory structure and TeX will search these directories recursively.
  5. If you use “updmap” to mantain the font map information, I suggest you just add one line in updmap.cfg(also in TEXMF/web2c) “Map cjk.map“. Run “mktexlsr”(If you don’t run this, updmap will not find the map file you just created) and then “updmap” to update the font map information. You can have a look at cjk.map, it contains a lot of lines ending with *.pfb, so this is in fact using Type1 fonts gbkfonts just created.(In Type1 directory. I am not quite sure about which font is actually used since the *.pfb files is created from TT fonts.) dvipdfm, dvips and pdftex all supports Type1 fonts, this works well. You should be able to get things works correctly now. Make some test?
  6. But there is still some problem. I use dvipdfmx to create pdf files which can be searched even it contains CJK fonts, but it should be configured to use TT fonts directly. The problem with updmap is that it updates font map information for the three program at the same time using the same map files 😦 That’s not what I wanted, but I am not able to modify the script now so I use the stupid method—add font map manully. “cd /var/lib/texmf/fonts/map”, keep dvipdfm untouched. “cd to dvips/updmap“, append cjk.map to psfonts_t1.map.(the file which symbolic link psfonts.map points to) Then “cd pdftex/updmap”, append all the map files in the directory pdftex which was created by gbkfonts to pdftex.map.(this is also a symbolic link, you can directly edit the file it points to) For dvipdfm(x), you just need to mv cid.map and some other map files created by gbkfonts to /usr/local/share/texmf/fonts/map/dvipdfm. Then dvipdfm(x) and pdftex will both use TT fonts directly, while dvips uses Type1 fonts. That’s all.

So many words… I do think these artiles stops at step 3 are right, and I don’t need to write so many words. I don’t know why 😦 After running gbkfonts we get the map files and the configuration files, if pdftex and dvips read these configuration files, then we can just stop at step 3. But I didn’t find pdftex.cfg in /usr/share/texmf/pdftex/config, in fact there is no such directory at all! So I wonder whether pdftex read the configuration file.(This seems not likely to happen, but the brutal fact makes me think so) There is the file config.ps in /usr/share/texmf/dvips/config, but it also seems that dvips also didn’t read it because unless I manully add cjk.map to psfonts_t1.map it won’t wok, though I have added “p +cjk.map” in config.ps. But it’s strange thar dvipdfm(x) read the configuration files since I keep it’s font map files in /var/lib… untouched. I will ask for help about this problem later. It is very likely that it is because I made some mistakes. If you know, please tell me, I do appreciate!