Features to support CJK CID-keyed font in Ghostscript

Table of contents

Impatient users looking for step-by-step installation notes for CJK fonts should check gs-cjk documents at

Font license

As we note in "Adding your own fonts", you have to read the license of fonts carefully. The fact you obtain the fonts legally does not mean always that you can use them with Ghostscript. Usually, outline fonts for east Asian scripts are licensed under more restricted conditions in comparison with ASCII or Latin fonts, because they must provide a large number of glyphs, more than 8000 glyphs. For example, Adobe licenses the Asian font package for Acrobat Reader as "solely for Acrobat Reader". So even if your system have pre-installed Acrobat Reader, you cannot use its Asian fonts in Ghostscript.

About OCF fonts

Prior to PostScript level 2015, PostScript fonts for multibyte encoded script (Chinese, Japanese, Korean and Vietnamese etc) were implemented as a collection of many elemental Type1/Type3 fonts and a selector. Today these fonts are known as OCF (Original Composite Font). Ghostscript fully supports OCF.

Adobe has announced that OCF is obsolete. For details of OCF, refer

"CJKV Information Processing" (Ken Lunde, O'Reilly 1999) p. 281,
"PostScript Language Reference Manual, third edition" p. 357 href="
"PostScript Language Tutorial and Cookbook, Japanese edition" (Adobe Systems, Incorporated, ASCII Corporation 1989) pp. 241-271,
and Technical Notes for CID-keyed fonts.

About CID-keyed fonts

In PostScript level 2015, Adobe introduced a new font format "CID-keyed font" for CJK scripts. For details of the CID-keyed font format, refer

"PostScript Language Reference Manual, third edition" p. 364
Technical Specification #5014 "Adobe CMap and CIDFont Files Specification"
Technical Specification #5092 "CID-keyed Font Technology Overview"
Ghostscript provides the basic functionalities of CID-keyed fonts, but the "rearranged font" feature is not implemented. The present functionalities are enough for common usage. Some Japanese PostScript programs expect that any system that supports CID-keyed fonts will also support "rearranged font". Such programs do not work well with ghostscript. Chinese and Korean scripts were never officially supplied by OCF, so such problems are rare.

The CID-keyed font format has a double layered structure. The lower layer is a CID-keyed font. The public interface of the CID-keyed font is a 16-bit CID (character identifier) number which is given to each unique "glyph" for subsets of various scripts. This is not a "character" code like ASCII/Unicode/etc. Adobe specifies CIDs for CJK scripts: Adobe-CNS1 & 2 (Traditional Chinese Hanzi glyphs), Adobe-GB1 (Simplified Chinese Hanzi glyphs), Adobe-Japan1 & 2 (Japanese Kana and Kanji glyphs), Adobe-Korea1 & 2 (Hangul and Hanja glyphs), Adobe-HongKong1 (Traditional Chinese Hanzi in HongKong), and Adobe-Vietnam1 (Chu-Han). The catalogues of glyphs for some CIDs are published by Adobe, refer Technical Notes service of Adobe:

A CID-keyed font must provide the CID number interface, but the format of the glyph data may vary:

The higher layer is a CMap. A CMap provides a map from the multibyte character code to the CID of corresponding glyph, under a specified encoding system. PostScript fonts must provide a character code interface, so a bare CID-keyed font cannot be used as normal PostScript font without a CMap (e.g. findfont, show, etc are not usable, however glyphshow operator is usable for a bare CID-keyed font). In a CID-keyed font system, the various encoding systems can be supported by higher layer only. The lower layer is sharable.

A CMap file is stored in the /CMap resource category and the CID-keyed font file is stored in the /CIDFont resource category. Several operators introduced for CID-keyed fonts assume these locations, so CMap and CIDFont must not be stored in the /Font resource used traditionally used by PostScript fonts.

For "named resource category", refer Finding PostScript Level 2 resources of Ghostscript.

Adobe distributes their official CMap (redistributable but no modification is permitted) on O'Reilly ftp site:
To use CID-keyed font, these CMap files must be installed into the CMap resource directory.

CIDFontType 0

CIDFontType0 is the most standard CIDFont of PostScript. It consists of two separated parts: PostScript program and attached binary data. The glyph data is stored in attached binary part and is dynamically accessed. In comparison with OCF, loading a CIDFontType0 is light-weight and comsumes less memory.

To make Ghostscript recognize a CIDFontType0 font is easy. If the CIDFontType0 font file is installed into a directory named "CIDFont" under GenericResourceDir (see Finding PostScript Level 2 resources), Ghostscript will find it when searching for resources in /CIDFont category.

CJK TrueType font and CIDFontType 2

In PostScript 2010, Adobe introduced the Type42 font format to embed a host-based TrueType font into a PostScript program. For details of the Type42 font format, refer to

The Type 42 Font Format Specification. Technical Note #5012 "
CIDFontType2 is a CID extension of the Type42 font format. If Ghostscript is compiled with ttfont device and CMap files are installed, Ghostscript is capable of handling CIDFontType2 resource embedded in PostScript program or PDF document. The Type42 font specification notes that Type42 is an installable font format, but there's no font distributed in the Type42 format. This is a big difference from the standard PostScript fonts: Type1, Type3 and CIDFontType0.

Ghostscript now provides "on-the-fly CIDFontType2 converter" for CJK TrueType, similar to the "on-the-fly Type42 converter" for Roman TrueType fonts. This does not mean you can perfectly substitute a required PostScript fonts by a TrueType font. CJK TrueType font often lack many non-popular glyphs and a few popular glyphs in Adobe CID. As a result, a TrueType font (designed as screen font for window system) cannot be a perfect replacement for an Adobe PostScript font Refer CJKTTCID.htm for further particulars.

The operator .openttcidfont constructs CIDFontType2 font dictionary from a given TrueType font. .openttcidfont requires extra CMaps for PDF available from:
The basic syntax of .openttcidfont is:
<ttf_filename> .openttcidfont

When a font file in Microsoft's TrueType Collection format (a font file with suffix .ttc includes multiple fonts in single file) is given, the first font in it is used by default. To specify a font manually, index of the font should be passed to .openttcidfont, as:

<ttc_filename> 2 .openttcidfont

Old TrueType fonts were encoded by CJK-system specific encodings (e.g. Big5, Johab, ShiftJIS, etc) without stating what encoding is used. On the other hand, recent TrueType fonts are encoded by Unicode, but included glyphs are limited to specific language. By default, .openttcidfont detects encoding of TrueType font and the suitable Adobe CID automatically, but if you have trouble, these parameters should be specified manually. To specify Adobe CID and TrueType encoding explicitly, pass a name object as:

<ttf_filename> /Adobe-Japan1-ShiftJIS .openttcidfont
In such syntax, Adobe-Japan1 specifies Adobe CID to be mapped, and ShiftJIS specifies the encoding of TrueType fonts. Currently supported Adobe CIDs are:
and, supported TrueType encodings are:
In addition about on-the-fly CIDFontType2 conversion of TrueType fonts (of Big5, PRC, ShiftJIS, Wangsung), .openttcidfont requires more extra CMap files which are available from Asian font packages for Adobe Acrobat Reader. See "Adobe CMaps" subsection of "Fonts and font facilities supplied with Ghostscript" section.

About "CIDFnmap" of Ghostscript

By applying various CMap to single CIDFont, various font resources can be generated. To utilize this feature conveniently, "CIDFnmap" is introduced. CIDFnmap is similar to Fontmap, but it handles resource name of CIDFont.

To map all /Ryumin-Light-* fonts (/Ryumin-Light-H, /Ryumin-Light-RKSJ-H etc) derived from /Ryumin-Light CIDFont to those from /WadaMin-Regular, following single entry works enough:

/Ryumin-Light /WadaMin-Regular ;
Also CIDFnmap can define a resource from a file specified with full path, it is convenient to import resource from out of Ghostscript directory tree:
/WadaMin-Regular (/usr/lib/X11/fonts/CIDFont/WadaMin-Regular) ;
If the given file is TrueType font, CIDFnmap automatically detect it, and execute .openttcidfont:
/HG-MinchoL (/usr/openwin/lib/locale/ja/X11/fonts/TT/HG-MinchoL.ttf) ;
Other operands for .openttcidfont (TTC index, CID/encoding specification) can be specified as:
/HeiseiMin-W3H (/usr/openwin/lib/locale/ja/X11/fonts/TT/HeiseiMin-W3H.ttf) /Adobe-Japan2-Unicode ;
/Ryobi-PGothic (/usr/X11R6/lib/X11/fonts/TrueType/tcgothb.ttc) 2 /Adobe-Japan1-Unicode ;

For detail, please refer included sample CIDFnmap. For the sites to get font itself, refer Fonts.htm.

For free CJK CIDFontType0 fonts manufactured by Adobe.
For free Hangul TrueType fonts manufactured by Hwan Design Inc..
For free Simplified/Traditional Chinese TrueType fonts manifactured by Arphic Technology.
Japanese TrueType fonts and free CIDFontType0 version of them, Kochi Mincho and Gothic.
For CJK TrueType fonts bundled on Solaris 8 International edition.
For CJK TrueType fonts bundled on Windows.
Aliasing for printer-based CJK fonts (/HYGoThic-Medium, /MSung-Light, /Ryumin-Light, /STSong-Light, etc) and fallback font definitions for missing fonts in PDF.
CIDFnmap.b5,, CIDFnmap.ksx,
Aliasing locale-specific CIDFontNames which are often required with multi-byte encoding in PS/PDF files.
NOTE: In gs7.2x and later release, "CIDFnmap" feature will be merged into new mapping feature: "cidfmap" and "CIDFnmap" itself will be removed.

There are CJK samples in examples/cjk:,,,, (drawing all glyphs in Adobe CID for Traditional Chinese, Simplified Chinese, Japanese, Japanese Hojo Kanji, Korean),,, (drawing short texts in horizontal and vertical writing modes) and multilingual sample (this sample loads many fonts for various scripts, quite heavy). gscjk_* samples are written in Asian character encoding and is in ISO-2022, not pure ASCII. To modify them, an internationalized or binary capable editor are recommended.

For proofing by PostScript printers (for Asian market), these samples use standard printer-based CJK fonts: /HYGoThic-Medium, /MSung-Light, /Ryumin-Light, /STSong-Light etc. To display them correctly by Ghostscript, printer-based fonts must be aliased to available fonts on Ghostscript. CIDFnmap.CJK lists known printer-based CJK fonts, modify it for your own environment.

This section by Suzuki Toshiya and gs-cjk project. <>

Copyright © 2001 gs-cjk project <>.

Copyright © 2002 artofocode LLC. All rights reserved.

This file is part of GNU Ghostscript. See the GNU General Public License (the "License") for full details of the terms of using, copying, modifying, and redistributing GNU Ghostscript.

Ghostscript version 7.07, 17 May 2003