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
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id$ */
package org.apache.fop.pdf;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
/**
* Class representing the CMap encodings.
*
* CMaps are defined in the "Predefined CJK CMap names" table.
* In section 5.6.4 of PDF reference 1.4.
*/
public class PDFCMap extends PDFStream {
/*
* Chinese (simplified)
*/
/**
* GB-EUC-H Microsoft Code Page 936 (lfCharSet 0x86), GB 2312-80
* character set, EUC-CN encoding
*/
public static final String ENC_GB_EUC_H = "GB-EUC-H";
/**
* GB-EUC-V Vertical version of GB-EUC-H
*/
public static final String ENC_GB_EUC_V = "GB_EUC_V";
/**
* GBpc-EUC-H Mac OS, GB 2312-80 character set, EUC-CN encoding, Script Manager code 19
*/
public static final String ENC_GBPC_EUC_H = "GBpc-EUC-H";
/**
* GBpc-EUC-V Vertical version of GBpc-EUC-H
*/
public static final String ENC_GBPC_EUC_V = "GBpc-EUC-V";
/**
* GBK-EUC-H Microsoft Code Page 936 (lfCharSet 0x86), GBK character set, GBK encoding
*/
public static final String ENC_GBK_EUC_H = "GBK-EUC-H";
/**
* GBK-EUC-V Vertical version of GBK-EUC-H
*/
public static final String ENC_GBK_EUC_V = "GBK-EUC-V";
/**
* GBKp-EUC-H Same as GBK-EUC-H, but replaces half-width
* Latin characters with proportional forms and maps character
* code 0x24 to a dollar sign ($) instead of a yuan symbol
*/
public static final String ENC_GBKP_EUC_H = "GBKp-EUC-H";
/**
* GBKp-EUC-V Vertical version of GBKp-EUC-H
*/
public static final String ENC_GBKP_EUC_V = "GBKp-EUC-V";
/**
* GBK2K-H GB 18030-2000 character set, mixed 1-, 2-, and 4-byte encoding
*/
public static final String ENC_GBK2K_H = "GBK2K-H";
/**
* GBK2K-V Vertical version of GBK2K-H
*/
public static final String ENC_GBK2K_V = "GBK2K-V";
/**
* UniGB-UCS2-H Unicode (UCS-2) encoding for the Adobe-GB1 character collection
*/
public static final String ENC_UNIGB_UCS2_H = "UniGB-UCS2-H";
/**
* UniGB-UCS2-V Vertical version of UniGB-UCS2-H
*/
public static final String ENC_UNIGB_UCS2_V = "UniGB-UCS2-V";
/*
* Chinese (Traditional)
*/
/**
* B5pc-H Mac OS, Big Five character set, Big Five encoding, Script Manager code 2
*/
public static final String ENC_B5PC_H = "B5pc-H";
/**
* B5pc-V Vertical version of B5pc-H
*/
public static final String ENC_B5PC_V = "B5pc-V";
/**
* HKscs-B5-H Hong Kong SCS, an extension to the Big Five
* character set and encoding
*/
public static final String ENC_HKSCS_B5_H = "HKscs-B5-H";
/**
* HKscs-B5-V Vertical version of HKscs-B5-H
*/
public static final String ENC_HKSCS_B5_V = "HKscs-B5-V";
/**
* ETen-B5-H Microsoft Code Page 950 (lfCharSet 0x88), Big Five
* character set with ETen extensions
*/
public static final String ENC_ETEN_B5_H = "ETen-B5-H";
/**
* ETen-B5-V Vertical version of ETen-B5-H
*/
public static final String ENC_ETEN_B5_V = "ETen-B5-V";
/**
* ETenms-B5-H Same as ETen-B5-H, but replaces half-width
* Latin characters with proportional forms
*/
public static final String ENC_ETENMS_B5_H = "ETenms-B5-H";
/**
* ETenms-B5-V Vertical version of ETenms-B5-H
*/
public static final String ENC_ETENMS_B5_V = "ETenms-B5-V";
/**
* CNS-EUC-H CNS 11643-1992 character set, EUC-TW encoding
*/
public static final String ENC_CNS_EUC_H = "CNS-EUC-H";
/**
* CNS-EUC-V Vertical version of CNS-EUC-H
*/
public static final String ENC_CNS_EUC_V = "CNS-EUC-V";
/**
* UniCNS-UCS2-H Unicode (UCS-2) encoding for the
* Adobe-CNS1 character collection
*/
public static final String ENC_UNICNS_UCS2_H = "UniCNS-UCS2-H";
/**
* UniCNS-UCS2-V Vertical version of UniCNS-UCS2-H
*/
public static final String ENC_UNICNS_UCS2_V = "UniCNS-UCS2-V";
/*
* Japanese
*/
/**
* 83pv-RKSJ-H Mac OS, JIS X 0208 character set with KanjiTalk6
* extensions, Shift-JIS encoding, Script Manager code 1
*/
public static final String ENC_83PV_RKSJ_H = "83pv-RKSJ-H"; // no V version
/**
* 90ms-RKSJ-H Microsoft Code Page 932 (lfCharSet 0x80), JIS X 0208
* character set with NEC and IBM extensions
*/
public static final String ENC_90MS_RKSJ_H = "90ms-RKSJ-H";
/**
* 90ms-RKSJ-V Vertical version of 90ms-RKSJ-H
*/
public static final String ENC_90MS_RKSJ_V = "90ms-RKSJ-V";
/**
* 90msp-RKSJ-H Same as 90ms-RKSJ-H, but replaces half-width Latin
* characters with proportional forms
*/
public static final String ENC_90MSP_RKSJ_H = "90msp-RKSJ-H";
/**
* 90msp-RKSJ-V Vertical version of 90msp-RKSJ-H
*/
public static final String ENC_90MSP_RKSJ_V = "90msp-RKSJ-V";
/**
* 90pv-RKSJ-H Mac OS, JIS X 0208 character set with KanjiTalk7
* extensions, Shift-JIS encoding, Script Manager code 1
*/
public static final String ENC_90PV_RKSJ_H = "90pv-RKSJ-H"; // no V version
/**
* Add-RKSJ-H JIS X 0208 character set with Fujitsu FMR
* extensions, Shift-JIS encoding
*/
public static final String ENC_ADD_RKSJ_H = "Add-RKSJ-H";
/**
* Add-RKSJ-V Vertical version of Add-RKSJ-H
*/
public static final String ENC_ADD_RKSJ_V = "Add-RKSJ-V";
/**
* EUC-H JIS X 0208 character set, EUC-JP encoding
*/
public static final String ENC_EUC_H = "EUC-H";
/**
* EUC-V Vertical version of EUC-H
*/
public static final String ENC_EUC_V = "EUC-V";
/**
* Ext-RKSJ-H JIS C 6226 (JIS78) character set with
* NEC extensions, Shift-JIS encoding
*/
public static final String ENC_EXT_RKSJ_H = "Ext-RKSJ-H";
/**
* Ext-RKSJ-V Vertical version of Ext-RKSJ-H
*/
public static final String ENC_EXT_RKSJ_V = "Ext-RKSJ-V";
/**
* H JIS X 0208 character set, ISO-2022-JP encoding
*/
public static final String ENC_H = "H";
/**
* V Vertical version of H
*/
public static final String ENC_V = "V";
/**
* UniJIS-UCS2-H Unicode (UCS-2) encoding for the
* Adobe-Japan1 character collection
*/
public static final String ENC_UNIJIS_UCS2_H = "UniJIS-UCS2-H";
/**
* UniJIS-UCS2-V Vertical version of UniJIS-UCS2-H
*/
public static final String ENC_UNIJIS_UCS2_V = "UniJIS-UCS2-V";
/**
* UniJIS-UCS2-HW-H Same as UniJIS-UCS2-H, but replaces proportional
* Latin characters with half-width forms
*/
public static final String ENC_UNIJIS_UCS2_HW_H = "UniJIS-UCS2-HW-H";
/**
* UniJIS-UCS2-HW-V Vertical version of UniJIS-UCS2-HW-H
*/
public static final String ENC_UNIJIS_UCS2_HW_V = "UniJIS-UCS2-HW-V";
/*
* Korean
*/
/**
* KSC-EUC-H KS X 1001:1992 character set, EUC-KR encoding
*/
public static final String ENC_KSC_EUC_H = "KSC-EUC-H";
/**
* KSC-EUC-V Vertical version of KSC-EUC-H
*/
public static final String ENC_KSC_EUC_V = "KSC-EUC-V";
/**
* KSCms-UHC-H Microsoft Code Page 949 (lfCharSet 0x81), KS X 1001:1992
* character set plus 8822 additional hangul,
* Unified Hangul Code (UHC) encoding
*/
public static final String ENC_KSCMS_UHC_H = "KSCms-UHC-H";
/**
* KSCms-UHC-V Vertical version of KSCms-UHC-H
*/
public static final String ENC_KSCMS_UHC_V = "KSCms-UHC-V";
/**
* KSCms-UHC-HW-H Same as KSCms-UHC-H, but replaces proportional
* Latin characters with half-width forms
*/
public static final String ENC_KSCMS_UHC_HW_H = "KSCms-UHC-HW-H";
/**
* KSCms-UHC-HW-V Vertical version of KSCms-UHC-HW-H
*/
public static final String ENC_KSCMS_UHC_HW_V = "KSCms-UHC-HW-V";
/**
* KSCpc-EUC-H Mac OS, KS X 1001:1992 character set with
* Mac OS KH extensions, Script Manager Code 3
*/
public static final String ENC_KSCPC_EUC_H = "KSCpc-EUC-H"; // no V version
/**
* UniKS-UCS2-H Unicode (UCS-2) encoding for the
* Adobe-Korea1 character collection
*/
public static final String ENC_UNIKSC_UCS2_H = "UniKSC-UCS2-H";
/**
* UniKS-UCS2-V Vertical version of UniKS-UCS2-H
*/
public static final String ENC_UNIKSC_UCS2_V = "UniKSC-UCS2-V";
/*
* Generic
*/
/**
* Identity-H The horizontal identity mapping for 2-byte CIDs;
* may be used with CIDFonts using any Registry, Ordering, and
* Supplement values. It maps 2-byte character codes ranging from
* 0 to 65,535 to the same 2-byte CID value, interpreted
* high-order byte first.
*/
public static final String ENC_IDENTITY_H = "Identity-H";
/**
* Identity-V Vertical version of Identity-H. The mapping
* is the same as for Identity-H.
*/
public static final String ENC_IDENTTITY_V = "Identity-V";
/**
* /CMapName attribute, one of the predefined constants
*/
protected String name;
/**
* /CIDSystemInfo attribute
*/
protected PDFCIDSystemInfo sysInfo;
/**
* horizontal writing direction
*/
public static final byte WMODE_HORIZONTAL = 0;
/**
* vertical writing direction
*/
public static final byte WMODE_VERTICAL = 1;
/**
* font's writing direction
*/
protected byte wMode = WMODE_HORIZONTAL;
/**
* base CMap (String or PDFStream)
*/
protected Object base;
/**
* create the /CMap object
*
* @param name one the registered names (see Table 7.20 on p 215)
* @param sysInfo the attributes of the character collection of the CIDFont
*/
public PDFCMap(String name, PDFCIDSystemInfo sysInfo) {
super();
this.name = name;
this.sysInfo = sysInfo;
this.base = null;
}
/**
* set the writing direction
*
* @param mode is either <code>WMODE_HORIZONTAL</code>
* or <code>WMODE_VERTICAL</code>
*/
public void setWMode(byte mode) {
this.wMode = mode;
}
/**
* set the base CMap
*
* @param base the name of the base CMap
*/
public void setUseCMap(String base) {
this.base = base;
}
/**
* set the base CMap
*
* @param base the stream to be used as base CMap
*/
public void setUseCMap(PDFStream base) {
this.base = base;
}
/**
* Creates the CMapBuilder that will build the CMap's content.
* @param writer a Writer to write the CMap's contents to
* @return the newly created CMapBuilder
*/
protected CMapBuilder createCMapBuilder(Writer writer) {
return new CMapBuilder(writer, this.name);
}
/** {@inheritDoc} */
public int output(OutputStream stream) throws IOException {
CMapBuilder builder = createCMapBuilder(getBufferWriter());
builder.writeCMap();
return super.output(stream);
}
}
|