Installation, principles, and usage of Chinese Postscript fonts of GPL

Source: Internet
Author: User

The main purpose of this article is to introduce a set of Chinese Postscript fonts released under GPL, which can be fully operated under Ghostscript, and its use is as easy as that of General English fonts. The usage is the same. Thanks to the generosity of jiesheng, we can use this font. It is a pity that almost no one knows how to use it in Linux. This book will reveal its secret. Finally, we propose a perlscript so that you can use it to print simple text files.

At present, there are many Chinese print programs on UNIX, basically all of their output files are Postscript files. This is because we have the best GPLPostscript file Printing Program, which is Ghsoscript. Ghostscript has excellent portability and supports almost all visible devices on the market. Moreover, it is of the same quality as a high-order Postscript printer, and even fully supports color printing.
Therefore, in Linux, it is natural to use Postscript as the output file format. However, it is not easy to enable the Postscript file to support Chinese Printing because the font format used by Postscript is mainly designed for the unit tuples. The word set of double-bitwise tuples such as Chinese was not taken into consideration in the initial design. However, because the Postscript Language is a drawing language, we can use Chinese as a graph, however, some text printing functions supported by Postscript cannot be used.
However, I would like to remind you that the Ghostscript mentioned here attached to Slackware cannot be used because it uses some level2 features (I guess ). Install the Ghostscript version 3.33 or later before using it. I will help you compile it into gs333.tgz. This file is also available on the CD. However, there is no font. Please install the font by yourself. (You can copy the Fontmap to/usr/lib/ghostscript/2.61 if the Fontmap is still in use)
Jackson-shaped Installation
Jackson's Chinese Postscript fonts can be obtained in NCTUCCCA. EDU. TW: // NeXT/Chinese/KaiSu.pkg_0_7.tar.gz. However, it cannot be identified directly in Linux. I undo it and take out useful parts and put it on a CD.
Jackson's font is divided into two files: one is used to build its Postscript Language file, and the other is the font definition file.
KaiSu-Regular ====> font definition file
KaiSu-Regular.dat ====> font data files
To put it in Ghostscript, follow these steps:
(1) Put the two files in/usr/lib/ghostscript/fonts.
(2) Modify/usr/lib/ghostscript/Fontmap and add/KaiSu-Regular (KaiSu-Regular) at the end. Do not forget the last semicolon.
(3) Use the following files to test its functions.
You can see the big concepts.
Principle of showpage Jackson
If you just want to use a font, this section can be omitted. This section is intended for those who are interested in the Jackson font principle or want to create their own Postscript font. We can generate fonts using the same TTF and Jackson methods.
The three programs mentioned below can be found on the CD. Their file names are,, and You should print them for reference at hand before reading the following.
In the original Postscriptlevel1, The Type1 and Type3 fonts provided by Postscript are applicable only to word sets smaller than 256 words. Therefore, Postscript provides additional type0 fonts (note 2) in level2, which is generally called compositefont. It does not have any information about fonts. On the contrary, it is used to combine multiple different fonts into one. That is to say, a 13095-character word set requires 52 fonts to be loaded, we can use a type0 to represent these fonts. More clearly, a dual-Bitte word set has two single-bit tuples. we can regard the first single-bit tuples as the font code, and the second single-bit tuples as the font index. If you are interested, you can find a detailed description of the Postscript font in the Appendix. The following describes how to select the correct font definition for the Jackson font from the dual-tuples. I suppose you have some knowledge about the Postscript Group literacy methods, and I try to reuse the font functions as much as possible. For more information, see the appendix or PostscriptLanguageReferenceManual.
First, I listed a short program code in KaiSu-Regular and added some annotations to it. I put it in on the disc. %! The annotation at the beginning is the execution status of the row stack (note 1), which is not in the original font. If the program does not understand it does not matter, you can directly explain the operation process by me. Note 1: Postscript is a stack-oriented language, which is similar to forth. It is also a post-order algorithm and puts the result on the stack. NOTE 2: This extension also exists in some levelI systems.
A Jackson font is a Type0 font which is divided into 89 subfonts. Each font has 158 characters, which is exactly the BIG5 encoding method. The first code of BIG5 is 0xa1-0xf9, and the second code is 0x40-0x7e and 0xa1-0xfe. There are 158 different codes. Therefore, Jackson adopts the ing method of 8/8. The above/bc is the BuildChar program in each sub-font. This program is the program that type3 fonts are used to draw words, before calling this program, Postscript will stack the dictionary and index, which should be removed from the stack after execution.
Because the number of characters in a text set is too large, we cannot load the definition of all characters into memory at a time like an English text set. The above program is used for dynamic loading. It loads fonts only when it is actually used. However, this program can be improved, we can store the definition loaded each time in the dictionary, so that when the second time is used, we don't have to load the definition in the file every time.
The above program also has a negotiable point, which gives up the use of fontcache. This may greatly affect the speed of the program. I still don't quite understand the reason why it gave up. I may have to try it, but the speed in Ghostscript seems acceptable.
Let's take a look at the definition of all-in-one font. It is because each font is the same except Offsets. I will only list the font whose first element is 0xF9 as an example. I put this part of the program in the file.
The first code is the font definition of 0xf9, and the rest is roughly the same. It is first copied from the CFT1JacksonFontdict to various types of font data./DataFile is the name of the font data file, And/BuildChar refers to the aforementioned/bc. It is worth noting that the last item/Offsets is an array with a length of 158*3. Each item is the starting position of the relative character in the document.
Now we have prepared all Type3 fonts. Finally, let's take a look at how the type0 fonts of KaiSu-Regular combine the 89 previously defined fonts, learn how the Postscript interpreter reads correct numbers of characters. Please refer to the File
In the definition of/KaiSu-Regular, we can see that its character translation mode is 6 (Note), which means that it uses messages in SubsVector to interpret the input string. Its SubsVector is defined
/SubsVector <00802158> def
1st 00 indicates that one character is read each time. The three digits at the end indicate that the entire font is divided into four sections, which are 0-3 Characters in sequence. Then, the actual font number is extracted from/Encoding, here it is exactly 0-3, and then the actual font is extracted from/FDepVector. The above process is intended to distinguish Chinese and English fonts, if the actual font range is listed.
0-0x7f 0th Font/_ @ ASCII
0x80-0xa0 1st Font/NotDefFont
0xa1-0xf9 font 2nd/CFT1JacksonFontSupp
0xfa-0xff 3rd Font/NotDefFont
This is the definition of the BIG5 code. In this process, only the valid first code actually uses the Jackson font, And the rest uses the original font.
Therefore, the process of extracting a text element is as follows. Take 0xa10x40 as an example.
KaiSu-Regular can see 0xa10x40, take out encoding As 2, and get/CFT1JacksonFontSupp in/FDepVector, which is also a typ20 font.
/CFT1JacksonFontSupp is an 8/8mapping type0 font. 0 is taken from/Encoding using 0xa1 as the index. Therefore,/FDepVector obtains the first/CFT1JacksonFontA1.
Stack CFT1JacksonFontA1 into the stack, and push 0x40 into the stack. Call/BuildChar, that is, the aforementioned/bc.
The/bc index 0x40 obtained from/Encoding in CFT1JacksonFontA1 is 0, so the position of the file obtained from Offsets is 0 and the length is 9.
Read this character definition, which is an encrypted character definition string (encrypedcharstrings) of type1 ).
Make a temporary font named exist/CFT1JacksonFontTemp, create a font, and put the character definition read above in it.
Use the show command to print the characters in the temporary Type1 font.
It seems complicated, but the speed of Ghostscript is acceptable and the memory used is acceptable. However, I have a little doubt about its speed in DiplayPostscript.
How to get a Postscript font from TTF Conversion
I can see that many people have accelerated their heartbeats! However, I declare that here I will only give you a recipe without any background. Just like Chinese Postscript fonts, we do not have any free TTF fonts. Therefore, it is impossible for me to use any TTF font as a Postscript font for you. I can only tell you the method, so you have to try the result on your own. It may not be easy. If you decide to try it yourself, check whether your configuration is sufficient.
(1) Of course there must be at least one set of Chinese TTF fonts.
(2) At least 16 MB of memory should be at least 20 mb.
(3) If the disk space is at least 50 MB, the larger the disk space, the more comfortable the work, because you do not have to delete the files generated in the middle. (4) A lot of time and patience
If you are ready, start with me!
The program ttf2limn is obtained from the same subdirectory of easyflow. It can generate a 158-word pk font file by TTF. Usage:
Ttf2mpo ntk5161.1440pkntk51611108161-s10-H0.75-D0.25-y150/cdrom/big5_k5.01 _
It generates two ntk5161.1440pk and ntk5161.tfm files. The preceding parameters are similar to those used in ttf2pk. The only difference is that the starting incode generated by the original font and the ending incode are now simplified to 161, it is the first code that generates the font in the font file. If you want to generate a font starting with 162
Ttf2mpo ntk5162.1440pkntk51621440162-s10-H0.75-D0.25-y150/cdrom/big5_k5.01 _
The limn program is obtained from the same location. It can generate a type1 box word by fit in the pk file generated above. It has many parameters that must be adjusted, and below is what I use, you can refer to the files in the fontutils-0.6. Fontutils-0.6 is a GNU product.
Limn-verbose-corner-surround = 8
-Filter-surround = 12
-Filter-alternative = 6
-Subdivide-surround = 12
-Tangent-surround = 12
-Error-thre shold = 0.6
-Subdivide-threshold = 0.01
-Filter-iterations = 1
-Reparameterize-threshold = 10
Obtain the type1 font generated by bzrto. Its usage is
Generate 58 fonts one by one, and the names are sequential
I wrote a program in perl to automate the process of generating these files. Its usage is
Maketype1ntk52880/cdrom/big5_k5.01 _
| + ----- ++ ------ Path of the TTF Archive
Font Name |
The font size generated when ttf2limn is used. Of course, the larger the font size, the better the hard disk .....
This command will automatically execute all the actions above (1) (2) (3. With this command, you can go to bed and wake up and it may be just done.
Extract the Type1 character definition from the preceding file to form a character definition file. There is a program makeup_jackson on the CD to do this.
# Makeup_jacksonntk536001
This will generate a file named ntk5.hex and a file named ntk5.pf0. It was modified by the aforementioned KaiSu-Regular. The second parameter is the UID of the font. Be sure not to repeat the UID of other fonts.
The ntk5.hex generated in the previous step is an archive encoded in hex string format. We usually convert it into binary files to save space and increase processing speed. I provide hextobin to do this, it is designed as a filter type, the usage is
Install ntk5.pf0 and ntk5.dat in/usr/lib/ghostscript/fonts and add them to/usr/lib/ghostscript/Fontmap.
/Ntk5 (ntk5.pf0 );
Take a test of the program below to see your results. Note that the first line of the program loads a Postscript file, which defines some definitions that will be used in the font. It can be obtained together with other programs
100100 moveto
It seems not difficult, but it will take at least one day for you. If you are interested, try it. Maybe we can build an automatic system so that everyone can easily generate fonts. The fonts produced by this program are all inflated, because we use the same parameters for simple fonts or complex fonts during fit work, therefore, the simple font will inevitably be a bit fat. In the case of a full-form comma, 8 yuan is represented in the Jackson font, but in the above process, the big5_k5.ttf text is used as an example, it is up to 53 yuan. To eliminate this situation, you may need a program that can set parameters in character units, and many people will be involved to do so.
Print Chinese text files with Jackson font
Finally, I will introduce a very simple perlscript that can be used to print medium files using Jackson. Its function is simple, but it is enough to solve the problem of printing most Chinese characters. Its usage is makeps [-f] font name, for example, the font size of the Postscript file generated by the file to be printed by/KaiSu-Regular can be used to verify the generated Postscript font or any other source Postscript font, it is printed in two columns. Of course, this program has not been tested too much, and there may be many questions. You can directly report the questions to the author. If you tell me the answer by the way, it would be best.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.