Tips on PostScript

[Back] [Japanese Page]

Text filter into PostScript - tops

Distribution

Keywords

m2ps, coco, Emacs/Mule, iconv, lv, a2ps, mpage, gs-cjk

References

  1. Adobe Systems Incorporated, ``Chapter 4 - Emulators and Translators,'' in ``PostScript Language Program Design,'' Addison-Wesley, pp. 59--75, 1988.
  2. Adobe Systems Incorporated, ``Adobe Solutions Network: PostScript Technical Notes,'' http://partners.adobe.com/asn/developer/technotes/postscript.html, 2000-2001.

Embed CIDFont/CMap into PostScript file - embresps

Distribution

Requirements

PostScript 3 printer, gs-cjk, CIDFontType0 fonts

On Ghostscript 6, let us use CJK(Chinese, Japanese, Korean) TrueType fonts as CID-Keyed fonts

[2000/3/24] I made a patch to use CJK(Chinese: PRC, Big5 or Unicode, Japanese: Shift-JIS or Unicode, Korean: Wansung, Johab or Unicode) TrueType fonts as CID-Keyed fonts on Ghostscript 6, based on this site by Mr. Hideyuki Suzuki. The features of this patch for gs_ttf.ps of GS 6 as follows:
  1. Automatically detects the kind CID(CNS1, GB1, Japan1 or Korea1) by reading some tables in a TrueType font
  2. Uses a /Resource/TrueType/* file for an inverse map from CIDs to codes of a TrueType font
  3. [2000/4/17] Prepares vertically-oriented glyphs for vertically-used CIDs by reading the GSUB table of a TrueType font

Patch and Resource/TrueType/* files

These resources are distributed under the BSD licnese. About the way to install TrueType fonts, please read the following sections.

How to change /Resource/ directory of Ghostscript 6

If you want to change /Resource directory to another one such as /usr/local/share/ghostscript/Resource, please modify /GenericResourceDir in gs_res.ps of GS 6 as follows:
/GenericResourceDir (/usr/local/share/ghostscript/Resource/) readonly .forcedef
If you also want to change /Resource/Font directory, in the case of GS 6.01, please modify /FontResourceDir in gs_res.ps as follows:
/FontResourceDir (/usr/local/share/ghostscript/Resource/Font/) readonly .forcedef
But, in the case of GS 6.0, modifying /FontResourceDir doesn't work because gs_res.ps has a bug at about 670th line. The correct code is 4 times 'pop' not 5 times as follows:
pop pop pop pop true exit

How to install CJK CID-Keyed fonts to Ghostscript 6

I explain how to install CID-Keyed fonts to GS 6.

First, please obtain following CMap files from ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/,

and extract these archives in /Resource directory of GS. As an example, I explain the case of ac13(Adobe-CNS1).
% cd /usr/local/share/ghostscript/Resource
% tar xvZf ac13.tar.Z
Please make /Resource/CMap directory and link CMap files to this directory,
% mkdir CMap
% cd CMap
% ln -s ../ac13/CMap/* .
and make /Resource/CIDFont and /Resource/Font directories.
% cd /usr/local/share/ghostscript/Resource
% mkdir CIDFont
% mkdir Font
Next, obtain one of following CID-Keyed fonts from ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/samples/. As an example, I use a CID-Keyed font of Adobe-CNS1, ``MOEKai-Regular''.

Here, please get install-cid-*.tar.gz which is a simple installer of CID-keyed fonts and extract this archive in /Resource directory.

% cd /usr/local/share/ghostscript/Resource
% tar xvzf install-cid-20010208.tar.gz
To apply all CMap resources of Adobe-CNS1 to MOEKai-Regular, please try to execute as follows:
% ac13.sh install MOEKai-Regular
then, all resource files are automatically generated in /Resource/Font directory. One of /Resource/Font/MOEKai-Regular-* is shown as follows:
%!PS-Adobe-3.0 Resource-Font
%%DocumentNeededResources: ETen-B5-H (CMap)
%%IncludeResource: ETen-B5-H (CMap)
%%BeginResource: Font (MOEKai-Regular-ETen-B5-H)
/MOEKai-Regular-ETen-B5-H
/ETen-B5-H /CMap findresource
[/MOEKai-Regular /CIDFont findresource]
composefont pop
%%EndResource
%%EOF
Now, on GS 6, you can use /MOEKai-Regular-ETen-B5-H, /MOEKai-Regular-UniCNS-UCS2-H and so on.

How to uninstall CJK CID-Keyed fonts

To delete generated files, please command as follows:
% ac13.sh uninstall MOEKai-Regular

How to install CJK TrueType fonts to Ghostscript 6

I explain how to install CJK TrueType fonts to GS 6. The way described in this section requires the patch and resource files introduced in the top of this page. Please extract the resource files in /Resource/TrueType as follows:
% cd /usr/local/share/ghostscript/Resource
% mkdir TrueType
% cd TrueType
% tar xvzf cjkvttcidmap-0.92.tar.gz
First, please be guided by procedures described in ``How to install CJK CID-Keyed fonts to Ghostscript 6'' until preparing a simple installer of CID fonts, install-cid-*.tar.gz.
Next, I explain about a TrueType font used in Taiwan, ``Abig5.ttf'' in /usr/local/share/fonts/truetype as an example.

To build a CID-Keyed font from a TrueType font and apply all CMap resources of Adobe-CNS1 to the generated CIDFont resource, please try to execute as follows:

% cd /usr/local/share/ghostscript/Resource
% alias-ac13.sh install AcademyBIG5=Abig5.ttf
then, /Resource/CIDFont/AcademyBIG5 is generated and is shown as follows:
%!PS-Adobe-3.0 Resource-CIDFont
%%BeginResource: CIDFont (AcademyBIG5)
/AcademyBIG5
(/usr/local/share/fonts/truetype/Abig5.ttf) .openttcidfont
dup length dict begin {def} forall currentdict end
/CIDFont defineresource pop
%%EndResource
%%EOF
and all resource files are also generated in /Resource/Font directory by internally using ac13.sh in alias-ac13.sh. One of /Resource/Font/AcademyBIG5-* is shown as follows:
%!PS-Adobe-3.0 Resource-Font
%%DocumentNeededResources: CNS1-H (CMap)
%%IncludeResource: CNS1-H (CMap)
%%BeginResource: Font (AcademyBIG5-CNS1-H)
/AcademyBIG5-CNS1-H
/CNS1-H /CMap findresource
[/AcademyBIG5 /CIDFont findresource]
composefont pop
%%EndResource
%%EOF
Now, on GS 6, you can use /AcademyBIG5-CNS1-H, /AcademyBIG5-UniCNS-UCS2-H, and so on.

How to uninstall CJK TrueType fonts

To delete generated files, please command as follows:
% alias-ac13.sh uninstall AcademyBIG5

Usages of alias-*.sh

Direct the kind of CID in a font name not to automatically detect from a TrueType font
% alias-ac13.sh install Arial-Adobe-CNS1=arialuni.ttf

Designate an index of a TTC(TrueType Collection) font
% alias-ag13.sh install NSimSun=simsun.ttc,2

Name alias ``Ryumin-Light'' a CID-keyed font ``MS-Mincho''
% alias-aj14.sh install Ryumin-Light=MS-Mincho

Designate an inverse map not to automatically detect from a TrueType font
% alias-aj14.sh install FA-Gothic,Adobe-Japan1-Unicode=FANGOT5.TTC

Install more than one font
% alias-ak12.sh install Batang=batang.ttc BatangChe=batang.ttc,2


PostScript examples for testing

Simple CJK PostScript files for testing

CJK PostScript files for detailed test

Encodings of CID-Keyed fonts with CJK TrueType fonts

Copyright (C) 2000-2002 Taiji Yamada, All rights reserved.