To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / c8 / c84c8feb09c74f4066537c3dc5805060fec4acf5.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (103 KB)

1
#!/usr/bin/env ruby
2
#
3
# Utility to generate font definition files
4
# Version: 1.1
5
# Date:    2006-07-19
6
#
7
# Changelog:
8
#  Version 1.1 - Brian Ollenberger
9
#   - Fixed a very small bug in MakeFont for generating FontDef.diff.
10

    
11
Charencodings = {
12
# Central Europe
13
    'cp1250' => [
14
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
15
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
16
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
17
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
18
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
19
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
20
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
21
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
22
        'space',          'exclam',         'quotedbl',       'numbersign',
23
        'dollar',         'percent',        'ampersand',      'quotesingle',
24
        'parenleft',      'parenright',     'asterisk',       'plus',
25
        'comma',          'hyphen',         'period',         'slash',
26
        'zero',           'one',            'two',            'three',
27
        'four',           'five',           'six',            'seven',
28
        'eight',          'nine',           'colon',          'semicolon',
29
        'less',           'equal',          'greater',        'question',
30
        'at',             'A',              'B',              'C',
31
        'D',              'E',              'F',              'G',
32
        'H',              'I',              'J',              'K',
33
        'L',              'M',              'N',              'O',
34
        'P',              'Q',              'R',              'S',
35
        'T',              'U',              'V',              'W',
36
        'X',              'Y',              'Z',              'bracketleft',
37
        'backslash',      'bracketright',   'asciicircum',    'underscore',
38
        'grave',          'a',              'b',              'c',
39
        'd',              'e',              'f',              'g',
40
        'h',              'i',              'j',              'k',
41
        'l',              'm',              'n',              'o',
42
        'p',              'q',              'r',              's',
43
        't',              'u',              'v',              'w',
44
        'x',              'y',              'z',              'braceleft',
45
        'bar',            'braceright',     'asciitilde',     '.notdef',
46
        'Euro',           '.notdef',        'quotesinglbase', '.notdef',
47
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
48
        '.notdef',        'perthousand',    'Scaron',         'guilsinglleft',
49
        'Sacute',         'Tcaron',         'Zcaron',         'Zacute',
50
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
51
        'quotedblright',  'bullet',         'endash',         'emdash',
52
        '.notdef',        'trademark',      'scaron',         'guilsinglright',
53
        'sacute',         'tcaron',         'zcaron',         'zacute',
54
        'space',          'caron',          'breve',          'Lslash',
55
        'currency',       'Aogonek',        'brokenbar',      'section',
56
        'dieresis',       'copyright',      'Scedilla',       'guillemotleft',
57
        'logicalnot',     'hyphen',         'registered',     'Zdotaccent',
58
        'degree',         'plusminus',      'ogonek',         'lslash',
59
        'acute',          'mu',             'paragraph',      'periodcentered',
60
        'cedilla',        'aogonek',        'scedilla',       'guillemotright',
61
        'Lcaron',         'hungarumlaut',   'lcaron',         'zdotaccent',
62
        'Racute',         'Aacute',         'Acircumflex',    'Abreve',
63
        'Adieresis',      'Lacute',         'Cacute',         'Ccedilla',
64
        'Ccaron',         'Eacute',         'Eogonek',        'Edieresis',
65
        'Ecaron',         'Iacute',         'Icircumflex',    'Dcaron',
66
        'Dcroat',         'Nacute',         'Ncaron',         'Oacute',
67
        'Ocircumflex',    'Ohungarumlaut',  'Odieresis',      'multiply',
68
        'Rcaron',         'Uring',          'Uacute',         'Uhungarumlaut',
69
        'Udieresis',      'Yacute',         'Tcommaaccent',   'germandbls',
70
        'racute',         'aacute',         'acircumflex',    'abreve',
71
        'adieresis',      'lacute',         'cacute',         'ccedilla',
72
        'ccaron',         'eacute',         'eogonek',        'edieresis',
73
        'ecaron',         'iacute',         'icircumflex',    'dcaron',
74
        'dcroat',         'nacute',         'ncaron',         'oacute',
75
        'ocircumflex',    'ohungarumlaut',  'odieresis',      'divide',
76
        'rcaron',         'uring',          'uacute',         'uhungarumlaut',
77
        'udieresis',      'yacute',         'tcommaaccent',   'dotaccent'
78
    ],
79
# Cyrillic
80
    'cp1251' => [
81
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
82
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
83
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
84
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
85
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
86
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
87
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
88
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
89
        'space',          'exclam',         'quotedbl',       'numbersign',
90
        'dollar',         'percent',        'ampersand',      'quotesingle',
91
        'parenleft',      'parenright',     'asterisk',       'plus',
92
        'comma',          'hyphen',         'period',         'slash',
93
        'zero',           'one',            'two',            'three',
94
        'four',           'five',           'six',            'seven',
95
        'eight',          'nine',           'colon',          'semicolon',
96
        'less',           'equal',          'greater',        'question',
97
        'at',             'A',              'B',              'C',
98
        'D',              'E',              'F',              'G',
99
        'H',              'I',              'J',              'K',
100
        'L',              'M',              'N',              'O',
101
        'P',              'Q',              'R',              'S',
102
        'T',              'U',              'V',              'W',
103
        'X',              'Y',              'Z',              'bracketleft',
104
        'backslash',      'bracketright',   'asciicircum',    'underscore',
105
        'grave',          'a',              'b',              'c',
106
        'd',              'e',              'f',              'g',
107
        'h',              'i',              'j',              'k',
108
        'l',              'm',              'n',              'o',
109
        'p',              'q',              'r',              's',
110
        't',              'u',              'v',              'w',
111
        'x',              'y',              'z',              'braceleft',
112
        'bar',            'braceright',     'asciitilde',     '.notdef',
113
        'afii10051',      'afii10052',      'quotesinglbase', 'afii10100',
114
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
115
        'Euro',           'perthousand',    'afii10058',      'guilsinglleft',
116
        'afii10059',      'afii10061',      'afii10060',      'afii10145',
117
        'afii10099',      'quoteleft',      'quoteright',     'quotedblleft',
118
        'quotedblright',  'bullet',         'endash',         'emdash',
119
        '.notdef',        'trademark',      'afii10106',      'guilsinglright',
120
        'afii10107',      'afii10109',      'afii10108',      'afii10193',
121
        'space',          'afii10062',      'afii10110',      'afii10057',
122
        'currency',       'afii10050',      'brokenbar',      'section',
123
        'afii10023',      'copyright',      'afii10053',      'guillemotleft',
124
        'logicalnot',     'hyphen',         'registered',     'afii10056',
125
        'degree',         'plusminus',      'afii10055',      'afii10103',
126
        'afii10098',      'mu',             'paragraph',      'periodcentered',
127
        'afii10071',      'afii61352',      'afii10101',      'guillemotright',
128
        'afii10105',      'afii10054',      'afii10102',      'afii10104',
129
        'afii10017',      'afii10018',      'afii10019',      'afii10020',
130
        'afii10021',      'afii10022',      'afii10024',      'afii10025',
131
        'afii10026',      'afii10027',      'afii10028',      'afii10029',
132
        'afii10030',      'afii10031',      'afii10032',      'afii10033',
133
        'afii10034',      'afii10035',      'afii10036',      'afii10037',
134
        'afii10038',      'afii10039',      'afii10040',      'afii10041',
135
        'afii10042',      'afii10043',      'afii10044',      'afii10045',
136
        'afii10046',      'afii10047',      'afii10048',      'afii10049',
137
        'afii10065',      'afii10066',      'afii10067',      'afii10068',
138
        'afii10069',      'afii10070',      'afii10072',      'afii10073',
139
        'afii10074',      'afii10075',      'afii10076',      'afii10077',
140
        'afii10078',      'afii10079',      'afii10080',      'afii10081',
141
        'afii10082',      'afii10083',      'afii10084',      'afii10085',
142
        'afii10086',      'afii10087',      'afii10088',      'afii10089',
143
        'afii10090',      'afii10091',      'afii10092',      'afii10093',
144
        'afii10094',      'afii10095',      'afii10096',      'afii10097'
145
    ],
146
# Western Europe
147
    'cp1252' => [
148
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
149
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
150
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
151
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
152
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
153
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
154
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
155
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
156
        'space',          'exclam',         'quotedbl',       'numbersign',
157
        'dollar',         'percent',        'ampersand',      'quotesingle',
158
        'parenleft',      'parenright',     'asterisk',       'plus',
159
        'comma',          'hyphen',         'period',         'slash',
160
        'zero',           'one',            'two',            'three',
161
        'four',           'five',           'six',            'seven',
162
        'eight',          'nine',           'colon',          'semicolon',
163
        'less',           'equal',          'greater',        'question',
164
        'at',             'A',              'B',              'C',
165
        'D',              'E',              'F',              'G',
166
        'H',              'I',              'J',              'K',
167
        'L',              'M',              'N',              'O',
168
        'P',              'Q',              'R',              'S',
169
        'T',              'U',              'V',              'W',
170
        'X',              'Y',              'Z',              'bracketleft',
171
        'backslash',      'bracketright',   'asciicircum',    'underscore',
172
        'grave',          'a',              'b',              'c',
173
        'd',              'e',              'f',              'g',
174
        'h',              'i',              'j',              'k',
175
        'l',              'm',              'n',              'o',
176
        'p',              'q',              'r',              's',
177
        't',              'u',              'v',              'w',
178
        'x',              'y',              'z',              'braceleft',
179
        'bar',            'braceright',     'asciitilde',     '.notdef',
180
        'Euro',           '.notdef',        'quotesinglbase', 'florin',
181
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
182
        'circumflex',     'perthousand',    'Scaron',         'guilsinglleft',
183
        'OE',             '.notdef',        'Zcaron',         '.notdef',
184
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
185
        'quotedblright',  'bullet',         'endash',         'emdash',
186
        'tilde',          'trademark',      'scaron',         'guilsinglright',
187
        'oe',             '.notdef',        'zcaron',         'Ydieresis',
188
        'space',          'exclamdown',     'cent',           'sterling',
189
        'currency',       'yen',            'brokenbar',      'section',
190
        'dieresis',       'copyright',      'ordfeminine',    'guillemotleft',
191
        'logicalnot',     'hyphen',         'registered',     'macron',
192
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
193
        'acute',          'mu',             'paragraph',      'periodcentered',
194
        'cedilla',        'onesuperior',    'ordmasculine',   'guillemotright',
195
        'onequarter',     'onehalf',        'threequarters',  'questiondown',
196
        'Agrave',         'Aacute',         'Acircumflex',    'Atilde',
197
        'Adieresis',      'Aring',          'AE',             'Ccedilla',
198
        'Egrave',         'Eacute',         'Ecircumflex',    'Edieresis',
199
        'Igrave',         'Iacute',         'Icircumflex',    'Idieresis',
200
        'Eth',            'Ntilde',         'Ograve',         'Oacute',
201
        'Ocircumflex',    'Otilde',         'Odieresis',      'multiply',
202
        'Oslash',         'Ugrave',         'Uacute',         'Ucircumflex',
203
        'Udieresis',      'Yacute',         'Thorn',          'germandbls',
204
        'agrave',         'aacute',         'acircumflex',    'atilde',
205
        'adieresis',      'aring',          'ae',             'ccedilla',
206
        'egrave',         'eacute',         'ecircumflex',    'edieresis',
207
        'igrave',         'iacute',         'icircumflex',    'idieresis',
208
        'eth',            'ntilde',         'ograve',         'oacute',
209
        'ocircumflex',    'otilde',         'odieresis',      'divide',
210
        'oslash',         'ugrave',         'uacute',         'ucircumflex',
211
        'udieresis',      'yacute',         'thorn',          'ydieresis'
212
    ],
213
# Greek
214
    'cp1253' => [
215
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
216
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
217
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
218
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
219
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
220
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
221
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
222
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
223
        'space',          'exclam',         'quotedbl',       'numbersign',
224
        'dollar',         'percent',        'ampersand',      'quotesingle',
225
        'parenleft',      'parenright',     'asterisk',       'plus',
226
        'comma',          'hyphen',         'period',         'slash',
227
        'zero',           'one',            'two',            'three',
228
        'four',           'five',           'six',            'seven',
229
        'eight',          'nine',           'colon',          'semicolon',
230
        'less',           'equal',          'greater',        'question',
231
        'at',             'A',              'B',              'C',
232
        'D',              'E',              'F',              'G',
233
        'H',              'I',              'J',              'K',
234
        'L',              'M',              'N',              'O',
235
        'P',              'Q',              'R',              'S',
236
        'T',              'U',              'V',              'W',
237
        'X',              'Y',              'Z',              'bracketleft',
238
        'backslash',      'bracketright',   'asciicircum',    'underscore',
239
        'grave',          'a',              'b',              'c',
240
        'd',              'e',              'f',              'g',
241
        'h',              'i',              'j',              'k',
242
        'l',              'm',              'n',              'o',
243
        'p',              'q',              'r',              's',
244
        't',              'u',              'v',              'w',
245
        'x',              'y',              'z',              'braceleft',
246
        'bar',            'braceright',     'asciitilde',     '.notdef',
247
        'Euro',           '.notdef',        'quotesinglbase', 'florin',
248
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
249
        '.notdef',        'perthousand',    '.notdef',        'guilsinglleft',
250
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
251
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
252
        'quotedblright',  'bullet',         'endash',         'emdash',
253
        '.notdef',        'trademark',      '.notdef',        'guilsinglright',
254
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
255
        'space',          'dieresistonos',  'Alphatonos',     'sterling',
256
        'currency',       'yen',            'brokenbar',      'section',
257
        'dieresis',       'copyright',      '.notdef',        'guillemotleft',
258
        'logicalnot',     'hyphen',         'registered',     'afii00208',
259
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
260
        'tonos',          'mu',             'paragraph',      'periodcentered',
261
        'Epsilontonos',   'Etatonos',       'Iotatonos',      'guillemotright',
262
        'Omicrontonos',   'onehalf',        'Upsilontonos',   'Omegatonos',
263
        'iotadieresistonos','Alpha',          'Beta',           'Gamma',
264
        'Delta',          'Epsilon',        'Zeta',           'Eta',
265
        'Theta',          'Iota',           'Kappa',          'Lambda',
266
        'Mu',             'Nu',             'Xi',             'Omicron',
267
        'Pi',             'Rho',            '.notdef',        'Sigma',
268
        'Tau',            'Upsilon',        'Phi',            'Chi',
269
        'Psi',            'Omega',          'Iotadieresis',   'Upsilondieresis',
270
        'alphatonos',     'epsilontonos',   'etatonos',       'iotatonos',
271
        'upsilondieresistonos','alpha',          'beta',           'gamma',
272
        'delta',          'epsilon',        'zeta',           'eta',
273
        'theta',          'iota',           'kappa',          'lambda',
274
        'mu',             'nu',             'xi',             'omicron',
275
        'pi',             'rho',            'sigma1',         'sigma',
276
        'tau',            'upsilon',        'phi',            'chi',
277
        'psi',            'omega',          'iotadieresis',   'upsilondieresis',
278
        'omicrontonos',   'upsilontonos',   'omegatonos',     '.notdef'
279
    ],
280
# Turkish
281
    'cp1254' => [
282
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
283
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
284
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
285
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
286
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
287
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
288
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
289
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
290
        'space',          'exclam',         'quotedbl',       'numbersign',
291
        'dollar',         'percent',        'ampersand',      'quotesingle',
292
        'parenleft',      'parenright',     'asterisk',       'plus',
293
        'comma',          'hyphen',         'period',         'slash',
294
        'zero',           'one',            'two',            'three',
295
        'four',           'five',           'six',            'seven',
296
        'eight',          'nine',           'colon',          'semicolon',
297
        'less',           'equal',          'greater',        'question',
298
        'at',             'A',              'B',              'C',
299
        'D',              'E',              'F',              'G',
300
        'H',              'I',              'J',              'K',
301
        'L',              'M',              'N',              'O',
302
        'P',              'Q',              'R',              'S',
303
        'T',              'U',              'V',              'W',
304
        'X',              'Y',              'Z',              'bracketleft',
305
        'backslash',      'bracketright',   'asciicircum',    'underscore',
306
        'grave',          'a',              'b',              'c',
307
        'd',              'e',              'f',              'g',
308
        'h',              'i',              'j',              'k',
309
        'l',              'm',              'n',              'o',
310
        'p',              'q',              'r',              's',
311
        't',              'u',              'v',              'w',
312
        'x',              'y',              'z',              'braceleft',
313
        'bar',            'braceright',     'asciitilde',     '.notdef',
314
        'Euro',           '.notdef',        'quotesinglbase', 'florin',
315
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
316
        'circumflex',     'perthousand',    'Scaron',         'guilsinglleft',
317
        'OE',             '.notdef',        '.notdef',        '.notdef',
318
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
319
        'quotedblright',  'bullet',         'endash',         'emdash',
320
        'tilde',          'trademark',      'scaron',         'guilsinglright',
321
        'oe',             '.notdef',        '.notdef',        'Ydieresis',
322
        'space',          'exclamdown',     'cent',           'sterling',
323
        'currency',       'yen',            'brokenbar',      'section',
324
        'dieresis',       'copyright',      'ordfeminine',    'guillemotleft',
325
        'logicalnot',     'hyphen',         'registered',     'macron',
326
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
327
        'acute',          'mu',             'paragraph',      'periodcentered',
328
        'cedilla',        'onesuperior',    'ordmasculine',   'guillemotright',
329
        'onequarter',     'onehalf',        'threequarters',  'questiondown',
330
        'Agrave',         'Aacute',         'Acircumflex',    'Atilde',
331
        'Adieresis',      'Aring',          'AE',             'Ccedilla',
332
        'Egrave',         'Eacute',         'Ecircumflex',    'Edieresis',
333
        'Igrave',         'Iacute',         'Icircumflex',    'Idieresis',
334
        'Gbreve',         'Ntilde',         'Ograve',         'Oacute',
335
        'Ocircumflex',    'Otilde',         'Odieresis',      'multiply',
336
        'Oslash',         'Ugrave',         'Uacute',         'Ucircumflex',
337
        'Udieresis',      'Idotaccent',     'Scedilla',       'germandbls',
338
        'agrave',         'aacute',         'acircumflex',    'atilde',
339
        'adieresis',      'aring',          'ae',             'ccedilla',
340
        'egrave',         'eacute',         'ecircumflex',    'edieresis',
341
        'igrave',         'iacute',         'icircumflex',    'idieresis',
342
        'gbreve',         'ntilde',         'ograve',         'oacute',
343
        'ocircumflex',    'otilde',         'odieresis',      'divide',
344
        'oslash',         'ugrave',         'uacute',         'ucircumflex',
345
        'udieresis',      'dotlessi',       'scedilla',       'ydieresis'
346
    ],
347
# Hebrew
348
    'cp1255' => [
349
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
350
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
351
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
352
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
353
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
354
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
355
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
356
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
357
        'space',          'exclam',         'quotedbl',       'numbersign',
358
        'dollar',         'percent',        'ampersand',      'quotesingle',
359
        'parenleft',      'parenright',     'asterisk',       'plus',
360
        'comma',          'hyphen',         'period',         'slash',
361
        'zero',           'one',            'two',            'three',
362
        'four',           'five',           'six',            'seven',
363
        'eight',          'nine',           'colon',          'semicolon',
364
        'less',           'equal',          'greater',        'question',
365
        'at',             'A',              'B',              'C',
366
        'D',              'E',              'F',              'G',
367
        'H',              'I',              'J',              'K',
368
        'L',              'M',              'N',              'O',
369
        'P',              'Q',              'R',              'S',
370
        'T',              'U',              'V',              'W',
371
        'X',              'Y',              'Z',              'bracketleft',
372
        'backslash',      'bracketright',   'asciicircum',    'underscore',
373
        'grave',          'a',              'b',              'c',
374
        'd',              'e',              'f',              'g',
375
        'h',              'i',              'j',              'k',
376
        'l',              'm',              'n',              'o',
377
        'p',              'q',              'r',              's',
378
        't',              'u',              'v',              'w',
379
        'x',              'y',              'z',              'braceleft',
380
        'bar',            'braceright',     'asciitilde',     '.notdef',
381
        'Euro',           '.notdef',        'quotesinglbase', 'florin',
382
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
383
        'circumflex',     'perthousand',    '.notdef',        'guilsinglleft',
384
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
385
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
386
        'quotedblright',  'bullet',         'endash',         'emdash',
387
        'tilde',          'trademark',      '.notdef',        'guilsinglright',
388
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
389
        'space',          'exclamdown',     'cent',           'sterling',
390
        'afii57636',      'yen',            'brokenbar',      'section',
391
        'dieresis',       'copyright',      'multiply',       'guillemotleft',
392
        'logicalnot',     'sfthyphen',      'registered',     'macron',
393
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
394
        'acute',          'mu',             'paragraph',      'middot',
395
        'cedilla',        'onesuperior',    'divide',         'guillemotright',
396
        'onequarter',     'onehalf',        'threequarters',  'questiondown',
397
        'afii57799',      'afii57801',      'afii57800',      'afii57802',
398
        'afii57793',      'afii57794',      'afii57795',      'afii57798',
399
        'afii57797',      'afii57806',      '.notdef',        'afii57796',
400
        'afii57807',      'afii57839',      'afii57645',      'afii57841',
401
        'afii57842',      'afii57804',      'afii57803',      'afii57658',
402
        'afii57716',      'afii57717',      'afii57718',      'gereshhebrew',
403
        'gershayimhebrew','.notdef',        '.notdef',        '.notdef',
404
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
405
        'afii57664',      'afii57665',      'afii57666',      'afii57667',
406
        'afii57668',      'afii57669',      'afii57670',      'afii57671',
407
        'afii57672',      'afii57673',      'afii57674',      'afii57675',
408
        'afii57676',      'afii57677',      'afii57678',      'afii57679',
409
        'afii57680',      'afii57681',      'afii57682',      'afii57683',
410
        'afii57684',      'afii57685',      'afii57686',      'afii57687',
411
        'afii57688',      'afii57689',      'afii57690',      '.notdef',
412
        '.notdef',        'afii299',        'afii300',        '.notdef'
413
    ],
414
# Baltic
415
    'cp1257' => [
416
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
417
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
418
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
419
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
420
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
421
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
422
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
423
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
424
        'space',          'exclam',         'quotedbl',       'numbersign',
425
        'dollar',         'percent',        'ampersand',      'quotesingle',
426
        'parenleft',      'parenright',     'asterisk',       'plus',
427
        'comma',          'hyphen',         'period',         'slash',
428
        'zero',           'one',            'two',            'three',
429
        'four',           'five',           'six',            'seven',
430
        'eight',          'nine',           'colon',          'semicolon',
431
        'less',           'equal',          'greater',        'question',
432
        'at',             'A',              'B',              'C',
433
        'D',              'E',              'F',              'G',
434
        'H',              'I',              'J',              'K',
435
        'L',              'M',              'N',              'O',
436
        'P',              'Q',              'R',              'S',
437
        'T',              'U',              'V',              'W',
438
        'X',              'Y',              'Z',              'bracketleft',
439
        'backslash',      'bracketright',   'asciicircum',    'underscore',
440
        'grave',          'a',              'b',              'c',
441
        'd',              'e',              'f',              'g',
442
        'h',              'i',              'j',              'k',
443
        'l',              'm',              'n',              'o',
444
        'p',              'q',              'r',              's',
445
        't',              'u',              'v',              'w',
446
        'x',              'y',              'z',              'braceleft',
447
        'bar',            'braceright',     'asciitilde',     '.notdef',
448
        'Euro',           '.notdef',        'quotesinglbase', '.notdef',
449
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
450
        '.notdef',        'perthousand',    '.notdef',        'guilsinglleft',
451
        '.notdef',        'dieresis',       'caron',          'cedilla',
452
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
453
        'quotedblright',  'bullet',         'endash',         'emdash',
454
        '.notdef',        'trademark',      '.notdef',        'guilsinglright',
455
        '.notdef',        'macron',         'ogonek',         '.notdef',
456
        'space',          '.notdef',        'cent',           'sterling',
457
        'currency',       '.notdef',        'brokenbar',      'section',
458
        'Oslash',         'copyright',      'Rcommaaccent',   'guillemotleft',
459
        'logicalnot',     'hyphen',         'registered',     'AE',
460
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
461
        'acute',          'mu',             'paragraph',      'periodcentered',
462
        'oslash',         'onesuperior',    'rcommaaccent',   'guillemotright',
463
        'onequarter',     'onehalf',        'threequarters',  'ae',
464
        'Aogonek',        'Iogonek',        'Amacron',        'Cacute',
465
        'Adieresis',      'Aring',          'Eogonek',        'Emacron',
466
        'Ccaron',         'Eacute',         'Zacute',         'Edotaccent',
467
        'Gcommaaccent',   'Kcommaaccent',   'Imacron',        'Lcommaaccent',
468
        'Scaron',         'Nacute',         'Ncommaaccent',   'Oacute',
469
        'Omacron',        'Otilde',         'Odieresis',      'multiply',
470
        'Uogonek',        'Lslash',         'Sacute',         'Umacron',
471
        'Udieresis',      'Zdotaccent',     'Zcaron',         'germandbls',
472
        'aogonek',        'iogonek',        'amacron',        'cacute',
473
        'adieresis',      'aring',          'eogonek',        'emacron',
474
        'ccaron',         'eacute',         'zacute',         'edotaccent',
475
        'gcommaaccent',   'kcommaaccent',   'imacron',        'lcommaaccent',
476
        'scaron',         'nacute',         'ncommaaccent',   'oacute',
477
        'omacron',        'otilde',         'odieresis',      'divide',
478
        'uogonek',        'lslash',         'sacute',         'umacron',
479
        'udieresis',      'zdotaccent',     'zcaron',         'dotaccent'
480
    ],
481
# Vietnamese
482
    'cp1258' => [
483
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
484
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
485
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
486
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
487
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
488
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
489
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
490
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
491
        'space',          'exclam',         'quotedbl',       'numbersign',
492
        'dollar',         'percent',        'ampersand',      'quotesingle',
493
        'parenleft',      'parenright',     'asterisk',       'plus',
494
        'comma',          'hyphen',         'period',         'slash',
495
        'zero',           'one',            'two',            'three',
496
        'four',           'five',           'six',            'seven',
497
        'eight',          'nine',           'colon',          'semicolon',
498
        'less',           'equal',          'greater',        'question',
499
        'at',             'A',              'B',              'C',
500
        'D',              'E',              'F',              'G',
501
        'H',              'I',              'J',              'K',
502
        'L',              'M',              'N',              'O',
503
        'P',              'Q',              'R',              'S',
504
        'T',              'U',              'V',              'W',
505
        'X',              'Y',              'Z',              'bracketleft',
506
        'backslash',      'bracketright',   'asciicircum',    'underscore',
507
        'grave',          'a',              'b',              'c',
508
        'd',              'e',              'f',              'g',
509
        'h',              'i',              'j',              'k',
510
        'l',              'm',              'n',              'o',
511
        'p',              'q',              'r',              's',
512
        't',              'u',              'v',              'w',
513
        'x',              'y',              'z',              'braceleft',
514
        'bar',            'braceright',     'asciitilde',     '.notdef',
515
        'Euro',           '.notdef',        'quotesinglbase', 'florin',
516
        'quotedblbase',   'ellipsis',       'dagger',         'daggerdbl',
517
        'circumflex',     'perthousand',    '.notdef',        'guilsinglleft',
518
        'OE',             '.notdef',        '.notdef',        '.notdef',
519
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
520
        'quotedblright',  'bullet',         'endash',         'emdash',
521
        'tilde',          'trademark',      '.notdef',        'guilsinglright',
522
        'oe',             '.notdef',        '.notdef',        'Ydieresis',
523
        'space',          'exclamdown',     'cent',           'sterling',
524
        'currency',       'yen',            'brokenbar',      'section',
525
        'dieresis',       'copyright',      'ordfeminine',    'guillemotleft',
526
        'logicalnot',     'hyphen',         'registered',     'macron',
527
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
528
        'acute',          'mu',             'paragraph',      'periodcentered',
529
        'cedilla',        'onesuperior',    'ordmasculine',   'guillemotright',
530
        'onequarter',     'onehalf',        'threequarters',  'questiondown',
531
        'Agrave',         'Aacute',         'Acircumflex',    'Abreve',
532
        'Adieresis',      'Aring',          'AE',             'Ccedilla',
533
        'Egrave',         'Eacute',         'Ecircumflex',    'Edieresis',
534
        'gravecomb',      'Iacute',         'Icircumflex',    'Idieresis',
535
        'Dcroat',         'Ntilde',         'hookabovecomb',  'Oacute',
536
        'Ocircumflex',    'Ohorn',          'Odieresis',      'multiply',
537
        'Oslash',         'Ugrave',         'Uacute',         'Ucircumflex',
538
        'Udieresis',      'Uhorn',          'tildecomb',      'germandbls',
539
        'agrave',         'aacute',         'acircumflex',    'abreve',
540
        'adieresis',      'aring',          'ae',             'ccedilla',
541
        'egrave',         'eacute',         'ecircumflex',    'edieresis',
542
        'acutecomb',      'iacute',         'icircumflex',    'idieresis',
543
        'dcroat',         'ntilde',         'dotbelowcomb',   'oacute',
544
        'ocircumflex',    'ohorn',          'odieresis',      'divide',
545
        'oslash',         'ugrave',         'uacute',         'ucircumflex',
546
        'udieresis',      'uhorn',          'dong',           'ydieresis'
547
    ],
548
# Thai
549
    'cp874' => [
550
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
551
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
552
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
553
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
554
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
555
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
556
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
557
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
558
        'space',          'exclam',         'quotedbl',       'numbersign',
559
        'dollar',         'percent',        'ampersand',      'quotesingle',
560
        'parenleft',      'parenright',     'asterisk',       'plus',
561
        'comma',          'hyphen',         'period',         'slash',
562
        'zero',           'one',            'two',            'three',
563
        'four',           'five',           'six',            'seven',
564
        'eight',          'nine',           'colon',          'semicolon',
565
        'less',           'equal',          'greater',        'question',
566
        'at',             'A',              'B',              'C',
567
        'D',              'E',              'F',              'G',
568
        'H',              'I',              'J',              'K',
569
        'L',              'M',              'N',              'O',
570
        'P',              'Q',              'R',              'S',
571
        'T',              'U',              'V',              'W',
572
        'X',              'Y',              'Z',              'bracketleft',
573
        'backslash',      'bracketright',   'asciicircum',    'underscore',
574
        'grave',          'a',              'b',              'c',
575
        'd',              'e',              'f',              'g',
576
        'h',              'i',              'j',              'k',
577
        'l',              'm',              'n',              'o',
578
        'p',              'q',              'r',              's',
579
        't',              'u',              'v',              'w',
580
        'x',              'y',              'z',              'braceleft',
581
        'bar',            'braceright',     'asciitilde',     '.notdef',
582
        'Euro',           '.notdef',        '.notdef',        '.notdef',
583
        '.notdef',        'ellipsis',       '.notdef',        '.notdef',
584
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
585
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
586
        '.notdef',        'quoteleft',      'quoteright',     'quotedblleft',
587
        'quotedblright',  'bullet',         'endash',         'emdash',
588
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
589
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
590
        'space',          'kokaithai',      'khokhaithai',    'khokhuatthai',
591
        'khokhwaithai',   'khokhonthai',    'khorakhangthai', 'ngonguthai',
592
        'chochanthai',    'chochingthai',   'chochangthai',   'sosothai',
593
        'chochoethai',    'yoyingthai',     'dochadathai',    'topatakthai',
594
        'thothanthai',    'thonangmonthothai', 'thophuthaothai', 'nonenthai',
595
        'dodekthai',      'totaothai',      'thothungthai',   'thothahanthai',
596
        'thothongthai',   'nonuthai',       'bobaimaithai',   'poplathai',
597
        'phophungthai',   'fofathai',       'phophanthai',    'fofanthai',
598
        'phosamphaothai', 'momathai',       'yoyakthai',      'roruathai',
599
        'ruthai',         'lolingthai',     'luthai',         'wowaenthai',
600
        'sosalathai',     'sorusithai',     'sosuathai',      'hohipthai',
601
        'lochulathai',    'oangthai',       'honokhukthai',   'paiyannoithai',
602
        'saraathai',      'maihanakatthai', 'saraaathai',     'saraamthai',
603
        'saraithai',      'saraiithai',     'sarauethai',     'saraueethai',
604
        'sarauthai',      'sarauuthai',     'phinthuthai',    '.notdef',
605
        '.notdef',        '.notdef',        '.notdef',        'bahtthai',
606
        'saraethai',      'saraaethai',     'saraothai',      'saraaimaimuanthai',
607
        'saraaimaimalaithai', 'lakkhangyaothai', 'maiyamokthai', 'maitaikhuthai',
608
        'maiekthai',      'maithothai',     'maitrithai',     'maichattawathai',
609
        'thanthakhatthai', 'nikhahitthai',  'yamakkanthai',   'fongmanthai',
610
        'zerothai',       'onethai',        'twothai',        'threethai',
611
        'fourthai',       'fivethai',       'sixthai',        'seventhai',
612
        'eightthai',      'ninethai',       'angkhankhuthai', 'khomutthai',
613
        '.notdef',        '.notdef',        '.notdef',        '.notdef'
614
    ],
615
# Western Europe
616
    'ISO-8859-1' => [
617
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
618
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
619
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
620
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
621
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
622
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
623
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
624
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
625
        'space',          'exclam',         'quotedbl',       'numbersign',
626
        'dollar',         'percent',        'ampersand',      'quotesingle',
627
        'parenleft',      'parenright',     'asterisk',       'plus',
628
        'comma',          'hyphen',         'period',         'slash',
629
        'zero',           'one',            'two',            'three',
630
        'four',           'five',           'six',            'seven',
631
        'eight',          'nine',           'colon',          'semicolon',
632
        'less',           'equal',          'greater',        'question',
633
        'at',             'A',              'B',              'C',
634
        'D',              'E',              'F',              'G',
635
        'H',              'I',              'J',              'K',
636
        'L',              'M',              'N',              'O',
637
        'P',              'Q',              'R',              'S',
638
        'T',              'U',              'V',              'W',
639
        'X',              'Y',              'Z',              'bracketleft',
640
        'backslash',      'bracketright',   'asciicircum',    'underscore',
641
        'grave',          'a',              'b',              'c',
642
        'd',              'e',              'f',              'g',
643
        'h',              'i',              'j',              'k',
644
        'l',              'm',              'n',              'o',
645
        'p',              'q',              'r',              's',
646
        't',              'u',              'v',              'w',
647
        'x',              'y',              'z',              'braceleft',
648
        'bar',            'braceright',     'asciitilde',     '.notdef',
649
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
650
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
651
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
652
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
653
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
654
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
655
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
656
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
657
        'space',          'exclamdown',     'cent',           'sterling',
658
        'currency',       'yen',            'brokenbar',      'section',
659
        'dieresis',       'copyright',      'ordfeminine',    'guillemotleft',
660
        'logicalnot',     'hyphen',         'registered',     'macron',
661
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
662
        'acute',          'mu',             'paragraph',      'periodcentered',
663
        'cedilla',        'onesuperior',    'ordmasculine',   'guillemotright',
664
        'onequarter',     'onehalf',        'threequarters',  'questiondown',
665
        'Agrave',         'Aacute',         'Acircumflex',    'Atilde',
666
        'Adieresis',      'Aring',          'AE',             'Ccedilla',
667
        'Egrave',         'Eacute',         'Ecircumflex',    'Edieresis',
668
        'Igrave',         'Iacute',         'Icircumflex',    'Idieresis',
669
        'Eth',            'Ntilde',         'Ograve',         'Oacute',
670
        'Ocircumflex',    'Otilde',         'Odieresis',      'multiply',
671
        'Oslash',         'Ugrave',         'Uacute',         'Ucircumflex',
672
        'Udieresis',      'Yacute',         'Thorn',          'germandbls',
673
        'agrave',         'aacute',         'acircumflex',    'atilde',
674
        'adieresis',      'aring',          'ae',             'ccedilla',
675
        'egrave',         'eacute',         'ecircumflex',    'edieresis',
676
        'igrave',         'iacute',         'icircumflex',    'idieresis',
677
        'eth',            'ntilde',         'ograve',         'oacute',
678
        'ocircumflex',    'otilde',         'odieresis',      'divide',
679
        'oslash',         'ugrave',         'uacute',         'ucircumflex',
680
        'udieresis',      'yacute',         'thorn',          'ydieresis'
681
    ],
682
# Central Europe
683
    'ISO-8859-2' => [
684
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
685
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
686
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
687
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
688
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
689
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
690
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
691
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
692
        'space',          'exclam',         'quotedbl',       'numbersign',
693
        'dollar',         'percent',        'ampersand',      'quotesingle',
694
        'parenleft',      'parenright',     'asterisk',       'plus',
695
        'comma',          'hyphen',         'period',         'slash',
696
        'zero',           'one',            'two',            'three',
697
        'four',           'five',           'six',            'seven',
698
        'eight',          'nine',           'colon',          'semicolon',
699
        'less',           'equal',          'greater',        'question',
700
        'at',             'A',              'B',              'C',
701
        'D',              'E',              'F',              'G',
702
        'H',              'I',              'J',              'K',
703
        'L',              'M',              'N',              'O',
704
        'P',              'Q',              'R',              'S',
705
        'T',              'U',              'V',              'W',
706
        'X',              'Y',              'Z',              'bracketleft',
707
        'backslash',      'bracketright',   'asciicircum',    'underscore',
708
        'grave',          'a',              'b',              'c',
709
        'd',              'e',              'f',              'g',
710
        'h',              'i',              'j',              'k',
711
        'l',              'm',              'n',              'o',
712
        'p',              'q',              'r',              's',
713
        't',              'u',              'v',              'w',
714
        'x',              'y',              'z',              'braceleft',
715
        'bar',            'braceright',     'asciitilde',     '.notdef',
716
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
717
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
718
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
719
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
720
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
721
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
722
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
723
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
724
        'space',          'Aogonek',        'breve',          'Lslash',
725
        'currency',       'Lcaron',         'Sacute',         'section',
726
        'dieresis',       'Scaron',         'Scedilla',       'Tcaron',
727
        'Zacute',         'hyphen',         'Zcaron',         'Zdotaccent',
728
        'degree',         'aogonek',        'ogonek',         'lslash',
729
        'acute',          'lcaron',         'sacute',         'caron',
730
        'cedilla',        'scaron',         'scedilla',       'tcaron',
731
        'zacute',         'hungarumlaut',   'zcaron',         'zdotaccent',
732
        'Racute',         'Aacute',         'Acircumflex',    'Abreve',
733
        'Adieresis',      'Lacute',         'Cacute',         'Ccedilla',
734
        'Ccaron',         'Eacute',         'Eogonek',        'Edieresis',
735
        'Ecaron',         'Iacute',         'Icircumflex',    'Dcaron',
736
        'Dcroat',         'Nacute',         'Ncaron',         'Oacute',
737
        'Ocircumflex',    'Ohungarumlaut',  'Odieresis',      'multiply',
738
        'Rcaron',         'Uring',          'Uacute',         'Uhungarumlaut',
739
        'Udieresis',      'Yacute',         'Tcommaaccent',   'germandbls',
740
        'racute',         'aacute',         'acircumflex',    'abreve',
741
        'adieresis',      'lacute',         'cacute',         'ccedilla',
742
        'ccaron',         'eacute',         'eogonek',        'edieresis',
743
        'ecaron',         'iacute',         'icircumflex',    'dcaron',
744
        'dcroat',         'nacute',         'ncaron',         'oacute',
745
        'ocircumflex',    'ohungarumlaut',  'odieresis',      'divide',
746
        'rcaron',         'uring',          'uacute',         'uhungarumlaut',
747
        'udieresis',      'yacute',         'tcommaaccent',   'dotaccent'
748
    ],
749
# Baltic
750
    'ISO-8859-4' => [
751
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
752
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
753
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
754
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
755
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
756
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
757
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
758
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
759
        'space',          'exclam',         'quotedbl',       'numbersign',
760
        'dollar',         'percent',        'ampersand',      'quotesingle',
761
        'parenleft',      'parenright',     'asterisk',       'plus',
762
        'comma',          'hyphen',         'period',         'slash',
763
        'zero',           'one',            'two',            'three',
764
        'four',           'five',           'six',            'seven',
765
        'eight',          'nine',           'colon',          'semicolon',
766
        'less',           'equal',          'greater',        'question',
767
        'at',             'A',              'B',              'C',
768
        'D',              'E',              'F',              'G',
769
        'H',              'I',              'J',              'K',
770
        'L',              'M',              'N',              'O',
771
        'P',              'Q',              'R',              'S',
772
        'T',              'U',              'V',              'W',
773
        'X',              'Y',              'Z',              'bracketleft',
774
        'backslash',      'bracketright',   'asciicircum',    'underscore',
775
        'grave',          'a',              'b',              'c',
776
        'd',              'e',              'f',              'g',
777
        'h',              'i',              'j',              'k',
778
        'l',              'm',              'n',              'o',
779
        'p',              'q',              'r',              's',
780
        't',              'u',              'v',              'w',
781
        'x',              'y',              'z',              'braceleft',
782
        'bar',            'braceright',     'asciitilde',     '.notdef',
783
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
784
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
785
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
786
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
787
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
788
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
789
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
790
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
791
        'space',          'Aogonek',        'kgreenlandic',   'Rcommaaccent',
792
        'currency',       'Itilde',         'Lcommaaccent',   'section',
793
        'dieresis',       'Scaron',         'Emacron',        'Gcommaaccent',
794
        'Tbar',           'hyphen',         'Zcaron',         'macron',
795
        'degree',         'aogonek',        'ogonek',         'rcommaaccent',
796
        'acute',          'itilde',         'lcommaaccent',   'caron',
797
        'cedilla',        'scaron',         'emacron',        'gcommaaccent',
798
        'tbar',           'Eng',            'zcaron',         'eng',
799
        'Amacron',        'Aacute',         'Acircumflex',    'Atilde',
800
        'Adieresis',      'Aring',          'AE',             'Iogonek',
801
        'Ccaron',         'Eacute',         'Eogonek',        'Edieresis',
802
        'Edotaccent',     'Iacute',         'Icircumflex',    'Imacron',
803
        'Dcroat',         'Ncommaaccent',   'Omacron',        'Kcommaaccent',
804
        'Ocircumflex',    'Otilde',         'Odieresis',      'multiply',
805
        'Oslash',         'Uogonek',        'Uacute',         'Ucircumflex',
806
        'Udieresis',      'Utilde',         'Umacron',        'germandbls',
807
        'amacron',        'aacute',         'acircumflex',    'atilde',
808
        'adieresis',      'aring',          'ae',             'iogonek',
809
        'ccaron',         'eacute',         'eogonek',        'edieresis',
810
        'edotaccent',     'iacute',         'icircumflex',    'imacron',
811
        'dcroat',         'ncommaaccent',   'omacron',        'kcommaaccent',
812
        'ocircumflex',    'otilde',         'odieresis',      'divide',
813
        'oslash',         'uogonek',        'uacute',         'ucircumflex',
814
        'udieresis',      'utilde',         'umacron',        'dotaccent'
815
    ],
816
# Cyrillic
817
    'ISO-8859-5' => [
818
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
819
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
820
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
821
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
822
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
823
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
824
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
825
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
826
        'space',          'exclam',         'quotedbl',       'numbersign',
827
        'dollar',         'percent',        'ampersand',      'quotesingle',
828
        'parenleft',      'parenright',     'asterisk',       'plus',
829
        'comma',          'hyphen',         'period',         'slash',
830
        'zero',           'one',            'two',            'three',
831
        'four',           'five',           'six',            'seven',
832
        'eight',          'nine',           'colon',          'semicolon',
833
        'less',           'equal',          'greater',        'question',
834
        'at',             'A',              'B',              'C',
835
        'D',              'E',              'F',              'G',
836
        'H',              'I',              'J',              'K',
837
        'L',              'M',              'N',              'O',
838
        'P',              'Q',              'R',              'S',
839
        'T',              'U',              'V',              'W',
840
        'X',              'Y',              'Z',              'bracketleft',
841
        'backslash',      'bracketright',   'asciicircum',    'underscore',
842
        'grave',          'a',              'b',              'c',
843
        'd',              'e',              'f',              'g',
844
        'h',              'i',              'j',              'k',
845
        'l',              'm',              'n',              'o',
846
        'p',              'q',              'r',              's',
847
        't',              'u',              'v',              'w',
848
        'x',              'y',              'z',              'braceleft',
849
        'bar',            'braceright',     'asciitilde',     '.notdef',
850
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
851
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
852
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
853
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
854
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
855
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
856
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
857
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
858
        'space',          'afii10023',      'afii10051',      'afii10052',
859
        'afii10053',      'afii10054',      'afii10055',      'afii10056',
860
        'afii10057',      'afii10058',      'afii10059',      'afii10060',
861
        'afii10061',      'hyphen',         'afii10062',      'afii10145',
862
        'afii10017',      'afii10018',      'afii10019',      'afii10020',
863
        'afii10021',      'afii10022',      'afii10024',      'afii10025',
864
        'afii10026',      'afii10027',      'afii10028',      'afii10029',
865
        'afii10030',      'afii10031',      'afii10032',      'afii10033',
866
        'afii10034',      'afii10035',      'afii10036',      'afii10037',
867
        'afii10038',      'afii10039',      'afii10040',      'afii10041',
868
        'afii10042',      'afii10043',      'afii10044',      'afii10045',
869
        'afii10046',      'afii10047',      'afii10048',      'afii10049',
870
        'afii10065',      'afii10066',      'afii10067',      'afii10068',
871
        'afii10069',      'afii10070',      'afii10072',      'afii10073',
872
        'afii10074',      'afii10075',      'afii10076',      'afii10077',
873
        'afii10078',      'afii10079',      'afii10080',      'afii10081',
874
        'afii10082',      'afii10083',      'afii10084',      'afii10085',
875
        'afii10086',      'afii10087',      'afii10088',      'afii10089',
876
        'afii10090',      'afii10091',      'afii10092',      'afii10093',
877
        'afii10094',      'afii10095',      'afii10096',      'afii10097',
878
        'afii61352',      'afii10071',      'afii10099',      'afii10100',
879
        'afii10101',      'afii10102',      'afii10103',      'afii10104',
880
        'afii10105',      'afii10106',      'afii10107',      'afii10108',
881
        'afii10109',      'section',        'afii10110',      'afii10193'
882
    ],
883
# Greek
884
    'ISO-8859-7' => [
885
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
886
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
887
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
888
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
889
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
890
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
891
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
892
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
893
        'space',          'exclam',         'quotedbl',       'numbersign',
894
        'dollar',         'percent',        'ampersand',      'quotesingle',
895
        'parenleft',      'parenright',     'asterisk',       'plus',
896
        'comma',          'hyphen',         'period',         'slash',
897
        'zero',           'one',            'two',            'three',
898
        'four',           'five',           'six',            'seven',
899
        'eight',          'nine',           'colon',          'semicolon',
900
        'less',           'equal',          'greater',        'question',
901
        'at',             'A',              'B',              'C',
902
        'D',              'E',              'F',              'G',
903
        'H',              'I',              'J',              'K',
904
        'L',              'M',              'N',              'O',
905
        'P',              'Q',              'R',              'S',
906
        'T',              'U',              'V',              'W',
907
        'X',              'Y',              'Z',              'bracketleft',
908
        'backslash',      'bracketright',   'asciicircum',    'underscore',
909
        'grave',          'a',              'b',              'c',
910
        'd',              'e',              'f',              'g',
911
        'h',              'i',              'j',              'k',
912
        'l',              'm',              'n',              'o',
913
        'p',              'q',              'r',              's',
914
        't',              'u',              'v',              'w',
915
        'x',              'y',              'z',              'braceleft',
916
        'bar',            'braceright',     'asciitilde',     '.notdef',
917
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
918
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
919
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
920
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
921
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
922
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
923
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
924
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
925
        'space',          'quoteleft',      'quoteright',     'sterling',
926
        '.notdef',        '.notdef',        'brokenbar',      'section',
927
        'dieresis',       'copyright',      '.notdef',        'guillemotleft',
928
        'logicalnot',     'hyphen',         '.notdef',        'afii00208',
929
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
930
        'tonos',          'dieresistonos',  'Alphatonos',     'periodcentered',
931
        'Epsilontonos',   'Etatonos',       'Iotatonos',      'guillemotright',
932
        'Omicrontonos',   'onehalf',        'Upsilontonos',   'Omegatonos',
933
        'iotadieresistonos','Alpha',          'Beta',           'Gamma',
934
        'Delta',          'Epsilon',        'Zeta',           'Eta',
935
        'Theta',          'Iota',           'Kappa',          'Lambda',
936
        'Mu',             'Nu',             'Xi',             'Omicron',
937
        'Pi',             'Rho',            '.notdef',        'Sigma',
938
        'Tau',            'Upsilon',        'Phi',            'Chi',
939
        'Psi',            'Omega',          'Iotadieresis',   'Upsilondieresis',
940
        'alphatonos',     'epsilontonos',   'etatonos',       'iotatonos',
941
        'upsilondieresistonos','alpha',          'beta',           'gamma',
942
        'delta',          'epsilon',        'zeta',           'eta',
943
        'theta',          'iota',           'kappa',          'lambda',
944
        'mu',             'nu',             'xi',             'omicron',
945
        'pi',             'rho',            'sigma1',         'sigma',
946
        'tau',            'upsilon',        'phi',            'chi',
947
        'psi',            'omega',          'iotadieresis',   'upsilondieresis',
948
        'omicrontonos',   'upsilontonos',   'omegatonos',     '.notdef'
949
    ],
950
# Turkish
951
    'ISO-8859-9' => [
952
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
953
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
954
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
955
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
956
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
957
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
958
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
959
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
960
        'space',          'exclam',         'quotedbl',       'numbersign',
961
        'dollar',         'percent',        'ampersand',      'quotesingle',
962
        'parenleft',      'parenright',     'asterisk',       'plus',
963
        'comma',          'hyphen',         'period',         'slash',
964
        'zero',           'one',            'two',            'three',
965
        'four',           'five',           'six',            'seven',
966
        'eight',          'nine',           'colon',          'semicolon',
967
        'less',           'equal',          'greater',        'question',
968
        'at',             'A',              'B',              'C',
969
        'D',              'E',              'F',              'G',
970
        'H',              'I',              'J',              'K',
971
        'L',              'M',              'N',              'O',
972
        'P',              'Q',              'R',              'S',
973
        'T',              'U',              'V',              'W',
974
        'X',              'Y',              'Z',              'bracketleft',
975
        'backslash',      'bracketright',   'asciicircum',    'underscore',
976
        'grave',          'a',              'b',              'c',
977
        'd',              'e',              'f',              'g',
978
        'h',              'i',              'j',              'k',
979
        'l',              'm',              'n',              'o',
980
        'p',              'q',              'r',              's',
981
        't',              'u',              'v',              'w',
982
        'x',              'y',              'z',              'braceleft',
983
        'bar',            'braceright',     'asciitilde',     '.notdef',
984
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
985
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
986
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
987
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
988
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
989
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
990
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
991
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
992
        'space',          'exclamdown',     'cent',           'sterling',
993
        'currency',       'yen',            'brokenbar',      'section',
994
        'dieresis',       'copyright',      'ordfeminine',    'guillemotleft',
995
        'logicalnot',     'hyphen',         'registered',     'macron',
996
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
997
        'acute',          'mu',             'paragraph',      'periodcentered',
998
        'cedilla',        'onesuperior',    'ordmasculine',   'guillemotright',
999
        'onequarter',     'onehalf',        'threequarters',  'questiondown',
1000
        'Agrave',         'Aacute',         'Acircumflex',    'Atilde',
1001
        'Adieresis',      'Aring',          'AE',             'Ccedilla',
1002
        'Egrave',         'Eacute',         'Ecircumflex',    'Edieresis',
1003
        'Igrave',         'Iacute',         'Icircumflex',    'Idieresis',
1004
        'Gbreve',         'Ntilde',         'Ograve',         'Oacute',
1005
        'Ocircumflex',    'Otilde',         'Odieresis',      'multiply',
1006
        'Oslash',         'Ugrave',         'Uacute',         'Ucircumflex',
1007
        'Udieresis',      'Idotaccent',     'Scedilla',       'germandbls',
1008
        'agrave',         'aacute',         'acircumflex',    'atilde',
1009
        'adieresis',      'aring',          'ae',             'ccedilla',
1010
        'egrave',         'eacute',         'ecircumflex',    'edieresis',
1011
        'igrave',         'iacute',         'icircumflex',    'idieresis',
1012
        'gbreve',         'ntilde',         'ograve',         'oacute',
1013
        'ocircumflex',    'otilde',         'odieresis',      'divide',
1014
        'oslash',         'ugrave',         'uacute',         'ucircumflex',
1015
        'udieresis',      'dotlessi',       'scedilla',       'ydieresis'
1016
    ],
1017
# Thai
1018
    'ISO-8859-11' => [
1019
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1020
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1021
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1022
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1023
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1024
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1025
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1026
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1027
        'space',          'exclam',         'quotedbl',       'numbersign',
1028
        'dollar',         'percent',        'ampersand',      'quotesingle',
1029
        'parenleft',      'parenright',     'asterisk',       'plus',
1030
        'comma',          'hyphen',         'period',         'slash',
1031
        'zero',           'one',            'two',            'three',
1032
        'four',           'five',           'six',            'seven',
1033
        'eight',          'nine',           'colon',          'semicolon',
1034
        'less',           'equal',          'greater',        'question',
1035
        'at',             'A',              'B',              'C',
1036
        'D',              'E',              'F',              'G',
1037
        'H',              'I',              'J',              'K',
1038
        'L',              'M',              'N',              'O',
1039
        'P',              'Q',              'R',              'S',
1040
        'T',              'U',              'V',              'W',
1041
        'X',              'Y',              'Z',              'bracketleft',
1042
        'backslash',      'bracketright',   'asciicircum',    'underscore',
1043
        'grave',          'a',              'b',              'c',
1044
        'd',              'e',              'f',              'g',
1045
        'h',              'i',              'j',              'k',
1046
        'l',              'm',              'n',              'o',
1047
        'p',              'q',              'r',              's',
1048
        't',              'u',              'v',              'w',
1049
        'x',              'y',              'z',              'braceleft',
1050
        'bar',            'braceright',     'asciitilde',     '.notdef',
1051
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1052
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1053
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1054
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1055
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1056
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1057
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1058
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1059
        'space',          'kokaithai',      'khokhaithai',    'khokhuatthai',
1060
        'khokhwaithai',   'khokhonthai',    'khorakhangthai', 'ngonguthai',
1061
        'chochanthai',    'chochingthai',   'chochangthai',   'sosothai',
1062
        'chochoethai',    'yoyingthai',     'dochadathai',    'topatakthai',
1063
        'thothanthai',    'thonangmonthothai','thophuthaothai', 'nonenthai',
1064
        'dodekthai',      'totaothai',      'thothungthai',   'thothahanthai',
1065
        'thothongthai',   'nonuthai',       'bobaimaithai',   'poplathai',
1066
        'phophungthai',   'fofathai',       'phophanthai',    'fofanthai',
1067
        'phosamphaothai', 'momathai',       'yoyakthai',      'roruathai',
1068
        'ruthai',         'lolingthai',     'luthai',         'wowaenthai',
1069
        'sosalathai',     'sorusithai',     'sosuathai',      'hohipthai',
1070
        'lochulathai',    'oangthai',       'honokhukthai',   'paiyannoithai',
1071
        'saraathai',      'maihanakatthai', 'saraaathai',     'saraamthai',
1072
        'saraithai',      'saraiithai',     'sarauethai',     'saraueethai',
1073
        'sarauthai',      'sarauuthai',     'phinthuthai',    '.notdef',
1074
        '.notdef',        '.notdef',        '.notdef',        'bahtthai',
1075
        'saraethai',      'saraaethai',     'saraothai',      'saraaimaimuanthai',
1076
        'saraaimaimalaithai','lakkhangyaothai','maiyamokthai',   'maitaikhuthai',
1077
        'maiekthai',      'maithothai',     'maitrithai',     'maichattawathai',
1078
        'thanthakhatthai','nikhahitthai',   'yamakkanthai',   'fongmanthai',
1079
        'zerothai',       'onethai',        'twothai',        'threethai',
1080
        'fourthai',       'fivethai',       'sixthai',        'seventhai',
1081
        'eightthai',      'ninethai',       'angkhankhuthai', 'khomutthai',
1082
        '.notdef',        '.notdef',        '.notdef',        '.notdef'
1083
    ],
1084
# Western Europe
1085
    'ISO-8859-15' => [
1086
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1087
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1088
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1089
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1090
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1091
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1092
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1093
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1094
        'space',          'exclam',         'quotedbl',       'numbersign',
1095
        'dollar',         'percent',        'ampersand',      'quotesingle',
1096
        'parenleft',      'parenright',     'asterisk',       'plus',
1097
        'comma',          'hyphen',         'period',         'slash',
1098
        'zero',           'one',            'two',            'three',
1099
        'four',           'five',           'six',            'seven',
1100
        'eight',          'nine',           'colon',          'semicolon',
1101
        'less',           'equal',          'greater',        'question',
1102
        'at',             'A',              'B',              'C',
1103
        'D',              'E',              'F',              'G',
1104
        'H',              'I',              'J',              'K',
1105
        'L',              'M',              'N',              'O',
1106
        'P',              'Q',              'R',              'S',
1107
        'T',              'U',              'V',              'W',
1108
        'X',              'Y',              'Z',              'bracketleft',
1109
        'backslash',      'bracketright',   'asciicircum',    'underscore',
1110
        'grave',          'a',              'b',              'c',
1111
        'd',              'e',              'f',              'g',
1112
        'h',              'i',              'j',              'k',
1113
        'l',              'm',              'n',              'o',
1114
        'p',              'q',              'r',              's',
1115
        't',              'u',              'v',              'w',
1116
        'x',              'y',              'z',              'braceleft',
1117
        'bar',            'braceright',     'asciitilde',     '.notdef',
1118
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1119
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1120
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1121
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1122
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1123
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1124
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1125
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1126
        'space',          'exclamdown',     'cent',           'sterling',
1127
        'Euro',           'yen',            'Scaron',         'section',
1128
        'scaron',         'copyright',      'ordfeminine',    'guillemotleft',
1129
        'logicalnot',     'hyphen',         'registered',     'macron',
1130
        'degree',         'plusminus',      'twosuperior',    'threesuperior',
1131
        'Zcaron',         'mu',             'paragraph',      'periodcentered',
1132
        'zcaron',         'onesuperior',    'ordmasculine',   'guillemotright',
1133
        'OE',             'oe',             'Ydieresis',      'questiondown',
1134
        'Agrave',         'Aacute',         'Acircumflex',    'Atilde',
1135
        'Adieresis',      'Aring',          'AE',             'Ccedilla',
1136
        'Egrave',         'Eacute',         'Ecircumflex',    'Edieresis',
1137
        'Igrave',         'Iacute',         'Icircumflex',    'Idieresis',
1138
        'Eth',            'Ntilde',         'Ograve',         'Oacute',
1139
        'Ocircumflex',    'Otilde',         'Odieresis',      'multiply',
1140
        'Oslash',         'Ugrave',         'Uacute',         'Ucircumflex',
1141
        'Udieresis',      'Yacute',         'Thorn',          'germandbls',
1142
        'agrave',         'aacute',         'acircumflex',    'atilde',
1143
        'adieresis',      'aring',          'ae',             'ccedilla',
1144
        'egrave',         'eacute',         'ecircumflex',    'edieresis',
1145
        'igrave',         'iacute',         'icircumflex',    'idieresis',
1146
        'eth',            'ntilde',         'ograve',         'oacute',
1147
        'ocircumflex',    'otilde',         'odieresis',      'divide',
1148
        'oslash',         'ugrave',         'uacute',         'ucircumflex',
1149
        'udieresis',      'yacute',         'thorn',          'ydieresis'
1150
    ],
1151
# Central Europe
1152
    'ISO-8859-16' => [
1153
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1154
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1155
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1156
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1157
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1158
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1159
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1160
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1161
        'space',          'exclam',         'quotedbl',       'numbersign',
1162
        'dollar',         'percent',        'ampersand',      'quotesingle',
1163
        'parenleft',      'parenright',     'asterisk',       'plus',
1164
        'comma',          'hyphen',         'period',         'slash',
1165
        'zero',           'one',            'two',            'three',
1166
        'four',           'five',           'six',            'seven',
1167
        'eight',          'nine',           'colon',          'semicolon',
1168
        'less',           'equal',          'greater',        'question',
1169
        'at',             'A',              'B',              'C',
1170
        'D',              'E',              'F',              'G',
1171
        'H',              'I',              'J',              'K',
1172
        'L',              'M',              'N',              'O',
1173
        'P',              'Q',              'R',              'S',
1174
        'T',              'U',              'V',              'W',
1175
        'X',              'Y',              'Z',              'bracketleft',
1176
        'backslash',      'bracketright',   'asciicircum',    'underscore',
1177
        'grave',          'a',              'b',              'c',
1178
        'd',              'e',              'f',              'g',
1179
        'h',              'i',              'j',              'k',
1180
        'l',              'm',              'n',              'o',
1181
        'p',              'q',              'r',              's',
1182
        't',              'u',              'v',              'w',
1183
        'x',              'y',              'z',              'braceleft',
1184
        'bar',            'braceright',     'asciitilde',     '.notdef',
1185
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1186
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1187
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1188
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1189
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1190
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1191
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1192
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1193
        'space',          'Aogonek',        'aogonek',        'Lslash',
1194
        'Euro',           'quotedblbase',   'Scaron',         'section',
1195
        'scaron',         'copyright',      'Scommaaccent',   'guillemotleft',
1196
        'Zacute',         'hyphen',         'zacute',         'Zdotaccent',
1197
        'degree',         'plusminus',      'Ccaron',         'lslash',
1198
        'Zcaron',         'quotedblright',  'paragraph',      'periodcentered',
1199
        'zcaron',         'ccaron',         'scommaaccent',   'guillemotright',
1200
        'OE',             'oe',             'Ydieresis',      'zdotaccent',
1201
        'Agrave',         'Aacute',         'Acircumflex',    'Abreve',
1202
        'Adieresis',      'Cacute',         'AE',             'Ccedilla',
1203
        'Egrave',         'Eacute',         'Ecircumflex',    'Edieresis',
1204
        'Igrave',         'Iacute',         'Icircumflex',    'Idieresis',
1205
        'Dcroat',         'Nacute',         'Ograve',         'Oacute',
1206
        'Ocircumflex',    'Ohungarumlaut',  'Odieresis',      'Sacute',
1207
        'Uhungarumlaut',  'Ugrave',         'Uacute',         'Ucircumflex',
1208
        'Udieresis',      'Eogonek',        'Tcommaaccent',   'germandbls',
1209
        'agrave',         'aacute',         'acircumflex',    'abreve',
1210
        'adieresis',      'cacute',         'ae',             'ccedilla',
1211
        'egrave',         'eacute',         'ecircumflex',    'edieresis',
1212
        'igrave',         'iacute',         'icircumflex',    'idieresis',
1213
        'dcroat',         'nacute',         'ograve',         'oacute',
1214
        'ocircumflex',    'ohungarumlaut',  'odieresis',      'sacute',
1215
        'uhungarumlaut',  'ugrave',         'uacute',         'ucircumflex',
1216
        'udieresis',      'eogonek',        'tcommaaccent',   'ydieresis'
1217
    ],
1218
# Russian
1219
    'KOI8-R' => [
1220
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1221
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1222
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1223
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1224
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1225
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1226
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1227
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1228
        'space',          'exclam',         'quotedbl',       'numbersign',
1229
        'dollar',         'percent',        'ampersand',      'quotesingle',
1230
        'parenleft',      'parenright',     'asterisk',       'plus',
1231
        'comma',          'hyphen',         'period',         'slash',
1232
        'zero',           'one',            'two',            'three',
1233
        'four',           'five',           'six',            'seven',
1234
        'eight',          'nine',           'colon',          'semicolon',
1235
        'less',           'equal',          'greater',        'question',
1236
        'at',             'A',              'B',              'C',
1237
        'D',              'E',              'F',              'G',
1238
        'H',              'I',              'J',              'K',
1239
        'L',              'M',              'N',              'O',
1240
        'P',              'Q',              'R',              'S',
1241
        'T',              'U',              'V',              'W',
1242
        'X',              'Y',              'Z',              'bracketleft',
1243
        'backslash',      'bracketright',   'asciicircum',    'underscore',
1244
        'grave',          'a',              'b',              'c',
1245
        'd',              'e',              'f',              'g',
1246
        'h',              'i',              'j',              'k',
1247
        'l',              'm',              'n',              'o',
1248
        'p',              'q',              'r',              's',
1249
        't',              'u',              'v',              'w',
1250
        'x',              'y',              'z',              'braceleft',
1251
        'bar',            'braceright',     'asciitilde',     '.notdef',
1252
        'SF100000',       'SF110000',       'SF010000',       'SF030000',
1253
        'SF020000',       'SF040000',       'SF080000',       'SF090000',
1254
        'SF060000',       'SF070000',       'SF050000',       'upblock',
1255
        'dnblock',        'block',          'lfblock',        'rtblock',
1256
        'ltshade',        'shade',          'dkshade',        'integraltp',
1257
        'filledbox',      'periodcentered', 'radical',        'approxequal',
1258
        'lessequal',      'greaterequal',   'space',          'integralbt',
1259
        'degree',         'twosuperior',    'periodcentered', 'divide',
1260
        'SF430000',       'SF240000',       'SF510000',       'afii10071',
1261
        'SF520000',       'SF390000',       'SF220000',       'SF210000',
1262
        'SF250000',       'SF500000',       'SF490000',       'SF380000',
1263
        'SF280000',       'SF270000',       'SF260000',       'SF360000',
1264
        'SF370000',       'SF420000',       'SF190000',       'afii10023',
1265
        'SF200000',       'SF230000',       'SF470000',       'SF480000',
1266
        'SF410000',       'SF450000',       'SF460000',       'SF400000',
1267
        'SF540000',       'SF530000',       'SF440000',       'copyright',
1268
        'afii10096',      'afii10065',      'afii10066',      'afii10088',
1269
        'afii10069',      'afii10070',      'afii10086',      'afii10068',
1270
        'afii10087',      'afii10074',      'afii10075',      'afii10076',
1271
        'afii10077',      'afii10078',      'afii10079',      'afii10080',
1272
        'afii10081',      'afii10097',      'afii10082',      'afii10083',
1273
        'afii10084',      'afii10085',      'afii10072',      'afii10067',
1274
        'afii10094',      'afii10093',      'afii10073',      'afii10090',
1275
        'afii10095',      'afii10091',      'afii10089',      'afii10092',
1276
        'afii10048',      'afii10017',      'afii10018',      'afii10040',
1277
        'afii10021',      'afii10022',      'afii10038',      'afii10020',
1278
        'afii10039',      'afii10026',      'afii10027',      'afii10028',
1279
        'afii10029',      'afii10030',      'afii10031',      'afii10032',
1280
        'afii10033',      'afii10049',      'afii10034',      'afii10035',
1281
        'afii10036',      'afii10037',      'afii10024',      'afii10019',
1282
        'afii10046',      'afii10045',      'afii10025',      'afii10042',
1283
        'afii10047',      'afii10043',      'afii10041',      'afii10044'
1284
    ],
1285
# Ukrainian
1286
    'KOI8-U' => [
1287
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1288
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1289
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1290
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1291
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1292
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1293
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1294
        '.notdef',        '.notdef',        '.notdef',        '.notdef',
1295
        'space',          'exclam',         'quotedbl',       'numbersign',
1296
        'dollar',         'percent',        'ampersand',      'quotesingle',
1297
        'parenleft',      'parenright',     'asterisk',       'plus',
1298
        'comma',          'hyphen',         'period',         'slash',
1299
        'zero',           'one',            'two',            'three',
1300
        'four',           'five',           'six',            'seven',
1301
        'eight',          'nine',           'colon',          'semicolon',
1302
        'less',           'equal',          'greater',        'question',
1303
        'at',             'A',              'B',              'C',
1304
        'D',              'E',              'F',              'G',
1305
        'H',              'I',              'J',              'K',
1306
        'L',              'M',              'N',              'O',
1307
        'P',              'Q',              'R',              'S',
1308
        'T',              'U',              'V',              'W',
1309
        'X',              'Y',              'Z',              'bracketleft',
1310
        'backslash',      'bracketright',   'asciicircum',    'underscore',
1311
        'grave',          'a',              'b',              'c',
1312
        'd',              'e',              'f',              'g',
1313
        'h',              'i',              'j',              'k',
1314
        'l',              'm',              'n',              'o',
1315
        'p',              'q',              'r',              's',
1316
        't',              'u',              'v',              'w',
1317
        'x',              'y',              'z',              'braceleft',
1318
        'bar',            'braceright',     'asciitilde',     '.notdef',
1319
        'SF100000',       'SF110000',       'SF010000',       'SF030000',
1320
        'SF020000',       'SF040000',       'SF080000',       'SF090000',
1321
        'SF060000',       'SF070000',       'SF050000',       'upblock',
1322
        'dnblock',        'block',          'lfblock',        'rtblock',
1323
        'ltshade',        'shade',          'dkshade',        'integraltp',
1324
        'filledbox',      'bullet',         'radical',        'approxequal',
1325
        'lessequal',      'greaterequal',   'space',          'integralbt',
1326
        'degree',         'twosuperior',    'periodcentered', 'divide',
1327
        'SF430000',       'SF240000',       'SF510000',       'afii10071',
1328
        'afii10101',      'SF390000',       'afii10103',      'afii10104',
1329
        'SF250000',       'SF500000',       'SF490000',       'SF380000',
1330
        'SF280000',       'afii10098',      'SF260000',       'SF360000',
1331
        'SF370000',       'SF420000',       'SF190000',       'afii10023',
1332
        'afii10053',      'SF230000',       'afii10055',      'afii10056',
1333
        'SF410000',       'SF450000',       'SF460000',       'SF400000',
1334
        'SF540000',       'afii10050',      'SF440000',       'copyright',
1335
        'afii10096',      'afii10065',      'afii10066',      'afii10088',
1336
        'afii10069',      'afii10070',      'afii10086',      'afii10068',
1337
        'afii10087',      'afii10074',      'afii10075',      'afii10076',
1338
        'afii10077',      'afii10078',      'afii10079',      'afii10080',
1339
        'afii10081',      'afii10097',      'afii10082',      'afii10083',
1340
        'afii10084',      'afii10085',      'afii10072',      'afii10067',
1341
        'afii10094',      'afii10093',      'afii10073',      'afii10090',
1342
        'afii10095',      'afii10091',      'afii10089',      'afii10092',
1343
        'afii10048',      'afii10017',      'afii10018',      'afii10040',
1344
        'afii10021',      'afii10022',      'afii10038',      'afii10020',
1345
        'afii10039',      'afii10026',      'afii10027',      'afii10028',
1346
        'afii10029',      'afii10030',      'afii10031',      'afii10032',
1347
        'afii10033',      'afii10049',      'afii10034',      'afii10035',
1348
        'afii10036',      'afii10037',      'afii10024',      'afii10019',
1349
        'afii10046',      'afii10045',      'afii10025',      'afii10042',
1350
        'afii10047',      'afii10043',      'afii10041',      'afii10044'
1351
    ]
1352
}
1353

    
1354
def ReadAFM(file, map)
1355

    
1356
    # Read a font metric file
1357
    a = IO.readlines(file)
1358

    
1359
    raise "File no found: #{file}" if a.size == 0
1360

    
1361
    widths = {}
1362
    fm = {}
1363
    fix = { 'Edot' => 'Edotaccent', 'edot' => 'edotaccent',
1364
            'Idot' => 'Idotaccent',
1365
            'Zdot' => 'Zdotaccent', 'zdot' => 'zdotaccent',
1366
            'Odblacute' => 'Ohungarumlaut', 'odblacute' => 'ohungarumlaut',
1367
            'Udblacute' => 'Uhungarumlaut', 'udblacute' => 'uhungarumlaut',
1368
            'Gcedilla' => 'Gcommaaccent', 'gcedilla' => 'gcommaaccent',
1369
            'Kcedilla' => 'Kcommaaccent', 'kcedilla' => 'kcommaaccent',
1370
            'Lcedilla' => 'Lcommaaccent', 'lcedilla' => 'lcommaaccent',
1371
            'Ncedilla' => 'Ncommaaccent', 'ncedilla' => 'ncommaaccent',
1372
            'Rcedilla' => 'Rcommaaccent', 'rcedilla' => 'rcommaaccent',
1373
            'Scedilla' => 'Scommaaccent',' scedilla' => 'scommaaccent',
1374
            'Tcedilla' => 'Tcommaaccent',' tcedilla' => 'tcommaaccent',
1375
            'Dslash' => 'Dcroat', 'dslash' => 'dcroat',
1376
            'Dmacron' => 'Dcroat', 'dmacron' => 'dcroat',
1377
            'combininggraveaccent' => 'gravecomb',
1378
            'combininghookabove' => 'hookabovecomb',
1379
            'combiningtildeaccent' => 'tildecomb',
1380
            'combiningacuteaccent' => 'acutecomb',
1381
            'combiningdotbelow' => 'dotbelowcomb',
1382
            'dongsign' => 'dong'
1383
        }
1384

    
1385
    a.each do |line|
1386

    
1387
        e = line.rstrip.split(' ')
1388
	next if e.size < 2
1389

    
1390
	code  = e[0]
1391
	param = e[1]
1392

    
1393
	if code == 'C' then
1394

    
1395
	    # Character metrics
1396
	    cc = e[1].to_i
1397
	    w  = e[4]
1398
	    gn = e[7]
1399

    
1400
	    gn = 'Euro' if gn[-4, 4] == '20AC'
1401

    
1402
	    if fix[gn] then
1403

    
1404
		# Fix incorrect glyph name
1405
		0.upto(map.size - 1) do |i|
1406
		    if map[i] == fix[gn] then
1407
			map[i] = gn
1408
		    end
1409
		end
1410
	    end
1411

    
1412
	    if map.size == 0 then
1413
		# Symbolic font: use built-in encoding
1414
		widths[cc] = w
1415
	    else
1416
		widths[gn] = w
1417
		fm['CapXHeight'] = e[13].to_i if gn == 'X'
1418
	    end
1419

    
1420
	    fm['MissingWidth'] = w if gn == '.notdef'
1421

    
1422
	elsif code == 'FontName' then
1423
	    fm['FontName'] = param
1424
	elsif code == 'Weight' then
1425
	    fm['Weight'] = param
1426
	elsif code == 'ItalicAngle' then
1427
	    fm['ItalicAngle'] = param.to_f
1428
	elsif code == 'Ascender' then
1429
	    fm['Ascender'] = param.to_i
1430
	elsif code == 'Descender' then
1431
	    fm['Descender'] = param.to_i
1432
	elsif code == 'UnderlineThickness' then
1433
	    fm['UnderlineThickness'] = param.to_i
1434
	elsif code == 'UnderlinePosition' then
1435
	    fm['UnderlinePosition'] = param.to_i
1436
	elsif code == 'IsFixedPitch' then
1437
	    fm['IsFixedPitch'] = (param == 'true')
1438
	elsif code == 'FontBBox' then
1439
	    fm['FontBBox'] = "[#{e[1]},#{e[2]},#{e[3]},#{e[4]}]"
1440
	elsif code == 'CapHeight' then
1441
	    fm['CapHeight'] = param.to_i
1442
	elsif code == 'StdVW' then
1443
	    fm['StdVW'] = param.to_i
1444
	end
1445
    end
1446

    
1447
    raise 'FontName not found' unless fm['FontName']
1448

    
1449
    if map.size > 0 then
1450
	widths['.notdef'] = 600 unless widths['.notdef']
1451

    
1452
	if (widths['Delta'] == nil) && widths['increment'] then
1453
	    widths['Delta'] = widths['increment']
1454
	end
1455

    
1456
	# Order widths according to map
1457
	0.upto(255) do |i|
1458
	    if widths[map[i]] == nil
1459
		puts "Warning: character #{map[i]} is missing"
1460
		widths[i] = widths['.notdef']
1461
	    else
1462
		widths[i] = widths[map[i]]
1463
	    end
1464
	end
1465
    end
1466

    
1467
    fm['Widths'] = widths
1468

    
1469
    return fm
1470
end
1471

    
1472
def MakeFontDescriptor(fm, symbolic)
1473

    
1474
    # Ascent
1475
    asc = fm['Ascender'] ? fm['Ascender'] : 1000
1476
    fd = "{\n        'Ascent' => '#{asc}'"
1477

    
1478
    # Descent
1479
    desc = fm['Descender'] ? fm['Descender'] : -200
1480
    fd += ", 'Descent' => '#{desc}'"
1481

    
1482
    # CapHeight
1483
    if fm['CapHeight'] then
1484
        ch = fm['CapHeight']
1485
    elsif fm['CapXHeight']
1486
        ch = fm['CapXHeight']
1487
    else
1488
        ch = asc
1489
    end
1490
    fd += ", 'CapHeight' => '#{ch}'"
1491

    
1492
    # Flags
1493
    flags = 0
1494

    
1495
    if fm['IsFixedPitch'] then
1496
        flags += 1 << 0
1497
    end
1498

    
1499
    if symbolic then
1500
        flags += 1 << 2
1501
    else
1502
        flags += 1 << 5
1503
    end
1504

    
1505
    if fm['ItalicAngle'] && (fm['ItalicAngle'] != 0) then
1506
        flags += 1 << 6
1507
    end
1508

    
1509
    fd += ",\n        'Flags' => '#{flags}'"
1510

    
1511
    # FontBBox
1512
    if fm['FontBBox'] then
1513
        fbb = fm['FontBBox'].gsub(/,/, ' ')
1514
    else
1515
        fbb = "[0 #{desc - 100} 1000 #{asc + 100}]"
1516
    end
1517

    
1518
    fd += ", 'FontBBox' => '#{fbb}'"
1519

    
1520
    # ItalicAngle
1521
    ia = fm['ItalicAngle'] ? fm['ItalicAngle'] : 0
1522
    fd += ",\n        'ItalicAngle' => '#{ia}'"
1523

    
1524
    # StemV
1525
    if fm['StdVW'] then
1526
        stemv = fm['StdVW']
1527
    elsif fm['Weight'] && (/bold|black/i =~ fm['Weight'])
1528
        stemv = 120
1529
    else
1530
        stemv = 70
1531
    end
1532

    
1533
    fd += ", 'StemV' => '#{stemv}'"
1534

    
1535
    # MissingWidth
1536
    if fm['MissingWidth'] then
1537
        fd += ", 'MissingWidth' => '#{fm['MissingWidth']}'"
1538
    end
1539

    
1540
    fd += "\n        }"
1541
    return fd
1542
end
1543

    
1544
def MakeWidthArray(fm)
1545

    
1546
    # Make character width array
1547
    s = "        [\n        "
1548

    
1549
    cw = fm['Widths']
1550

    
1551
    0.upto(255) do |i|
1552
        s += "%5d" % cw[i]
1553
        s += "," if i != 255
1554
        s += "\n        " if (i % 8) == 7
1555
    end
1556

    
1557
    s += ']'
1558

    
1559
    return s
1560
end
1561

    
1562
def MakeFontEncoding(map)
1563

    
1564
    # Build differences from reference encoding
1565
    ref = Charencodings['cp1252']
1566
    s = ''
1567
    last = 0
1568
    32.upto(255) do |i|
1569
	if map[i] != ref[i] then
1570
	    if i != last + 1 then
1571
		s += i.to_s + ' '
1572
            end
1573
	    last = i
1574
	    s += '/' + map[i] + ' '
1575
	end
1576
    end
1577
    return s.rstrip
1578
end
1579

    
1580
def ReadShort(f)
1581
    a = f.read(2).unpack('n')
1582
    return a[0]
1583
end
1584

    
1585
def ReadLong(f)
1586
    a = f.read(4).unpack('N')
1587
    return a[0]
1588
end
1589

    
1590
def CheckTTF(file)
1591

    
1592
    rl = false
1593
    pp = false
1594
    e  = false
1595

    
1596
    # Check if font license allows embedding
1597
    File.open(file, 'rb') do |f|
1598

    
1599
        # Extract number of tables
1600
        f.seek(4, IO::SEEK_CUR)
1601
	nb = ReadShort(f)
1602
        f.seek(6, IO::SEEK_CUR)
1603

    
1604
        # Seek OS/2 table
1605
	found = false
1606
        0.upto(nb - 1) do |i|
1607
            if f.read(4) == 'OS/2' then
1608
                found = true
1609
                break
1610
            end
1611

    
1612
           f.seek(12, IO::SEEK_CUR)
1613
        end
1614

    
1615
	if ! found then
1616
            return
1617
        end
1618

    
1619
        f.seek(4, IO::SEEK_CUR)
1620
        offset = ReadLong(f)
1621
        f.seek(offset, IO::SEEK_SET)
1622

    
1623
        # Extract fsType flags
1624
        f.seek(8, IO::SEEK_CUR)
1625
	fsType = ReadShort(f)
1626

    
1627
	rl = (fsType & 0x02) != 0
1628
	pp = (fsType & 0x04) != 0
1629
	e  = (fsType & 0x08) != 0
1630
    end
1631

    
1632
    if rl && ( ! pp) && ( ! e) then
1633
        puts 'Warning: font license does not allow embedding'
1634
    end
1635
end
1636

    
1637
#
1638
# fontfile: path to TTF file (or empty string if not to be embedded)
1639
# afmfile:  path to AFM file
1640
# enc:      font encoding (or empty string for symbolic fonts)
1641
# patch:    optional patch for encoding
1642
# type :    font type if $fontfile is empty
1643
#
1644
def MakeFont(fontfile, afmfile, enc = 'cp1252', patch = {}, type = 'TrueType')
1645
    # Generate a font definition file
1646
    if (enc != nil) && (enc != '') then
1647
	map = Charencodings[enc]
1648
	patch.each { |cc, gn| map[cc] = gn }
1649
    else
1650
	map = []
1651
    end
1652

    
1653
    raise "Error: AFM file not found: #{afmfile}" unless File.exists?(afmfile)
1654

    
1655
    fm = ReadAFM(afmfile, map)
1656

    
1657
    if (enc != nil) && (enc != '') then
1658
	diff = MakeFontEncoding(map)
1659
    else
1660
	diff = ''
1661
    end
1662

    
1663
    fd = MakeFontDescriptor(fm, (map.size == 0))
1664

    
1665
    # Find font type
1666
    if fontfile then
1667
        ext = File.extname(fontfile).downcase.sub(/^\./, '')
1668

    
1669
        if ext == 'ttf' then
1670
            type = 'TrueType'
1671
        elsif ext == 'pfb'
1672
            type = 'Type1'
1673
        else
1674
            raise "Error: unrecognized font file extension: #{ext}"
1675
        end
1676
    else
1677
	    raise "Error: incorrect font type: #{type}" if (type != 'TrueType') && (type != 'Type1')
1678
    end
1679
    printf "type = #{type}\n"
1680
    # Start generation
1681
    s  = "# #{fm['FontName']} font definition\n\n"
1682
    s += "module FontDef\n"
1683
    s += "    def FontDef.type\n        '#{type}'\n    end\n"
1684
    s += "    def FontDef.name\n        '#{fm['FontName']}'\n    end\n"
1685
    s += "    def FontDef.desc\n        #{fd}\n    end\n"
1686

    
1687
    if fm['UnderlinePosition'] == nil then
1688
        fm['UnderlinePosition'] = -100
1689
    end
1690

    
1691
    if fm['UnderlineThickness'] == nil then
1692
        fm['UnderlineThickness'] = 50
1693
    end
1694

    
1695
    s += "    def FontDef.up\n        #{fm['UnderlinePosition']}\n    end\n"
1696
    s += "    def FontDef.ut\n        #{fm['UnderlineThickness']}\n    end\n"
1697

    
1698
    w = MakeWidthArray(fm)
1699
    s += "    def FontDef.cw\n#{w}\n    end\n"
1700

    
1701
    s += "    def FontDef.enc\n        '#{enc}'\n    end\n"
1702
    s += "    def FontDef.diff\n        #{(diff == nil) || (diff == '') ? 'nil' : '\'' + diff '\''}\n    end\n"
1703

    
1704
    basename = File.basename(afmfile, '.*')
1705

    
1706
    if fontfile then
1707
        # Embedded font
1708
        if ! File.exist?(fontfile) then
1709
            raise "Error: font file not found: #{fontfile}"
1710
        end
1711

    
1712
        if type == 'TrueType' then
1713
            CheckTTF(fontfile)
1714
        end
1715

    
1716
	file = ''
1717
        File.open(fontfile, 'rb') do |f|
1718
            file = f.read()
1719
        end
1720

    
1721
        if type == 'Type1' then
1722
            # Find first two sections and discard third one
1723
            header = file[0] == 128
1724
            file = file[6, file.length - 6] if header
1725

    
1726
            pos = file.index('eexec')
1727
            raise 'Error: font file does not seem to be valid Type1' if pos == nil
1728

    
1729
            size1 = pos + 6
1730

    
1731
            file = file[0, size1] + file[size1 + 6, file.length - (size1 + 6)] if header && file[size1] == 128
1732

    
1733
            pos = file.index('00000000')
1734
            raise 'Error: font file does not seem to be valid Type1' if pos == nil
1735

    
1736
            size2 = pos - size1
1737
            file = file[0, size1 + size2]
1738
        end
1739

    
1740
        if require 'zlib' then
1741
            File.open(basename + '.z', 'wb') { |f| f.write(Zlib::Deflate.deflate(file)) }
1742
            s += "    def FontDef.file\n        '#{basename}.z'\n    end\n"
1743
            puts "Font file compressed ('#{basename}.z')"
1744
        else
1745
            s += "    def FontDef.file\n        '#{File.basename(fontfile)}'\n    end\n"
1746
            puts 'Notice: font file could not be compressed (zlib not available)'
1747
        end
1748

    
1749
        if type == 'Type1' then
1750
            s += "    def FontDef.size1\n        '#{size1}'\n    end\n"
1751
            s += "    def FontDef.size2\n        '#{size2}'\n    end\n"
1752
        else
1753
            s += "    def FontDef.originalsize\n        '#{File.size(fontfile)}'\n    end\n"
1754
        end
1755

    
1756
    else
1757
        # Not embedded font
1758
        s += "    def FontDef.file\n        ''\n    end\n"
1759
    end
1760

    
1761
    s += "end\n"
1762
    File.open(basename + '.rb', 'w') { |file| file.write(s)}
1763
    puts "Font definition file generated (#{basename}.rb)"
1764
end
1765

    
1766

    
1767
if $0 == __FILE__ then
1768
    if ARGV.length >= 3 then
1769
        enc = ARGV[2]
1770
    else
1771
        enc = 'cp1252'
1772
    end
1773

    
1774
    if ARGV.length >= 4 then
1775
        patch = ARGV[3]
1776
    else
1777
        patch = {}
1778
    end
1779

    
1780
    if ARGV.length >= 5 then
1781
        type = ARGV[4]
1782
    else
1783
        type = 'TrueType'
1784
    end
1785

    
1786
    MakeFont(ARGV[0], ARGV[1], enc, patch, type)
1787
end