Tgif Home
----
About Tgif
Current Release & Download
FAQ
Copyright Info
A Screendump of Tgif
Release History
Tools That Tgif Uses
Tools That Work with Tgif
Author of Tgif
Miscellaneous Info
----
 
Return to Tgif's Home Page
William Chia-Wei Cheng
(bill.cheng@usc.edu)
 

Tgif FAQ - Input Double-byte Characters

 
Ever since tgif-4.2.3, tgif generates bad PS/EPS files for Japanese characters (EUC fonts). Is there a fix for this?
Please apply the tgif-QPL-4.2-patch5b patch. Sorry about the bug!
I've just compiled xcin but don't know how to invoke it within tgif-4.x. The man page is not very clear on how to input Chinese characters. Can you give me some pointers?
I'm not too familiar with xcin. This is what I can do to get some characters into it:

  1. Make sure you have something like the following in your X defaults file:

    Tgif.DoubleByteInputMethod: xcin
    Tgif.SquareDoubleByteFonts: \n\
        -hku-fixed-medium-r-normal--%d-*-*-*-*-*-big5.hku-0,*,HKU \n\
        -hku-fixed-medium-r-normal--%d-*-*-*-*-*-big5.hku-0,*,HKU \n\
        -hku-fixed-medium-r-normal--%d-*-*-*-*-*-big5.hku-0,*,HKU \n\
        -hku-fixed-medium-r-normal--%d-*-*-*-*-*-big5.hku-0,*,HKU
    

    I'm using hku-ch16 and I'm using the HKU PostScript font (which doesn't really exist -- I'm just using it as an example).

  2. Start xcin. Start tgif and select the HKU font.

  3. Type <Cntrl><Space>. This should activate xcin. Part of the xcin window becomes red and the title bar changes to "Phonetic".

  4. Type "hak1" and I get a chinese two!

  5. Type <Cntrl><Space> again and xcin is deactivated. Please note that tgif only talks to the active DoubleByteInputMethod when the active font is a double-byte font. The active font is displayed in the window of icons. You can see it changes as you move the text cursor through single and double-byte fonts.
 
Umm... Where can I get xcin?
You can get it from xcin's home page. Version 2.5 supposed to use XIM protocol (so you may need to change Tgif.DoubleByteInputMethod to xim) but I haven't (and couldn't) tried it out. If you've tried it, please let me know if tgif works with it.
 
I'm running on Fedora Core 3 and I cannot get xcin to work with tgif. Is there an easier to way to just input some traditional Chinese characters in tgif? By the way, I would also like to generate nice looking postscript files with traditional Chinese characters in them. Can this be done?
If you are familiar with zhu-yin-fu-hao, then you are in luck. Tgif has a built-in zhu-yin-fu-hao input method for inputting traditional Chinese characters. This input method is called tgtwb5 in tgif.

Here are the X defaults you can try:

Tgif.ShanHeiSunShowFontChar: \244\255
Tgif.ShanHeiSunConvFromUTF8: iconv -f utf8 -t big5
Tgif.ShanHeiSunConvToUTF8:   iconv -f big5 -t utf8
Tgif.ZenKaiShowFontChar:     \244\255
Tgif.ZenKaiConvFromUTF8:     iconv -f utf8 -t big5
Tgif.ZenKaiConvToUTF8:       iconv -f big5 -t utf8
Tgif.DoubleByteInputMethod:  tgtwb5,-taipei-fixed-medium-r-normal--16-150-75-75-c-160-big5-0
Tgif.SquareDoubleByteFonts:  \n\
 -taipei-fixed-medium-r-normal--%d-*-*-*-*-*-big5-0,*,ShanHeiSun-Light-B5-H\n\
 -taipei-fixed-medium-r-normal--%d-*-*-*-*-*-big5-0,*,ShanHeiSun-Light-B5-H\n\
 -taipei-fixed-medium-r-normal--%d-*-*-*-*-*-big5-0,*,ZenKai-Medium-B5-H\n\
 -taipei-fixed-medium-r-normal--%d-*-*-*-*-*-big5-0,*,ZenKai-Medium-B5-H
In the above, the taipei-fixed font is used in both the input method and text in tgif. As far as I know, only font sizes 16 and 24 are available for the taipei-fixed font on Linux machines.

The above also uses two PostScript fonts, namely, ShanHeiSun and ZenKai. These fonts are available on Linux machines. To verify that they are on your machine, you should first locate the ghostscript library. If you run "gs -help" and look at the search path. You should see something like /usr/share/ghostscript/###/lib.

For example, if you have ghostscript 7.07 installed, the ### above would be 7.07. Look at the content of the CIDFnmap.ARP file in the ghostscript library directory and it should contain the following lines:

% Adobe-CNS1

/ZenKai-Medium    (bkai00mp.ttf) ;
/ShanHeiSun-Light (bsmi00lp.ttf) ;

In newer version of ghostscript (such as ghostscript 8.71), a different file and file format is used. Please append the following to /usr/share/ghostscript/###/Resource/Init/cidfmap.GS (on cygwin, this file is /usr/share/ghostscript/###/lib/cidfmap):

/ZenKai-Medium     << /FileType /TrueType /Path (/usr/share/fonts/cjkuni-ukai/ukai.ttc) /CSI [(CNS1) 4] >> ;
/ShanHeiSun-Light  << /FileType /TrueType /Path (/usr/share/fonts/cjkuni-uming/uming.ttc) /CSI [(CNS1) 4] >> ;
/Adobe-CNS1        /ShanHeiSun-Light ;
In addition, if somehow gs works but ps2pdf does not, please try setting the GS_FONTPATH environment variable and see if it helps. Try:
setenv GS_FONTPATH /usr/share/fonts/cjkuni-ukai:/usr/share/fonts/cjkuni-uming

With all the above settings, you can then do the following:

  1. start tgif
  2. change font size to 16
  3. change font to ShanHeiSun
  4. go into draw text mode
  5. click inside canvas window
  6. press <Cntrl><Space> (or <Cntrl><Shift><Space>, or <Cntrl><BackSlash>) and you should get a simple zhu-yin-fu-hao input method (the popup window has a title of "Traditional Chinese (zh_TW.Big5) Keypad")
  7. you can click around the zhu-yin-fu-hao symbols followed by a numeric symbol, only after you have clicked on a numeric symbol you will get a list of Chinese characters to select
  8. alternatively, you can use pinyin by entering an English string followed by a number between 1 and 5 and press <Enter> to get a list of Chinese characters to select
  9. when you print/export in PostScript format, you should get good quality printout

A screenshot of the zhu-yin-fu-hao input method is shown here:

The PostScript output of the above file is provided here. A screenshot of a PostScript previewer is shown here:
 
What if I want to input simplified Chinese characters?
Instead of using the above settings, you need to do the following.

Since version 4.2.3 tgif supports a built-in pinyin input method for inputting simplified Chinese characters. This input method is called tgchgb in tgif.

Here are the X defaults you can try:

Tgif.MSungGBKShowFontChar:   \271\372
Tgif.MSungGBKConvFromUTF8:   iconv -f utf8 -t gb2312
Tgif.MSungGBKConvToUTF8:     iconv -f gb2312 -t utf8
Tgif.GBZenKaiShowFontChar:   \271\372
Tgif.GBZenKaiConvFromUTF8:   iconv -f utf8 -t gb2312
Tgif.GBZenKaiConvToUTF8:     iconv -f gb2312 -t utf8
Tgif.DoubleByteInputMethod:  tgchgb,-isas-fangsong ti-medium-r-normal--16-150-75-75-c-160-gb2312.1980-0
Tgif.SquareDoubleByteFonts:  \n\
 -isas-fangsong ti-medium-r-normal--%d-*-*-*-*-*-gb2312.1980-0,*,MSungGBK-Light-GB-H\n\
 -isas-fangsong ti-medium-r-normal--%d-*-*-*-*-*-gb2312.1980-0,*,MSungGBK-Light-GB-H\n\
 -isas-song ti-medium-r-normal--%d-*-*-*-*-*-gb2312.1980-0,*,GBZenKai-Medium-GB-H\n\
 -isas-song ti-medium-r-normal--%d-*-*-*-*-*-gb2312.1980-0,*,GBZenKai-Medium-GB-H\n\
In the above, the isas-fangsong ti font is used in both the input method and text in tgif.

The above also uses two TrueType fonts, namely, MSungGBK and GBZenKai. These fonts are available on Linux machines, usually in the cjkuni-ukai and cjkuni-uming subdirectories of the main fonts directory (typically /usr/share/fonts).

In newer version of ghostscript (such as ghostscript 8.71), a different file and file format is used. Please append the following to /usr/share/ghostscript/###/Resource/Init/cidfmap.GS (on cygwin, this file is /usr/share/ghostscript/###/lib/cidfmap):

/BousungEG-Light-GB  << /FileType /TrueType /Path (/usr/share/fonts/cjkuni-uming/uming.ttc) /CSI [(GB1) 4] >> ;
/GBZenKai-Medium     << /FileType /TrueType /Path (/usr/share/fonts/cjkuni-ukai/ukai.ttc) /CSI [(GB1) 4] >> ;
/MSungGBK-Light      /BousungEG-Light-GB ;
/Adobe-GB1           /BousungEG-Light-GB ;
In addition, if somehow gs works but ps2pdf does not, please try setting the GS_FONTPATH environment variable and see if it helps. Try:
setenv GS_FONTPATH /usr/share/fonts/cjkuni-ukai:/usr/share/fonts/cjkuni-uming

With all the above settings, you can then do the following:

  1. start tgif
  2. change font size to 16
  3. change font to MSungGBK
  4. go into draw text mode
  5. click inside canvas window
  6. press <Cntrl><Space> (or <Cntrl><Shift><Space>, or <Cntrl><BackSlash>) and you should get a simple pinyin input method (with a zhu-yin-fu-hao keypad)
  7. the popup window looks almost identical to the window for entering traditional Chinese characters (see above); the only difference is that the title bar says "Simplified Chinese (zh_CN.euc) Keypad"
  8. you can click around the zhu-yin-fu-hao symbols followed by a numeric symbol, only after you have clicked on a numeric symbol you will get a list of Chinese characters to select
  9. alternatively, you can use pinyin by entering an English string followed by a number between 1 and 5 and press <Enter> to get a list of Chinese characters to select
  10. when you print/export in PostScript format, you should get good quality printout
 
When I was running Fedora Core 3, everything was working like you described above. I've upgrade to Fedora Core 5 and things are not working. What should I do?
The taipei font seems to be missing in Fedora Core 5, but it really is not. If you open /etc/X11/fs/config and look for the string "chinese", you should see that the following line is in it:
    /usr/share/fonts/chinese/TrueType
The taipei font is in /usr/share/fonts/chinese/misc. So, you should change the above line to:
    /usr/share/fonts/chinese/TrueType,
    /usr/share/fonts/chinese/misc
Be careful with the comma above! If you miss a comma or have too many commas, your X server may not be able start. So, please make sure that the lines for the catalogue key are formatted correctly. Every line in it should end with a comma except the last line.

Another problem is that the PostScript Chinese fonts seem to be missing in Fedora Core 5. So, if you generate a PostScript file with Chinese characters in it, you will get a bunch of errors when you view it with evince or acroread. But if you view it with gs -sDEVICE=x11, it seems that gs (or ghostscript) has no trouble finding the PostScript Chinese fonts (because it uses information in /etc/ghostscrip/*). I have no idea how to fix this. My recommendation would be to simply stick with gs if you want to view these PostScript files. (I would prefer to use gv-3.5.8, but I cannot get it to compile on Fedora Core 5.)
 
How do I input Japanese characters in tgif?
If you use something like kinput2 to input Japanese characters. Try something like:

Tgif.DoubleByteInputMethod: kinput2
Tgif.SquareDoubleByteFonts: \n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\
 \n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\
 \n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\
 \n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V\n\
 -jis-fixed-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V
When one of the above 4 fonts is selected, you can type or something like (I don't remember exactly how kinput2 works) that to activate kinputs.

You can also checkout other X defaults in tgif.Xdefaults which is distributed with the tgif source code. Find the place where it says "DoubleByte related" and look below that.
 
I can input Japanese characters. But when I create a PS file with tgif and view it with ghostscript, I get an error message saying that Ryumin-Light-EUC-H font is not found. What can I get this to work?
Please see http://www2.enel.ucalgary.ca/People/far/howto/gs-ttf.html.