summaryrefslogtreecommitdiff
path: root/Master/xemtex/doc/ghostscript/CJK.htm
blob: 9833db35da4cdd3ce071984e3f30e8739f390c0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
<html>
<head>
<title>Features to support CJK CID-keyed in Ghostscript</title>
<!-- $Id: CJK.htm,v 1.1.4.8.2.5 2003/05/17 14:38:59 giles Exp $ -->
<link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style">
</head>

<body>
<!-- [1.0 begin visible header] ============================================ -->

<!-- [1.1 begin headline] ================================================== -->

<h1>Features to support CJK CID-keyed font in Ghostscript</h1>

<!-- [1.1 end headline] ==================================================== -->

<!-- [1.2 begin table of contents] ========================================= -->

<h2>Table of contents</h2>

<blockquote><ul>
<li><a href="#Font_License">Font license</a>
<li><a href="#About_OCF_fonts">About OCF fonts</a>
<li><a href="#About_CID_keyed_fonts">About CID-keyed fonts</a>
<ul>
  <li><a href="#About_CIDFontType0">CIDFontType 0</a>
  <li><a href="#About_CIDFontType2">CJK TrueType font and CIDFontType 2</a>
</ul>
<li><a href="#About_CIDFnmap">About "CIDFnmap" of Ghostscript</a>
</ul></blockquote>

<!-- [1.2 end table of contents] =========================================== -->

<!-- [1.3 begin hint] ====================================================== -->

<p>Impatient users looking for step-by-step installation notes for
CJK fonts should check gs-cjk documents at
<a href="http://www.gyve.org/gs-cjk/supplement/">
http://www.gyve.org/gs-cjk/supplement/</a>.

<!-- [1.3 end hint] ======================================================== -->

<hr>

<!-- [1.0 end visible header] ============================================== -->

<!-- [2.0 begin contents] ================================================== -->



<h2><a name="Font_license"></a>Font license</h2>
<p>
As we note in <a href="Fonts.htm#Add_fonts">"Adding your own fonts"</a>,
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.


<h2><a name="About_OCF_fonts"></a>About OCF fonts</h2>
<p>
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.


<p>
Adobe has announced that OCF is obsolete.
For details of OCF, refer<br>
<blockquote>
"CJKV Information Processing" (Ken Lunde, O'Reilly 1999) p. 281,<br>
"PostScript Language Reference Manual, third edition" p. 357
<a
href="http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf"
class="offsite">
href="http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf
</a><br>
"PostScript Language Tutorial and Cookbook, Japanese edition" (Adobe Systems, Incorporated, ASCII Corporation 1989) pp. 241-271,<br>
</blockquote>
and Technical Notes for CID-keyed fonts.


<h2><a name="About_CID_keyed_fonts"></a>About CID-keyed fonts</h2>
<p>
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<br>
<blockquote>
"PostScript Language Reference Manual, third edition"</a> p. 364
<a
href="http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf"
class="offsite">
http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf</a><br>
Technical Specification #5014 "Adobe CMap and CIDFont Files Specification"
<a
href="http://partners.adobe.com/asn/developer/pdfs/tn/5014.CMap_CIDFont_Spec.pdf"
class="offsite">
http://partners.adobe.com/asn/developer/pdfs/tn/5014.CMap_CIDFont_Spec.pdf
</a><br>
Technical Specification #5092 "CID-keyed Font Technology Overview"
<a href="http://partners.adobe.com/asn/developer/pdfs/tn/5092.CID_Overview.pdf"
class="offsite">
http://partners.adobe.com/asn/developer/pdfs/tn/5092.CID_Overview.pdf
</a><br>
</blockquote>
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.

<p>
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 &amp 2 (Traditional Chinese Hanzi glyphs),
Adobe-GB1 (Simplified Chinese Hanzi glyphs),
Adobe-Japan1 &amp; 2 (Japanese Kana and Kanji glyphs),
Adobe-Korea1 &amp; 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:<br>
<blockquote>
<a
href="http://partners.adobe.com/asn/developer/technotes/fonts.html"
class="offsite">
http://partners.adobe.com/asn/developer/technotes/fonts.html</a>
</blockquote>




<p>
A CID-keyed font must provide the CID number interface,
but the format of the glyph data may vary:<br>
<ul>
<li>CIDFontType 0 (FontType 9, CID-keyed Type1 font),</li>
<li>CIDFontType 1 (FontType 10, CID-keyed Type3 font),</li>
<li>CIDFontType 2 (FontType 11, CID-keyed Type42 font - TrueType)</li>
</ul>






<p>
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. <tt>findfont</tt>, <tt>show</tt>,
etc are not usable, however <tt>glyphshow</tt> 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.

<p>
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.

<p>
For "named resource category", refer
<a href="Use.htm#PS_resources">Finding PostScript Level 2 resources</a> of Ghostscript.

<p>
Adobe distributes their official CMap (redistributable but no modification
is permitted) on O'Reilly ftp site:
<blockquote>
<a
href="ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/"
class="offsite">
ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/</a>
</blockquote>

To use CID-keyed font, these CMap files must be installed into the CMap
resource directory.



<h3><a name="About_CIDFontType0"></a>CIDFontType 0</h2>
<p>
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.

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




<h3><a name="About_CIDFontType2"></a>CJK TrueType font and CIDFontType 2</h2>
<p>
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
<blockquote>
The Type 42 Font Format Specification. Technical Note #5012
<a
href="http://partners.adobe.com/asn/developer/pdfs/tn/5012.Type42_Spec.pdf"
class="offsite">
"http://partners.adobe.com/asn/developer/pdfs/tn/5012.Type42_Spec.pdf
</a>
</blockquote>
CIDFontType2 is a CID extension of the Type42 font format.
If Ghostscript is compiled with 
<a href="Make.htm#Features_and_devices">ttfont device</a>
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.

<p>
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 <a href="CJKTTCID.htm">CJKTTCID.htm</a> for further particulars.

<p>
The operator <b><tt>.openttcidfont</tt></b> constructs CIDFontType2
font dictionary from a given TrueType font. <b><tt>.openttcidfont</tt></b>
requires extra CMaps for PDF available from:

<blockquote>
<a
href="http://partners.adobe.com/asn/developer/technotes/acrobatpdf.html"
class="offsite">
http://partners.adobe.com/asn/developer/technotes/acrobatpdf.html
</a>
</blockquote>

The basic syntax of <b><tt>.openttcidfont</tt></b> is:<br>
<blockquote>
<b><tt>&lt;ttf_filename&gt; .openttcidfont</tt></b><br>
</blockquote>

<p>
When a font file in Microsoft's TrueType Collection format
(a font file with suffix <b><tt>.ttc</tt></b>
 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 <b><tt>.openttcidfont</b></tt>, as:<br>

<blockquote>
<b><tt>&lt;ttc_filename&gt; 2 .openttcidfont</tt></b><br>
</blockquote>

<p>
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, <b><tt>.openttcidfont</tt></b> 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:

<blockquote>
<b><tt>&lt;ttf_filename&gt; /Adobe-Japan1-ShiftJIS .openttcidfont</tt></b><br>
</blockquote>

In such syntax, Adobe-Japan1 specifies Adobe CID to be mapped,
and ShiftJIS specifies the encoding of TrueType fonts.
Currently supported Adobe CIDs are:<br>

<blockquote>
<b><tt>Adobe-CNS1</tt></b><br>
<b><tt>Adobe-GB1</tt></b><br>
<b><tt>Adobe-Japan1</tt></b><br>
<b><tt>Adobe-Japan2</tt></b><br>
<b><tt>Adobe-Korea1</tt></b><br>
</blockquote>

and, supported TrueType encodings are:<br>

<blockquote>
<b><tt>Big5</tt></b><br>
<b><tt>Johab</tt></b><br>
<b><tt>PRC</tt></b><br>
<b><tt>ShiftJIS</tt></b><br>
<b><tt>Unicode</tt></b><br>
<b><tt>Wansung</tt></b><br>
</blockquote>

In addition about on-the-fly CIDFontType2 conversion of TrueType fonts
(of Big5, PRC, ShiftJIS, Wangsung), <tt>.openttcidfont</tt> requires
more extra CMap files which are available from Asian font packages for
Adobe Acrobat Reader. See <a href="Fonts.htm#CMap_Adobe"> "Adobe
CMaps" subsection</a> of "Fonts and font facilities supplied with
Ghostscript" section.



<h2><a name="About_CIDFnmap"></a>About "CIDFnmap" of Ghostscript</h2>
<p>
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.

<p>
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:<br>

<blockquote>
<b><tt>/Ryumin-Light&nbsp;/WadaMin-Regular&nbsp;;</tt></b><br>
</blockquote>

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:<br>

<blockquote>
<b><tt>/WadaMin-Regular&nbsp;(/usr/lib/X11/fonts/CIDFont/WadaMin-Regular)&nbsp;;</tt></b><br>
</blockquote>

If the given file is TrueType font, CIDFnmap automatically detect it, and
execute <b><tt>.openttcidfont</tt></b>:<br>

<blockquote>
<b><tt>/HG-MinchoL&nbsp;(/usr/openwin/lib/locale/ja/X11/fonts/TT/HG-MinchoL.ttf)&nbsp;;</tt></b><br>
</blockquote>

Other operands for <b><tt>.openttcidfont</tt></b> (TTC index, CID/encoding
specification) can be specified as:<br>

<blockquote>
<b><tt>
/HeiseiMin-W3H&nbsp;(/usr/openwin/lib/locale/ja/X11/fonts/TT/HeiseiMin-W3H.ttf)&nbsp;/Adobe-Japan2-Unicode&nbsp;;<br>
</blockquote>
<blockquote>
/Ryobi-PGothic&nbsp;(/usr/X11R6/lib/X11/fonts/TrueType/tcgothb.ttc)&nbsp;2&nbsp;/Adobe-Japan1-Unicode&nbsp;;<br>
</tt></b>
</blockquote>


<p>
For detail, please refer included sample CIDFnmap. For the sites
to get font itself, refer <a href="Fonts.htm">Fonts.htm</a>.

<dl>
<dt>CIDFnmap.Ore</dt>
<dd>
        For free CJK CIDFontType0 fonts manufactured by Adobe.
</dd>

<dt>CIDFnmap.Bae</dt>
<dd>
        For free Hangul TrueType fonts manufactured by Hwan Design Inc..
</dd>

<dt>CIDFnmap.ARP</dt>
<dd>
        For free Simplified/Traditional Chinese TrueType fonts
        manifactured by Arphic Technology.
</dd>

<dt>CIDFnmap.Koc</dt>
<dd>
        Japanese TrueType fonts and free CIDFontType0 version of them,
        Kochi Mincho and Gothic.
</dd>

<dt>CIDFnmap.Sol</dt>
<dd>
        For CJK TrueType fonts bundled on Solaris 8 International edition.
</dd>

<dt>CIDFnmap.Win</dt>
<dd>
        For CJK TrueType fonts bundled on Windows.
</dd>

<dt>CIDFnmap.CJK</dt>
<dd>
        Aliasing for printer-based CJK fonts
        (/HYGoThic-Medium, /MSung-Light, /Ryumin-Light, /STSong-Light, etc)
        and fallback font definitions for missing fonts in PDF.
</dd>

<dt>CIDFnmap.b5, CIDFnmap.gb, CIDFnmap.ksx, CIDFnmap.sj</dt>
<dd>
        Aliasing locale-specific CIDFontNames which are often required
        with multi-byte encoding in PS/PDF files.
</dd>

</dl>


<b>NOTE:</b>
In gs7.2x and later release,
"CIDFnmap" feature will be merged into new mapping feature:
"cidfmap" and "CIDFnmap" itself will be removed.


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

<p>
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.





<p>
This section by Suzuki Toshiya and gs-cjk project.
&lt;<a href="mailto:mpsuzuki@gyve.org">mpsuzuki@gyve.org</a>&gt;

<!-- [2.0 end contents] ==================================================== -->

<!-- [3.0 begin visible trailer] =========================================== -->
<hr>

<font size=2>

<p>Copyright &copy; 2001 gs-cjk project
&lt;<a href="http://www.gyve.org/gs-cjk/">http://www.gyve.org/gs-cjk/</a>&gt;.
<p>Copyright &copy; 2002 artofocode LLC. All rights reserved.

<p>This file is part of GNU Ghostscript.  See the
<a href="COPYING">GNU General Public License</a> (the "License") for
full details of the terms of using, copying, modifying, and redistributing
GNU Ghostscript.

<p>
<small>Ghostscript version 7.07, 17 May 2003

</font>

<!-- [3.0 end visible trailer] ============================================= -->

</body>
</html>