Chinese(GB) PostScript Fonts, v1.1 (gbpfb-1.1) Chen Xiangyang (chenxy@sun.ihep.ac.cn) Apr.28, 1998 Copyleft 1998 Chen Xiangyang Introduction ------------ Yes! This IS what you want! At last, I release the first version of Chinese(GB) PostScript fonts. You may often say that you can't view Chinese characters in PostScript files saved by netscape, and you can't easily print Chinese files to a printer attached to your machine running an OS that doesn't support Chinese. From now on, everything will be easier. The Chinese enhancement of Ghostscript will help you get splendid output from your screen and your printer! This package includes a set of Chinese(GB) PostScript fonts and some small utilities helping you generate Chinese PostScript files. It also includes some hints on establishing a printer queue that uses Ghostscript as the PostScript filter. After easy installation, you may get an Chinese-enabled Ghostscript through which you can view and print Chinese files. Installation ------------ 0a. Make sure Ghostscript has been installed on your system. You should also know the location of Ghostscript-related files. You may get this by using the command 'gs -help', the output should contain some lines like this: Search path: . : /usr/local/share/ghostscript/5.10 : /usr/local/share/ghostscript/fonts in this case, Ghostscript files are in /usr/local/share/ghostscript/ and its sub-directories. 0b. Install freetype-1.0. The program ttf2pfb.c use the library from FreeType. You must install freetype-1.0 first in order to compile ttf2pfb.c. You may get freetype-1.0.tar.gz from ftp://sunsite.unc.edu/pub/Linux/X11/fonts or many other sites. Note that you should NOT use the test version of FreeType, i.e., freetype-current.tar.gz. Follow the instruction in that package to install FreeType. 1. Compile and install some binaries and scripts of gbpfb-1.1. You may use the following commands: % make # make install The default is to install the following files to /usr/local/bin: ttf2pfb, t1asm, gbpfb, ns2cps, txt2cps, jy2cps and the following files to /usr/local/lib/gbpfb: GBK_codeRange, printafm.ps, Fontmap.gb If you want to install them elsewhere, use 'make install prefix=', for example, % make install prefix=/home/jack will install the above files to /home/jack/bin and /home/jack/lib/gbpfb. 2. Append Fontmap.gb to the original Fontmap file of Ghostscript, e.g., cat Fontmap.gb >> /usr/local/share/ghostscript/5.10/Fontmap 3. Copy all files (GB-*.ps) in ./fonts directory to Ghostscript's font directory, in the above case, it is /usr/local/share/ghostscript/fonts. 4. Generate Chinese PFB fonts from Chinese TrueType fonts (see next section 'Building Chinese PFB fonts') and install the .pfb files into Ghostscript's font directory, e.g., /usr/local/share/ghostscript/fonts. Note*: If you don't have root privilege, you may not put files into system directories, as in step 2, 3 and 4. You may use your personal directory, for example, $HOME/gsfonts, to put them. Copy all files (GB-*.ps) in ./fonts directory and all .pfb files to $HOME/gsfonts. Copy Fontmap.gb to $HOME/gsfonts and rename it to Fontmap. Set an environment variable GS_LIB to point to $HOME/gsfonts: sh or bash: GS_LIB=$HOME/gsfonts export GS_LIB csh or tcsh: setenv GS_LIB $HOME/gsfonts 5. You are ready to use Chinese(GB) PostScript fonts through Chinese-enabled Ghostscript! Building Chinese(GB) PFB fonts ------------------------------ Chinese(GB) PFB fonts are made from Chinese TrueType fonts(TTF). You may get Chinese TrueType fonts from your Chinese operating systems or Chinese platforms. gbpfb-1.1 can make use of Chinese TrueType fonts in Unicode or GB encoding. You may use the utility 'ftdump' in freetype-1.0 package to get the encoding of a TrueType font. If you see from the result of the command 'ftdump ' something like this: encoding 1: Windows Unicode that means the TrueType font is in Unicode encoding. If you see encoding 0: Windows Unknown 3 that means the TrueType font is in GB encoding. TrueType fonts in GB encoding contain only GB 2312-1980 character set. Some Unicode TrueType fonts cover GB 13000-1993 character set, i.e., GBK character set, which is a superset of GB 2312-1980. ttf2pfb is used to generate raw Type1 PostScript fonts from TrueType fonts. The original ttf2pfb.c can't generate GBK encoded fonts from Unicode TrueType fonts. I add a gbk2uni.h in it so that it can map a character's GBK code to its Unicode and get its glyph from Unicode TrueType fonts. t1asm is used to convert raw Type1 PostScript fonts to either PFB or PFA format. Ghostscript and afm2tfm (in teTeX package) are used to generate AFM and TFM files from PostScript font files. I provide a shell script 'gbpfb' in this package, which automates the whole procession of generating Chinese(GB) PFB fonts and related TFM files from Chinese TrueType font files. The usage of gbpfb is: gbpfb ttf_file face face: song/hei/kai/fs If you use a Song Ti TrueType font, you should choose face as 'song'; if you use a Kai Ti TrueType font, you should choose face as 'kai', etc. You should construct four types of Chinese(GB) PFB fonts. They are: Song Ti, Hei Ti, Kai Ti, FangSong Ti. For each type, there are 126 PFB files, each represents a row of GB 13000-1993 (GBK) character set: gbsong81.pfb -- gbsongfe.pfb gbhei81.pfb -- gbheife.pfb gbkai81.pfb -- gbkaife.pfb gbfs81.pfb -- gbfsfe.pfb gbpfb will move these PFB files to a sub-directory fonts/. You should copy all 126 x 4 = 504 PFB files to Ghostscript's font directory, e.g, /usr/local/share/ghostscript/fonts. For each PFB file, gbpfb also generate a TFM file, which is saved in tfm/ directory and can be used with CJK, the Chinese enhancement to LaTeX2e. If you want to keep the AFM files generated by gbpfb, comment out the following command in gbpfb script: rm gb$face$plane.afm and uncomment the following commands: #mkdir -p afm #mv gb$face??.afm afm AFM files will be saved in afm/ directory. Chinese(GB) PostScript Fonts ---------------------------- Each Chinese(GB) PFB file defines a PostScript Type1 fonts, e.g., /GB-Song81 defined in gbsong81.pfb /GB-Heib0 defined in gbheib0.pfb /GB-Kaidb defined in gbkaidb.pfb /GB-FangSongfe defined in gbfsfe.pfb Four Chinese(GB) elementary fonts are defined through Type0 font files: /GB-Song defined in GB-Song.ps /GB-Hei defined in GB-Hei.ps /GB-Kai defined in GB-Kai.ps /GB-FangSong defined in GB-FangSong.ps Four Chinese(GB) regular fonts (including ASCII PostScript fonts as a part) are defined through Type0 font files: /GB-Song-Regular defined in GB-Song-Regular.ps /GB-Hei-Regular defined in GB-Hei-Regular.ps /GB-Kai-Regular defined in GB-Kai-Regular.ps /GB-FangSong-Regular defined in GB-FangSong-Regular.ps Four Chinese(GB) italic fonts (including ASCII PostScript fonts as a part) are defined through Type0 font files: /GB-Song-Italic defined in GB-Song-Italic.ps /GB-Hei-Italic defined in GB-Hei-Italic.ps /GB-Kai-Italic defined in GB-Kai-Italic.ps /GB-FangSong-Italic defined in GB-FangSong-Italic.ps Four Chinese(GB) fixed fonts (including fixed-width ASCII PostScript fonts as a part) are defined through Type0 font files: /GB-Song-Fixed defined in GB-Song-Fixed.ps /GB-Hei-Fixed defined in GB-Hei-Fixed.ps /GB-Kai-Fixed defined in GB-Kai-Fixed.ps /GB-FangSong-Fixed defined in GB-FangSong-Fixed.ps Four Chinese(GB) fixed italic fonts (including fixed-width ASCII PostScript fonts as a part) are defined through Type0 font files: /GB-Song-FixedItalic defined in GB-Song-FixedItalic.ps /GB-Hei-FixedItalic defined in GB-Hei-FixedItalic.ps /GB-Kai-FixedItalic defined in GB-Kai-FixedItalic.ps /GB-FangSong-FixedItalic defined in GB-FangSong-FixedItalic.ps The correspondents of Times and Courier fonts are defined through font aliases and Type0 fonts files: /GB-Times-Roman alias of /GB-Song-Regular /GB-Times-Italic alias of /GB-Song-Italic /GB-Times-Bold alias of /GB-Hei-Regular /GB-Times-BoldItalic alias of /GB-Hei-Italic /GB-Courier alias of /GB-FangSong-Fixed /GB-Courier-Oblique alias of /GB-FangSong-FixedItalic /GB-Courier-Bold defined by GB-Courier-Bold.ps /GB-Courier-BoldOblique defined by GB-Courier-BoldOblique.ps In order to support mixed use of ASCII and Chinese(GB) characters, you should use regular, italic, fixed, and fixed italic fonts, which include ASCII PostScript fonts as a part. You should NOT use elementary fonts directly. How to Use Chinese(GB) PostScript Fonts --------------------------------------- 1. ... to write PostScript files If you know something about PostScript language, you will find that using Chinese(GB) PostScript fonts is just like using ASCII PostScript fonts. Here is a small example: lark% gs Aladdin Ghostscript 5.10 (1997-11-23) Copyright (C) 1997 Aladdin Enterprises, Menlo Park, CA. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. GS>/GB-Song-Regular 24 selectfont GS>100 600 moveto GS>(希望Chinese(GB) PostScript Fonts越来越完善) show GS>/GB-Courier-Oblique 16 selectfont GS>100 130 moveto GS>(意见和建议请发至chenxy@sun.ihep.ac.cn) show GS>300 100 moveto GS>(\320\273)show show %% 谢谢大家 In the string before "show" operator, you may use character codes (octal) or hexadecimal encoding of a Chinese character, as well as the character itself. Chinese(GB) PostScript fonts support unconditionally mixed use of ASCII and Chinese(GB) characters. If you used Times-Roman before, you may now simply use GB-Times-Roman, just so so. The correspondents of other ASCII PostScript fonts, e.g. Helvetica, are not included in this package. But you can easily write it yourself, you only need slightly modify GB-Courier*.ps. Fixed fonts are designed as such that the width of Chinese(GB) characters are exactly two times of the width of ASCII characters. So you may use them to keep regularity of ASCII and Chinese(GB) characters. 2. ... to view and print PostScript files containing Chinese saved by netscape The small shell script scripts/ns2cps can be used to modify PostScript files containing Chinese(GB) characters saved by netscape and generate new Chinese PostScript files that can be viewed by Chinese-enabled Ghostscript. If you save a WWW page that contains Chinese(GB) characters to a file page.ps, you may use scripts/ns2cps as this: lark% ns2cps page.ps > page.cps The Chinese PostScript file page.cps can be viewed by Chinese-enabled Ghostscript. If you use Ghostscript as input PostScript file filter of your printer, you can directly send the modified Chinese PostScript file to your printer: lark% lpr page.cps If you want to print directly from netscape, you may open "Print..." menu and modify "Print command" item as "ns2cps - | lpr", then you can print any page that contain Chinese(GB) characters directly to your printer. 3. ... to print plain Chinese text files The small shell script scripts/txt2cps can be used to convert a plain Chinese text file to a Chinese PostScript files. By default, txt2cps uses a fixed font GB-Song-Fixed, you may specify other font using "-fn" option, e.g. lark% txt2cps -fn GB-Kai-Fixed report.txt > report.cps If you want to retain the regularity of ASCII and Chinese(GB) characters, you should use fixed fonts, otherwise you may use any font you like. If you use Ghostscript as input PostScript file filter of your printer, you can directly send the Chinese PostScript file report.cps to your printer. 4. ... to view Jin Yong's novels Recently there is a popular CD-ROM that contains many famous books, especially Jin Yong's emprise novels. They are saved in Chinese PDF format and can be read by Acrobat Reader on Chinese version of Windows-95, but can't be read by Acrobat Reader on UNIX. Now you can read them in PostScript format. The small shell script scripts/jy2cps can be used to convert (through acroread) Chinese PDF files to Chinese PostScript files, e.g. lark% jy2cps a97.pdf will generate a new file called a97.cps. It can be read by Ghostscript and can be printed out. If you find that your Ghostscript can't read the JPEG image on the first page of the Chinese PostScript file, you may have to recompile a new version of Ghostscript that support JPEG images. 5. ... to view and print Big5 files If you have some Chinese files in Big5 encoding and you want to print them out, you may first convert them to GB encoding. You may get a package from ftp://ftp.ifcss.org/pub/software/unix/convert/hc-30.tar.gz After they are in GB encoding, follow the instruction above. 6. ... with CJK enhancement to LaTeX2e If you want to use Chinese(GB) PostScript fonts with CJK enhancement to LaTeX2e, you should first install CJK package. I have made a ready-to- install CJK package of GB encoding, cjk-4.1.3-gb, you may get it from ftp://ftp.ihep.ac.cn/pub/chinese/packages and install it in your teTeX tree. After installation of cjk-4.1.3-gb, you should copy all 126 x 4 = 504 TFM files generated by 'gbpfb' to teTeX's TFM file directory. you may use the directories $TETEXDIR/texmf/fonts/tfm/chinese/{gbsong, gbhei, gbkai, gbfs} to hold them. You should use 'pmC' font encoding in your Chinese LaTeX files, e.g., \documentclass[12pt,a4paper]{article} \usepackage{CJK} \begin{document} \begin{CJK*}[pmC]{GB}{song} your Chinese document here...... \end{CJK*} \end{document} and use 'gblatex' to process them, e.g., % gblatex doc.tex # do not omit the extension .tex % dvips doc dvips will use 'gsftopk' to generate PK font files from Ghostscript's Chinese PFB files and produce a self-contained PostScript file. If you don't want to build Chinese fonts into the resulting PostScript files, you may use % dvips -P CJK doc which will produce a quite small Chinese PostScript file, but it requires every one who wants to read it to have Chinese-enabled Ghostscript. Setup Printer Queue Using Ghostscript As Filter ----------------------------------------------- If you have a printer connected to your computer, and your computer uses a BSD-like printing system, you can easily setup a printer queue using Ghostscript as its filter. Some operation systems have already done this, e.g., RedHat Linux's printtool. If you have already used this, it is OK. Else, you may use the files in ./printer sub-directory to setup one. First, use "gs -help" to try to find your printer's DEVICE name. For example, gs uses "ljet4" to represent HP LaserJet 4, and "stcolor" to represent EPSON Stylus Color. If you can't find a proper one, you may get the package of Ghostscript's source codes from ftp://ftp.cs.wisc.edu/ghost/aladdin/gs###/ (### is the version number) or its mirror sites and examine related documents in it. In some cases, you need to recompile Ghostscript to include your printer's device driver. And you also need nenscript package. If you don't have one, try to get it from ftp://sunsite.unc.edu/pub/Linux/system/printing/ or its mirror sites and install it on your system. Then you should modify ./printer/printcap and ./printer/filter files properly (the simplest, change all "ljet4" to your printer's DEVICE name and /dev/lp1 to the port device your printer uses). Copy ./printer/printcap to your system's /etc/printcap, create a spool directory according to the "sd=..." line in printcap file, and copy ./printer/filter to the spool directory. Restart lpd (usually in /usr/sbin) and you may try your new printer queue. Where to get the newest version of this software? ------------------------------------------------- ftp://ftp.ihep.ac.cn/pub/chinese/packages/gbpfb-x.x.tar.gz You should be patient because our connection to the Internet is very slow.