old-www/HOWTO/Chinese-HOWTO-6.html

232 lines
10 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>Linux Chinese HOWTO English Version: Printing for Chinese</TITLE>
<LINK HREF="Chinese-HOWTO-7.html" REL=next>
<LINK HREF="Chinese-HOWTO-5.html" REL=previous>
<LINK HREF="Chinese-HOWTO.html#toc6" REL=contents>
</HEAD>
<BODY>
<A HREF="Chinese-HOWTO-7.html">Next</A>
<A HREF="Chinese-HOWTO-5.html">Previous</A>
<A HREF="Chinese-HOWTO.html#toc6">Contents</A>
<HR>
<H2><A NAME="s6">6. Printing for Chinese</A></H2>
<P>This section will teach you how to print Chinese documents, but without the demonstrations of how to set up your printer; that you have to make it all ready by yourself.
Tools introduced in this section are all for transformations to PostScript format; hence, you need to set your printer up in order to print PostScript files. If your printer doesn't support PostScript directly, you can install <CODE>
<A HREF="http://www.cs.wisc.edu/~ghost/index.html">ghostscript</A></CODE> instead.
Please refer to
<A HREF="http://sunsite.unc.edu/LDP/HOWTO/Printing-HOWTO.html">Printing HOWTO</A>.
<P>
<H2><A NAME="ss6.1">6.1 cnprint</A>
</H2>
<P><CODE>cnprint</CODE> is a printing tool for the purpose of changing Chinese text files into PostScript format, of which commands are the same as the standard ones. It supports GB, HZ, and BIG5 codes simultaneously.
<P>
<H3>Where to get it?</H3>
<P>Download it from <CODE>
<A HREF="ftp://ftp.ifcss.org/pub/software/unix/print">ftp://ftp.ifcss.org/pub/software/unix/print</A></CODE>, of which name is <CODE>cnprint280.tar.gz</CODE>.
<P>
<H3>Setting up cnprint</H3>
<P><CODE>cnprint280.tar.gz</CODE> contains only five files.
<BLOCKQUOTE><CODE>
<PRE>
# ls
cnprint.1 cnprint.cmd cnprint280.README
cnprint.c cnprint.help
</PRE>
</CODE></BLOCKQUOTE>
Compile it through this way below:
<BLOCKQUOTE><CODE>
<PRE>
# gcc cnprint.c -o cnprint
# mv cnprint /usr/local/bin
# mv cnprint.1 /usr/local/man/man1
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H3><A NAME="hbf"></A> Installing HBF fonts</H3>
<P>HBF fonts includes both description files and fonts files. A <CODE>.hbf</CODE> is the header file describing fonts, with a texture of plain text, recording the file names of its fonts files.
Both of two files must be installed yourself. You can find them at <CODE>
<A HREF="ftp://ftp.ifcss.org/pub/software/fonts/">ftp://ftp.ifcss.org/pub/software/fonts/</A></CODE>.
<P>If you want to use <CODE>ccfs24.hbf</CODE>, for example, which is a sort of simplified Sung-imitated style font, you must obtain these three following files: <CODE>ccfs24.hbf</CODE>, <CODE>cclib.n24</CODE> and <CODE>ccsym.24</CODE>.
In the ifcss fonts directory, <CODE>00index.txt</CODE> lists all HBF fonts' filenames.
Establish a specific directory to store HBF fonts, just like <CODE>/usr/local/lib/chinese/HBF/</CODE>, for instance. Put all HBF description files and fonts files you've got together under this directory, then export the complete directory pathname for HBF out of environmental variables.
<BLOCKQUOTE><CODE>
<PRE>
# export HBFPATH="/usr/local/lib/chinese/HBF/"
</PRE>
</CODE></BLOCKQUOTE>
<P>This file <CODE>cnprint.cmd</CODE> contains some default values for <CODE>cnprint</CODE>, that you have to fix them up to point to the HBF fonts you have installed, and then export it to <CODE>$HBFPATH</CODE>.
<BLOCKQUOTE><CODE>
<PRE>
# cp cnprint.cmd $HBFPATH
</PRE>
</CODE></BLOCKQUOTE>
Now, you can use ``<CODE>cnprint -w FILENAME</CODE>'' to change Chinese text files into PostScript files well. For more information in detail, take a look at <CODE>man cnprint</CODE> yourself.
<P>
<H3>Code Transformation</H3>
<P>The <CODE>cnprint 2.80</CODE> has been added a great deal of <EM>splendid abilities</EM> such as transformations amongst various code formats, for example, BIG5 &lt;=> GB &lt;=> HZ.
For BIG5 &lt;=> GB, you need another tabulation for installing, though, which can be found from this following site:
<BLOCKQUOTE>
<A HREF="ftp://ftp.ifcss.org/pub/software/unix/convert/hc.tab">ftp://ftp.ifcss.org/pub/software/unix/convert/hc.tab</A></BLOCKQUOTE>
Put it under the fonts directory of HBF, and modify <CODE>cnprint.cmd</CODE>, adding this
<BLOCKQUOTE><CODE>
<PRE>
DEFAULT_GBB5_TABLEFILE: /usr/local/lib/chinese/HBF/hc.tab
</PRE>
</CODE></BLOCKQUOTE>
<P>Not only, for BIG5 into GB codes, can the transformation of <CODE>cnprint 2.80</CODE> against <B>words to words</B> be done, but also the work against <B>phases to phases</B>. However, <CODE>cnprint</CODE> itself didn't offer the dictionary for transformations, that means that you have to create a dictionary yourself if you need one. Please refer to <CODE>man cnprint</CODE> for more details.
<P>
<H2><A NAME="ss6.2">6.2 ps2cps</A>
</H2>
<P>The purpose of this small program is to make PostScript files, which could not pork Chinese out to output devices, available for Chinese output.
For example, when Netscape is printing files, it will transport files into PostScript formats first; however, the outputs of PostScript won't load Chinese fonts so that the original parts of Chinese words will become disturbed codes to output.
This program can read PostScript in, and replace the disturbed codes with corresponding words; afterwards pork the results out to the standard output devices, which the output data can send to the printer that can print PostScript documents.
<P>Pick ps2cps up from this site:
<BLOCKQUOTE>
<A HREF="ftp://linux.cis.nctu.edu.tw/packages/chinese/misc/ps2cps-0.1.tgz">ftp://linux.cis.nctu.edu.tw/packages/chinese/misc/ps2cps-0.1.tgz</A></BLOCKQUOTE>
<P>Untar and unzip this file, and modify Makefile according to your demands:
<BLOCKQUOTE><CODE>
<PRE>
BINPATH : Installing pathname for binary ps2cps
PS2CPSPATH : Resources files' pathname for PS2CPS
PS2CPSRC : Filename of resources files for PS2CPS
</PRE>
</CODE></BLOCKQUOTE>
<P>Next step is <CODE>make all install</CODE>.
<P>You have to install HBF Chinese fonts first according to the previous section, and then modify your <CODE>ps2cpsrc</CODE> file:
<BLOCKQUOTE><CODE>
<PRE>
HBF_PATH: Define the directory pathname of HBF fonts
HBF_NAME: Define filenames of HBF fonts(NOT including pathname)
CH_WORD_SHIFT: Define shift of Chinese fonts
</PRE>
</CODE></BLOCKQUOTE>
The last item is used for adjustment of Chinese fonts' locations. Some Chinese fonts and the original English fonts may probably not locate on the same horizontal level line, so you can set this variable, of which numeric values ranging from -1.0 to +1.0, activated to adjust it up or down.
<P>So, you can use that examples made from the founder to do some tests:
<BLOCKQUOTE><CODE>
<PRE>
# ps2cps thhsieh.ps > c-thhsieh.ps
</PRE>
</CODE></BLOCKQUOTE>
Use <CODE>ghostview</CODE> to see whether you can see Chinese words or not.
<P>However, this program is still under beta, there are so many problems waitting for resolving. If you have any questions or recommendations, you can send messages to the author directly: Tung-Han Hsieh &lt;
<A HREF="mailto:thhsieh@twclx.phys.ntu.edu.tw">thhsieh@twclx.phys.ntu.edu.tw</A>&gt;.
<P>
<H2><A NAME="ss6.3">6.3 bg2ps</A>
</H2>
<P>This is another program which can transform BIG5-based Chinese files into PostScript available for printing(the same as cnprint).
But because it uses the TrueType fonts, the output is more beautiful than others. In addition, it has a script which can transform PostScript out of Netscape into Chinese.
The author is
<A HREF="http://weber.u.washington.edu/~cschin/chinhome.html">Chen-Shan Chin</A> &lt;
<A HREF="mailto:cschin@u.washington.edu">cschin@u.washington.edu</A>&gt;.
<P>Get this software from this web site:
<BLOCKQUOTE>
<A HREF="http://weber.u.washington.edu/~cschin/bg2ps/">http://weber.u.washington.edu/~cschin/bg2ps/</A></BLOCKQUOTE>
<P>
<H3>Installing bg2ps</H3>
<P>Decompress and compile it:
<BLOCKQUOTE><CODE>
<PRE>
# mkdir bg2ps
# cd bg2ps
# tar xzvf bg5ps.tgz
# gcc -O2 ttf2psm.c -o ttf2psm
</PRE>
</CODE></BLOCKQUOTE>
<P>Install TrueType fonts next. You can install it under the same directory of bg2ps or can assign another directory for use. Refer to
<A HREF="Chinese-HOWTO-11.html#ntuttf">Installing TTF fonts</A> for more explanations.
Then create a <CODE>.bg5ps.conf</CODE> under the directory, and you can pick directly up the sample file coming with this program to modify.
The most important is to assign the directory where you installed the TrueType fonts to <CODE>chineseFontPath</CODE>, and rename the content of <CODE>fontName</CODE> to the fonts name you used.
<P>Test the sample coming with it, and view the output as <CODE>ghostview</CODE> or <CODE>gv</CODE>.
<BLOCKQUOTE><CODE>
<PRE>
# ./bg5ps -if test.big5 -of test.ps
# ghostview test.ps
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H3>Installing nps2cps</H3>
<P>The nps2cps has no extra configuration files. You need to modify yourself <CODE>chineseFontPath</CODE> and <CODE>fontName</CODE> in <CODE>nps2cps</CODE> script.
<P>Test nps2cps:
<BLOCKQUOTE><CODE>
<PRE>
# nps2cps &lt; netscape.ps > test.ps
# ghostview test.ps
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>
<H2><A NAME="ss6.4">6.4 gb2ps</A>
</H2>
<P>The gb2ps program is another tool for printing GB and HZ codes.
<P>
<H3>How to get gb2ps?</H3>
<P>
<BLOCKQUOTE><CODE>
<DL>
<DT><B>Package:</B><DD><P>
<PRE>
gb2ps.2.02.tar.gz
</PRE>
<A HREF="ftp://ftp.ifcss.org/pub/software/unix/print">ftp://ftp.ifcss.org/pub/software/unix/print</A></DL>
</CODE></BLOCKQUOTE>
<BLOCKQUOTE><CODE>
<DL>
<DT><B>Fonts:</B><DD><P>
<PRE>
csong24.ccf ckai24.ccf
cfang24.ccf chei24.ccf
</PRE>
<A HREF="ftp://ftp.ifcss.org/pub/software/fonts/gb/misc/">ftp://ftp.ifcss.org/pub/software/fonts/gb/misc/</A></DL>
</CODE></BLOCKQUOTE>
Put the fonts under certain self-established directory, just like <CODE>/usr/local/lib/chinese/CFONT</CODE>.
<P>
<H3>Installing gb2ps</H3>
<P>Change the settings in <CODE>Makefile</CODE> before compiling gb2ps.
<BLOCKQUOTE><CODE>
<PRE>
CFONT=/usr/local/lib/chinese/CFONT/
COVERPAGE=/usr/local/lib/chinese/lib/cover.ps
</PRE>
</CODE></BLOCKQUOTE>
Then type these commands and hit return key,
<BLOCKQUOTE><CODE>
<PRE>
# make
# cp gb2ps /usr/local/bin
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>
<HR>
<A HREF="Chinese-HOWTO-7.html">Next</A>
<A HREF="Chinese-HOWTO-5.html">Previous</A>
<A HREF="Chinese-HOWTO.html#toc6">Contents</A>
</BODY>
</HTML>