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
|
/*---------------------------------------------------------------------------*
| PDFlib - A library for generating PDF on the fly |
+---------------------------------------------------------------------------+
| Copyright (c) 1997-2006 Thomas Merz and PDFlib GmbH. All rights reserved. |
+---------------------------------------------------------------------------+
| |
| This software is subject to the PDFlib license. It is NOT in the |
| public domain. Extended versions and commercial licenses are |
| available, please check http://www.pdflib.com. |
| |
*---------------------------------------------------------------------------*/
/* $Id: ft_cid.c,v 1.2 2009/10/20 18:12:26 scuri Exp $
*
* FONT CID functions
*
*/
#define FT_CID_C
#include <errno.h>
#include "ft_font.h"
#include "pc_file.h"
/* ------------------------ Predefined CMaps ------------------------ */
/* Predefined CMaps and the corresponding character collection */
static const fnt_cmap_info fnt_predefined_cmaps[] =
{
{ "83pv-RKSJ-H", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 0},
{ "90ms-RKSJ-H", cc_japanese, 0, PDC_1_3, 2, 2, 2, 2, 0},
{ "90ms-RKSJ-V", cc_japanese, 0, PDC_1_3, 2, 2, 2, 2, 1},
{ "90msp-RKSJ-H", cc_japanese, 0, PDC_1_3, 2, 2, 2, 2, 0},
{ "90msp-RKSJ-V", cc_japanese, 0, PDC_1_3, 2, 2, 2, 2, 1},
{ "90pv-RKSJ-H", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 0},
{ "Add-RKSJ-H", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 0},
{ "Add-RKSJ-V", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 1},
{ "EUC-H", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 0},
{ "EUC-V", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 1},
{ "Ext-RKSJ-H", cc_japanese, 0, PDC_1_3, 2, 2, 2, 2, 0},
{ "Ext-RKSJ-V", cc_japanese, 0, PDC_1_3, 2, 2, 2, 2, 1},
{ "H", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 0},
{ "V", cc_japanese, 0, PDC_1_3, 1, 1, 1, 1, 1},
{ "UniJIS-UCS2-H", cc_japanese, 2, PDC_1_3, 2, 4, 4, 6, 0},
{ "UniJIS-UCS2-V", cc_japanese, 2, PDC_1_3, 2, 4, 4, 6, 1},
{ "UniJIS-UCS2-HW-H", cc_japanese,-2, PDC_1_3, 2, 4, 4, 6, 0},
{ "UniJIS-UCS2-HW-V", cc_japanese -2, PDC_1_3, 2, 4, 4, 6, 1},
{ "UniJIS-UTF16-H", cc_japanese, 2, PDC_1_5, 0, 0, 5, 6, 0},
{ "UniJIS-UTF16-V", cc_japanese, 2, PDC_1_5, 0, 0, 5, 6, 1},
{ "GB-EUC-H", cc_simplified_chinese, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "GB-EUC-V", cc_simplified_chinese, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ "GBpc-EUC-H", cc_simplified_chinese, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "GBpc-EUC-V", cc_simplified_chinese, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ "GBK-EUC-H", cc_simplified_chinese, 0, PDC_1_3, 2, 2, 2, 2, 0},
{ "GBK-EUC-V", cc_simplified_chinese, 0, PDC_1_3, 2, 2, 2, 2, 1},
{ "GBKp-EUC-H", cc_simplified_chinese, 0, PDC_1_4, 0, 2, 2, 2, 0},
{ "GBKp-EUC-V", cc_simplified_chinese, 0, PDC_1_4, 0, 2, 2, 2, 1},
{ "GBK2K-H", cc_simplified_chinese, 0, PDC_1_4, 0, 4, 4, 5, 0},
{ "GBK2K-V", cc_simplified_chinese, 0, PDC_1_4, 0, 4, 4, 5, 1},
{ "UniGB-UCS2-H", cc_simplified_chinese, 2, PDC_1_3, 2, 4, 4, 4, 0},
{ "UniGB-UCS2-V", cc_simplified_chinese, 2, PDC_1_3, 2, 4, 4, 4, 1},
{ "UniGB-UTF16-H", cc_simplified_chinese, 2, PDC_1_5, 0, 0, 4, 5, 0},
{ "UniGB-UTF16-V", cc_simplified_chinese, 2, PDC_1_5, 0, 0, 4, 5, 1},
{ "B5pc-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "B5pc-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ "HKscs-B5-H", cc_traditional_chinese, 0, PDC_1_4, 0, 3, 3, 5, 0},
{ "HKscs-B5-V", cc_traditional_chinese, 0, PDC_1_4, 0, 3, 3, 5, 1},
{ "ETen-B5-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "ETen-B5-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ "ETenms-B5-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "ETenms-B5-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ "CNS-EUC-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "CNS-EUC-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ "UniCNS-UCS2-H", cc_traditional_chinese, 2, PDC_1_3, 0, 3, 3, 3, 0},
{ "UniCNS-UCS2-V", cc_traditional_chinese, 2, PDC_1_3, 0, 3, 3, 3, 1},
{ "UniCNS-UTF16-H", cc_traditional_chinese, 2, PDC_1_5, 0, 0, 4, 4, 0},
{ "UniCNS-UTF16-V", cc_traditional_chinese, 2, PDC_1_5, 0, 0, 4, 4, 1},
{ "KSC-EUC-H", cc_korean, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "KSC-EUC-V", cc_korean, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ "KSCms-UHC-H", cc_korean, 0, PDC_1_3, 1, 1, 1, 1, 0},
{ "KSCms-UHC-V", cc_korean, 0, PDC_1_3, 1, 1, 1, 1, 1},
{ "KSCms-UHC-HW-H", cc_korean, 0, PDC_1_3, 1, 1, 1, 1, 0},
{ "KSCms-UHC-HW-V", cc_korean, 0, PDC_1_3, 1, 1, 1, 1, 1},
{ "KSCpc-EUC-H", cc_korean, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "UniKS-UCS2-H", cc_korean, 2, PDC_1_3, 1, 1, 1, 1, 0},
{ "UniKS-UCS2-V", cc_korean, 2, PDC_1_3, 1, 1, 1, 1, 1},
{ "UniKS-UTF16-H", cc_korean, 2, PDC_1_5, 0, 0, 2, 2, 0},
{ "UniKS-UTF16-V", cc_korean, 2, PDC_1_5, 0, 0, 2, 2, 1},
{ "Identity-H", cc_identity, 0, PDC_1_3, 0, 0, 0, 0, 0},
{ "Identity-V", cc_identity, 0, PDC_1_3, 0, 0, 0, 0, 1},
{ NULL, cc_none, 0, 0, 0, 0, 0, 0, 0},
};
static int
fnt_get_predefined_cmap_slot(const char *cmapname)
{
int slot;
for (slot = 0; ; slot++)
{
if (fnt_predefined_cmaps[slot].name == NULL)
{
slot = -1;
break;
}
if (!strcmp(fnt_predefined_cmaps[slot].name, cmapname))
break;
}
return slot;
}
int
fnt_get_predefined_cmap_info(const char *cmapname, fnt_cmap_info *cmapinfo)
{
int slot;
slot = fnt_get_predefined_cmap_slot(cmapname);
if (slot == -1)
return cc_none;
if (cmapinfo)
*cmapinfo = fnt_predefined_cmaps[slot];
return fnt_predefined_cmaps[slot].charcoll;
}
static const pdc_keyconn fnt_charcoll_keylist[] =
{
{ "Japan1", cc_japanese},
{ "GB1", cc_simplified_chinese},
{ "CNS1", cc_traditional_chinese},
{ "Korea1", cc_korean},
{ "Identity", cc_identity},
{ "Unknown", cc_unknown},
{ NULL, 0}
};
const char *
fnt_get_ordering_cid(int charcoll)
{
return pdc_get_keyword(charcoll, fnt_charcoll_keylist);
}
int
fnt_get_charcoll(const char *ordering)
{
int charcoll;
charcoll = (int) pdc_get_keycode(ordering, fnt_charcoll_keylist);
if (charcoll == PDC_KEY_NOTFOUND)
return cc_unknown;
else
return charcoll;
}
int
fnt_get_supplement(fnt_cmap_info *cmapinfo, int compatibility)
{
int retval = 0;
switch(compatibility)
{
case PDC_1_3:
retval = cmapinfo->supplement13;
break;
case PDC_1_4:
retval = cmapinfo->supplement14;
break;
case PDC_1_5:
retval = cmapinfo->supplement15;
break;
default:
case PDC_1_6:
retval = cmapinfo->supplement16;
break;
}
return retval;
}
/*
* See:
* Adobe Technical Note #5078 (Japanese1)
* Adobe Technical Note #5079 (GB1)
* Adobe Technical Note #5080 (CNS1)
* Adobe Technical Note #5093 (Korea1)
*
*/
int
fnt_get_maxcid(int charcoll, int supplement)
{
switch(charcoll)
{
case cc_japanese:
switch(supplement)
{
case 0:
return 8283;
case 1:
return 8358;
case 2:
return 8719;
case 3:
return 9353;
case 4:
return 15443;
case 5:
return 20316;
case 6:
default:
return 23057;
}
case cc_simplified_chinese:
switch(supplement)
{
case 0:
return 7716;
case 1:
return 9896;
case 2:
return 22126;
case 3:
return 22352;
case 4:
return 29063;
case 5:
default:
return 30283;
}
case cc_traditional_chinese:
switch(supplement)
{
case 0:
return 14098;
case 1:
return 17407;
case 2:
return 17600;
case 3:
return 18845;
case 4:
return 18964;
case 5:
default:
return 19087;
}
case cc_korean:
switch(supplement)
{
case 0:
return 9332;
case 1:
return 18154;
case 2:
default:
return 18351;
}
case cc_identity:
case cc_unknown:
return FNT_MAXCID;
default:
return 0;
}
}
|