Debian Codegraph @

texk/ttf2pk2/ttfenc.c

raw
1 /*
2 * ttfenc.c
3 *
4 * This file is part of the ttf2pk package.
5 *
6 * Copyright 1997-1999, 2000 by
7 * Frederic Loyer <[email protected]>
8 * Werner Lemberg <[email protected]>
9 */
10
11
12 #ifdef HAVE_CONFIG_H
13 #include <config.h>
14 #endif
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19
20 #include "newobj.h"
21 #include "ttf2tfm.h"
22 #include "ttfenc.h"
23 #include "errormsg.h"
24
25 EncodingScheme current_encoding_scheme;
26
27 struct encoding_table
28 {
29 long code;
30 const char *adobename;
31 };
32
33 struct encoding_table unicode_table[] =
34 {
35 {-1, ".notdef"},
36
37 {0x0020, "space"},
38 {0x0021, "exclam"},
39 {0x0022, "quotedbl"},
40 {0x0023, "numbersign"},
41 {0x0024, "dollar"},
42 {0x0025, "percent"},
43 {0x0026, "ampersand"},
44 {0x0027, "quotesingle"},
45 {0x0028, "parenleft"},
46 {0x0029, "parenright"},
47 {0x002a, "asterisk"},
48 {0x002b, "plus"},
49 {0x002c, "comma"},
50 {0x002d, "hyphen"}, /* cf "minus" */
51 {0x002e, "period"},
52 {0x002f, "slash"},
53
54 {0x0030, "zero"},
55 {0x0031, "one"},
56 {0x0032, "two"},
57 {0x0033, "three"},
58 {0x0034, "four"},
59 {0x0035, "five"},
60 {0x0036, "six"},
61 {0x0037, "seven"},
62 {0x0038, "eight"},
63 {0x0039, "nine"},
64 {0x003a, "colon"},
65 {0x003b, "semicolon"},
66 {0x003c, "less"},
67 {0x003d, "equal"},
68 {0x003e, "greater"},
69 {0x003f, "question"},
70
71 {0x0040, "at"},
72 {0x0041, "A"},
73 {0x0042, "B"},
74 {0x0043, "C"},
75 {0x0044, "D"},
76 {0x0045, "E"},
77 {0x0046, "F"},
78 {0x0047, "G"},
79 {0x0048, "H"},
80 {0x0049, "I"},
81 {0x004a, "J"},
82 {0x004b, "K"},
83 {0x004c, "L"},
84 {0x004d, "M"},
85 {0x004e, "N"},
86 {0x004f, "O"},
87
88 {0x0050, "P"},
89 {0x0051, "Q"},
90 {0x0052, "R"},
91 {0x0053, "S"},
92 {0x0054, "T"},
93 {0x0055, "U"},
94 {0x0056, "V"},
95 {0x0057, "W"},
96 {0x0058, "X"},
97 {0x0059, "Y"},
98 {0x005a, "Z"},
99 {0x005b, "bracketleft"},
100 {0x005c, "backslash"},
101 {0x005d, "bracketright"},
102 {0x005e, "asciicircum"},
103 {0x005f, "underscore"},
104
105 {0x0060, "grave"},
106 {0x0061, "a"},
107 {0x0062, "b"},
108 {0x0063, "c"},
109 {0x0064, "d"},
110 {0x0065, "e"},
111 {0x0066, "f"},
112 {0x0067, "g"},
113 {0x0068, "h"},
114 {0x0069, "i"},
115 {0x006a, "j"},
116 {0x006b, "k"},
117 {0x006c, "l"},
118 {0x006d, "m"},
119 {0x006e, "n"},
120 {0x006f, "o"},
121
122 {0x0070, "p"},
123 {0x0071, "q"},
124 {0x0072, "r"},
125 {0x0073, "s"},
126 {0x0074, "t"},
127 {0x0075, "u"},
128 {0x0076, "v"},
129 {0x0077, "w"},
130 {0x0078, "x"},
131 {0x0079, "y"},
132 {0x007a, "z"},
133 {0x007b, "braceleft"},
134 {0x007c, "bar"},
135 {0x007d, "braceright"},
136 {0x007e, "asciitilde"},
137
138 {0x00a0, "nbspace"}, /* cf "space" */
139 {0x00a1, "exclamdown"},
140 {0x00a2, "cent"},
141 {0x00a3, "sterling"},
142 {0x00a4, "currency"},
143 {0x00a5, "yen"},
144 {0x00a6, "brokenbar"},
145 {0x00a7, "section"},
146 {0x00a8, "dieresis"},
147 {0x00a9, "copyright"}, /* "copyrightserif" "copyrightsans" */
148 {0x00aa, "ordfeminine"},
149 {0x00ab, "guillemotleft"},
150 {0x00ac, "logicalnot"},
151 {0x00ad, "sfthyphen"}, /* cf "hyphen" */
152 {0x00ae, "registered"}, /* "registeredserif" "registeredsans" */
153 {0x00af, "overscore"},
154
155 {0x00b0, "degree"},
156 {0x00b1, "plusminus"},
157 {0x00b2, "twosuperior"},
158 {0x00b3, "threesuperior"},
159 {0x00b4, "acute"},
160 {0x00b5, "mu1"}, /* "micro" */
161 {0x00b6, "paragraph"},
162 {0x00b7, "middot"}, /* cf "periodcentered" */
163 {0x00b8, "cedilla"},
164 {0x00b9, "onesuperior"},
165 {0x00ba, "ordmasculine"},
166 {0x00bb, "guillemotright"},
167 {0x00bc, "onequarter"},
168 {0x00bd, "onehalf"},
169 {0x00be, "threequarters"},
170 {0x00bf, "questiondown"},
171
172 {0x00c0, "Agrave"},
173 {0x00c1, "Aacute"},
174 {0x00c2, "Acircumflex"},
175 {0x00c3, "Atilde"},
176 {0x00c4, "Adieresis"},
177 {0x00c5, "Aring"},
178 {0x00c6, "AE"},
179 {0x00c7, "Ccedilla"},
180 {0x00c8, "Egrave"},
181 {0x00c9, "Eacute"},
182 {0x00ca, "Ecircumflex"},
183 {0x00cb, "Edieresis"},
184 {0x00cc, "Igrave"},
185 {0x00cd, "Iacute"},
186 {0x00ce, "Icircumflex"},
187 {0x00cf, "Idieresis"},
188
189 {0x00d0, "Eth"},
190 {0x00d1, "Ntilde"},
191 {0x00d2, "Ograve"},
192 {0x00d3, "Oacute"},
193 {0x00d4, "Ocircumflex"},
194 {0x00d5, "Otilde"},
195 {0x00d6, "Odieresis"},
196 {0x00d7, "multiply"},
197 {0x00d8, "Oslash"},
198 {0x00d9, "Ugrave"},
199 {0x00da, "Uacute"},
200 {0x00db, "Ucircumflex"},
201 {0x00dc, "Udieresis"},
202 {0x00dd, "Yacute"},
203 {0x00de, "Thorn"},
204 {0x00df, "germandbls"},
205
206 {0x00e0, "agrave"},
207 {0x00e1, "aacute"},
208 {0x00e2, "acircumflex"},
209 {0x00e3, "atilde"},
210 {0x00e4, "adieresis"},
211 {0x00e5, "aring"},
212 {0x00e6, "ae"},
213 {0x00e7, "ccedilla"},
214 {0x00e8, "egrave"},
215 {0x00e9, "eacute"},
216 {0x00ea, "ecircumflex"},
217 {0x00eb, "edieresis"},
218 {0x00ec, "igrave"},
219 {0x00ed, "iacute"},
220 {0x00ee, "icircumflex"},
221 {0x00ef, "idieresis"},
222
223 {0x00f0, "eth"},
224 {0x00f1, "ntilde"},
225 {0x00f2, "ograve"},
226 {0x00f3, "oacute"},
227 {0x00f4, "ocircumflex"},
228 {0x00f5, "otilde"},
229 {0x00f6, "odieresis"},
230 {0x00f7, "divide"},
231 {0x00f8, "oslash"},
232 {0x00f9, "ugrave"},
233 {0x00fa, "uacute"},
234 {0x00fb, "ucircumflex"},
235 {0x00fc, "udieresis"},
236 {0x00fd, "yacute"},
237 {0x00fe, "thorn"},
238 {0x00ff, "ydieresis"},
239
240 {0x0100, "Amacron"},
241 {0x0101, "amacron"},
242 {0x0102, "Abreve"},
243 {0x0103, "abreve"},
244 {0x0104, "Aogonek"},
245 {0x0105, "aogonek"},
246 {0x0106, "Cacute"},
247 {0x0107, "cacute"},
248 {0x0108, "Ccircumflex"},
249 {0x0109, "ccircumflex"},
250 {0x010a, "Cdot"},
251 {0x010b, "cdot"},
252 {0x010c, "Ccaron"},
253 {0x010d, "ccaron"},
254 {0x010e, "Dcaron"},
255 {0x010f, "dcaron"},
256
257 {0x0110, "Dslash"},
258 {0x0111, "dmacron"},
259 {0x0112, "Emacron"},
260 {0x0113, "emacron"},
261 {0x0114, "Ebreve"},
262 {0x0115, "ebreve"},
263 {0x0116, "Edot"},
264 {0x0117, "edot"},
265 {0x0118, "Eogonek"},
266 {0x0119, "eogonek"},
267 {0x011a, "Ecaron"},
268 {0x011b, "ecaron"},
269 {0x011c, "Gcircumflex"},
270 {0x011d, "gcircumflex"},
271 {0x011e, "Gbreve"},
272 {0x011f, "gbreve"},
273
274 {0x0120, "Gdot"},
275 {0x0121, "gdot"},
276 {0x0122, "Gcedilla"},
277 {0x0123, "gcedilla"},
278 {0x0124, "Hcircumflex"},
279 {0x0125, "hcircumflex"},
280 {0x0126, "Hbar"},
281 {0x0127, "hbar"},
282 {0x0128, "Itilde"},
283 {0x0129, "itilde"},
284 {0x012a, "Imacron"},
285 {0x012b, "imacron"},
286 {0x012c, "Ibreve"},
287 {0x012d, "ibreve"},
288 {0x012e, "Iogonek"},
289 {0x012f, "iogonek"},
290
291 {0x0130, "Idot"},
292 {0x0131, "dotlessi"},
293 {0x0132, "IJ"},
294 {0x0133, "ij"},
295 {0x0134, "Jcircumflex"},
296 {0x0135, "jcircumflex"},
297 {0x0136, "Kcedilla"},
298 {0x0137, "kcedilla"},
299 {0x0138, "kgreenlandic"},
300 {0x0139, "Lacute"},
301 {0x013a, "lacute"},
302 {0x013b, "Lcedilla"},
303 {0x013c, "lcedilla"},
304 {0x013d, "Lcaron"},
305 {0x013e, "lcaron"},
306 {0x013f, "Ldot"},
307
308 {0x0140, "ldot"},
309 {0x0141, "Lslash"},
310 {0x0142, "lslash"},
311 {0x0143, "Nacute"},
312 {0x0144, "nacute"},
313 {0x0145, "Ncedilla"},
314 {0x0146, "ncedilla"},
315 {0x0147, "Ncaron"},
316 {0x0148, "ncaron"},
317 {0x0149, "napostrophe"},
318 {0x014a, "Eng"},
319 {0x014b, "eng"},
320 {0x014c, "Omacron"},
321 {0x014d, "omacron"},
322 {0x014e, "Obreve"},
323 {0x014f, "obreve"},
324
325 {0x0150, "Odblacute"},
326 {0x0151, "odblacute"},
327 {0x0152, "OE"},
328 {0x0153, "oe"},
329 {0x0154, "Racute"},
330 {0x0155, "racute"},
331 {0x0156, "Rcedilla"},
332 {0x0157, "rcedilla"},
333 {0x0158, "Rcaron"},
334 {0x0159, "rcaron"},
335 {0x015a, "Sacute"},
336 {0x015b, "sacute"},
337 {0x015c, "Scircumflex"},
338 {0x015d, "scircumflex"},
339 {0x015e, "Scedilla"},
340 {0x015f, "scedilla"},
341
342 {0x0160, "Scaron"},
343 {0x0161, "scaron"},
344 {0x0162, "Tcedilla"},
345 {0x0163, "tcedilla"},
346 {0x0164, "Tcaron"},
347 {0x0165, "tcaron"},
348 {0x0166, "Tbar"},
349 {0x0167, "tbar"},
350 {0x0168, "Utilde"},
351 {0x0169, "utilde"},
352 {0x016a, "Umacron"},
353 {0x016b, "umacron"},
354 {0x016c, "Ubreve"},
355 {0x016d, "ubreve"},
356 {0x016e, "Uring"},
357 {0x016f, "uring"},
358
359 {0x0170, "Udblacute"},
360 {0x0171, "udblacute"},
361 {0x0172, "Uogonek"},
362 {0x0173, "uogonek"},
363 {0x0174, "Wcircumflex"},
364 {0x0175, "wcircumflex"},
365 {0x0176, "Ycircumflex"},
366 {0x0177, "ycircumflex"},
367 {0x0178, "Ydieresis"},
368 {0x0179, "Zacute"},
369 {0x017a, "zacute"},
370 {0x017b, "Zdot"},
371 {0x017c, "zdot"},
372 {0x017d, "Zcaron"},
373 {0x017e, "zcaron"},
374 {0x017f, "longs"},
375
376 {0x0192, "florin"},
377
378 {0x01fa, "Aringacute"},
379 {0x01fb, "aringacute"},
380 {0x01fc, "AEacute"},
381 {0x01fd, "aeacute"},
382 {0x01fe, "Oslashacute"},
383 {0x01ff, "oslashacute"},
384
385 {0x02c6, "circumflex"},
386 {0x02c7, "caron"},
387 {0x02c9, "macron"}, /* cf "overscore" */
388
389 {0x02d8, "breve"},
390 {0x02d9, "dotaccent"},
391 {0x02da, "ring"},
392 {0x02db, "ogonek"},
393 {0x02dc, "tilde"},
394 {0x02dd, "hungarumlaut"},
395
396 {0x037e, "semicolon"},
397
398 {0x0384, "tonos"},
399 {0x0385, "dieresistonos"},
400 {0x0386, "Alphatonos"},
401 {0x0387, "anoteleia"},
402 {0x0388, "Epsilontonos"},
403 {0x0389, "Etatonos"},
404 {0x038a, "Iotatonos"},
405 {0x038c, "Omicrontonos"},
406 {0x038e, "Upsilontonos"},
407 {0x038f, "Omegatonos"},
408
409 {0x0390, "iotadieresistonos"},
410 {0x0391, "Alpha"},
411 {0x0392, "Beta"},
412 {0x0393, "Gamma"},
413 {0x0394, "Delta"},
414 {0x0395, "Epsilon"},
415 {0x0396, "Zeta"},
416 {0x0397, "Eta"},
417 {0x0398, "Theta"},
418 {0x0399, "Iota"},
419 {0x039a, "Kappa"},
420 {0x039b, "Lambda"},
421 {0x039c, "Mu"},
422 {0x039d, "Nu"},
423 {0x039e, "Xi"},
424 {0x039f, "Omicron"},
425
426 {0x03a0, "Pi"},
427 {0x03a1, "Rho"},
428 {0x03a2, "Sigma"},
429 {0x03a3, "Tau"},
430 {0x03a4, "Upsilon"},
431 {0x03a5, "Phi"},
432 {0x03a6, "Chi"},
433 {0x03a7, "Psi"},
434 {0x03a8, "Omega"}, /* cf "Ohm" */
435 {0x03aa, "Iotadieresis"},
436 {0x03ab, "Upsilondieresis"},
437 {0x03ac, "alphatonos"},
438 {0x03ad, "epsilontonos"},
439 {0x03ae, "etatonos"},
440 {0x03af, "iotatonos"},
441
442 {0x03b0, "upsilondieresistonos"},
443 {0x03b1, "alpha"},
444 {0x03b2, "beta"},
445 {0x03b3, "gamma"},
446 {0x03b4, "delta"},
447 {0x03b5, "epsilon"},
448 {0x03b6, "zeta"},
449 {0x03b7, "eta"},
450 {0x03b8, "theta"},
451 {0x03b9, "iota"},
452 {0x03ba, "kappa"},
453 {0x03bb, "lambda"},
454 {0x03bc, "mu"},
455 {0x03bd, "nu"},
456 {0x03be, "xi"},
457 {0x03bf, "omicron"},
458
459 {0x03c0, "pi"},
460 {0x03c1, "rho"},
461 {0x03c2, "sigma1"},
462 {0x03c3, "sigma"},
463 {0x03c4, "tau"},
464 {0x03c5, "upsilon"},
465 {0x03c6, "phi"},
466 {0x03c7, "chi"},
467 {0x03c8, "psi"},
468 {0x03c9, "omega"},
469 {0x03ca, "iotadieresis"},
470 {0x03cb, "upsilondieresis"},
471 {0x03cc, "omicrontonos"},
472 {0x03cd, "upsilontonos"},
473 {0x03ce, "omegatonos"},
474
475 {0x0401, "afii10023"},
476 {0x0402, "afii10051"},
477 {0x0403, "afii10052"},
478 {0x0404, "afii10053"},
479 {0x0405, "afii10054"},
480 {0x0406, "afii10055"},
481 {0x0407, "afii10056"},
482 {0x0408, "afii10057"},
483 {0x0409, "afii10058"},
484 {0x040a, "afii10059"},
485 {0x040b, "afii10060"},
486 {0x040c, "afii10061"},
487 {0x040e, "afii10062"},
488 {0x040f, "afii10145"},
489
490 {0x0410, "afii10017"},
491 {0x0411, "afii10018"},
492 {0x0412, "afii10019"},
493 {0x0413, "afii10020"},
494 {0x0414, "afii10021"},
495 {0x0415, "afii10022"},
496 {0x0416, "afii10024"},
497 {0x0417, "afii10025"},
498 {0x0418, "afii10026"},
499 {0x0419, "afii10027"},
500 {0x041a, "afii10028"},
501 {0x041b, "afii10029"},
502 {0x041c, "afii10030"},
503 {0x041d, "afii10031"},
504 {0x041e, "afii10032"},
505 {0x041f, "afii10033"},
506
507 {0x0420, "afii10034"},
508 {0x0421, "afii10035"},
509 {0x0422, "afii10036"},
510 {0x0423, "afii10037"},
511 {0x0424, "afii10038"},
512 {0x0425, "afii10039"},
513 {0x0426, "afii10040"},
514 {0x0427, "afii10041"},
515 {0x0428, "afii10042"},
516 {0x0429, "afii10043"},
517 {0x042a, "afii10044"},
518 {0x042b, "afii10045"},
519 {0x042c, "afii10046"},
520 {0x042d, "afii10047"},
521 {0x042e, "afii10048"},
522 {0x042f, "afii10049"},
523
524 {0x0430, "afii10065"},
525 {0x0431, "afii10066"},
526 {0x0432, "afii10067"},
527 {0x0433, "afii10068"},
528 {0x0434, "afii10069"},
529 {0x0435, "afii10070"},
530 {0x0436, "afii10072"},
531 {0x0437, "afii10073"},
532 {0x0438, "afii10074"},
533 {0x0439, "afii10075"},
534 {0x043a, "afii10076"},
535 {0x043b, "afii10077"},
536 {0x043c, "afii10078"},
537 {0x043d, "afii10079"},
538 {0x043e, "afii10080"},
539 {0x043f, "afii10081"},
540
541 {0x0440, "afii10082"},
542 {0x0441, "afii10083"},
543 {0x0442, "afii10084"},
544 {0x0443, "afii10085"},
545 {0x0444, "afii10086"},
546 {0x0445, "afii10087"},
547 {0x0446, "afii10088"},
548 {0x0447, "afii10089"},
549 {0x0448, "afii10090"},
550 {0x0449, "afii10091"},
551 {0x044a, "afii10092"},
552 {0x044b, "afii10093"},
553 {0x044c, "afii10094"},
554 {0x044d, "afii10095"},
555 {0x044e, "afii10096"},
556 {0x044f, "afii10097"},
557
558 {0x0451, "afii10071"},
559 {0x0452, "afii10099"},
560 {0x0453, "afii10100"},
561 {0x0454, "afii10101"},
562 {0x0455, "afii10102"},
563 {0x0456, "afii10103"},
564 {0x0457, "afii10104"},
565 {0x0458, "afii10105"},
566 {0x0459, "afii10106"},
567 {0x045a, "afii10107"},
568 {0x045b, "afii10108"},
569 {0x045c, "afii10109"},
570 {0x045e, "afii10110"},
571 {0x045f, "afii10193"},
572
573 {0x0490, "afii10050"},
574 {0x0491, "afii10098"},
575
576 {0x1e80, "Wgrave"},
577 {0x1e81, "wgrave"},
578 {0x1e82, "Wacute"},
579 {0x1e83, "wacute"},
580 {0x1e84, "Wdieresis"},
581 {0x1e85, "wdieresis"},
582
583 {0x1ef2, "Ygrave"},
584 {0x1ef3, "ygrave"},
585
586 {0x2013, "endash"},
587 {0x2014, "emdash"},
588 {0x2015, "afii00208"}, /* horizontal bar */
589 {0x2017, "underscoredbl"},
590 {0x2018, "quoteleft"},
591 {0x2019, "quoteright"},
592 {0x201a, "quotesinglbase"},
593 {0x201b, "quotereversed"},
594 {0x201c, "quotedblleft"},
595 {0x201d, "quotedblright"},
596 {0x201e, "quotedblbase"},
597
598 {0x2020, "dagger"},
599 {0x2021, "daggerdbl"},
600 {0x2022, "bullet"},
601 {0x2026, "ellipsis"},
602 {0x2030, "perthousand"},
603 {0x2032, "minute"},
604 {0x2033, "second"},
605 {0x2039, "guilsinglleft"},
606 {0x203a, "guilsinglright"},
607 {0x203c, "exclamdbl"},
608 {0x203e, "radicalex"},
609
610 {0x2044, "fraction"}, /* cf U+2215 */
611
612 {0x207f, "nsuperior"},
613
614 {0x20a3, "franc"},
615 {0x20a4, "afii08941"}, /* lira sign */
616 {0x20a7, "peseta"},
617
618 {0x2105, "afii61248"}, /* care of */
619
620 {0x2113, "afii61289"}, /* script small l */
621 {0x2116, "afii61352"}, /* numero sign */
622
623 {0x2122, "trademark"},
624 {0x2126, "Ohm"},
625 {0x212e, "estimated"},
626
627 {0x215b, "oneeighth"},
628 {0x215c, "threeeighths"},
629 {0x215d, "fiveeighths"},
630 {0x215e, "seveneighths"},
631
632 {0x2190, "arrowleft"},
633 {0x2191, "arrowup"},
634 {0x2192, "arrowright"},
635 {0x2193, "arrowdown"},
636 {0x2194, "arrowboth"},
637 {0x2195, "arrowupdn"},
638
639 {0x21a8, "arrowupdnbse"},
640
641 {0x2202, "partialdiff"},
642 {0x2206, "increment"},
643 {0x220f, "product"},
644
645 {0x2211, "summation"},
646 {0x2212, "minus"},
647 {0x2215, "fraction"}, /* cf U+2044 */
648 {0x2219, "periodcentered"},
649 {0x221a, "radical"},
650 {0x221e, "infinity"},
651 {0x221f, "orthogonal"},
652
653 {0x2229, "intersection"},
654 {0x222b, "integral"},
655
656 {0x2248, "approxequal"},
657
658 {0x2260, "notequal"},
659 {0x2261, "equivalence"},
660 {0x2264, "lessequal"},
661 {0x2265, "greaterequal"},
662
663 {0x2302, "house"},
664
665 {0x2310, "revlogicalnot"},
666
667 {0x2320, "integraltp"},
668 {0x2321, "integralbt"},
669
670 {0x2500, "SF100000"},
671 {0x2502, "SF110000"},
672 {0x250c, "SF010000"},
673
674 {0x2510, "SF030000"},
675 {0x2514, "SF020000"},
676 {0x2518, "SF040000"},
677 {0x251c, "SF080000"},
678
679 {0x2524, "SF090000"},
680 {0x252c, "SF060000"},
681
682 {0x2534, "SF070000"},
683 {0x253c, "SF050000"},
684
685 {0x2550, "SF430000"},
686 {0x2551, "SF240000"},
687 {0x2552, "SF510000"},
688 {0x2553, "SF520000"},
689 {0x2554, "SF390000"},
690 {0x2555, "SF220000"},
691 {0x2556, "SF210000"},
692 {0x2557, "SF250000"},
693 {0x2558, "SF500000"},
694 {0x2559, "SF490000"},
695 {0x255a, "SF380000"},
696 {0x255b, "SF280000"},
697 {0x255c, "SF270000"},
698 {0x255d, "SF260000"},
699 {0x255e, "SF360000"},
700 {0x255f, "SF370000"},
701
702 {0x2560, "SF420000"},
703 {0x2561, "SF190000"},
704 {0x2562, "SF200000"},
705 {0x2563, "SF230000"},
706 {0x2564, "SF470000"},
707 {0x2565, "SF480000"},
708 {0x2566, "SF410000"},
709 {0x2567, "SF450000"},
710 {0x2568, "SF460000"},
711 {0x2569, "SF400000"},
712 {0x256a, "SF540000"},
713 {0x256b, "SF530000"},
714 {0x256c, "SF440000"},
715
716 {0x2580, "upblock"},
717 {0x2584, "dnblock"},
718 {0x2588, "block"},
719 {0x258c, "lfblock"},
720
721 {0x2590, "rtblock"},
722 {0x2591, "ltshade"},
723 {0x2592, "shade"},
724 {0x2593, "dkshade"},
725
726 {0x25a0, "filledbox"},
727 {0x25a1, "H22073"},
728 {0x25aa, "H18543"},
729 {0x25ab, "H18551"},
730 {0x25ac, "filledrect"},
731
732 {0x25b2, "triagup"},
733 {0x25ba, "triagrt"},
734 {0x25bc, "triagdn"},
735
736 {0x25c4, "triaglf"},
737 {0x25ca, "lozenge"},
738 {0x25cb, "circle"},
739 {0x25cf, "H18533"},
740
741 {0x25d8, "invbullet"},
742 {0x25d9, "invcircle"},
743
744 {0x25e6, "openbullet"},
745
746 {0x263a, "smileface"},
747 {0x263b, "invsmileface"},
748 {0x263c, "sun"},
749
750 {0x2640, "female"},
751 {0x2642, "male"},
752
753 {0x2660, "spade"},
754 {0x2663, "club"},
755 {0x2665, "heart"},
756 {0x2666, "diamond"},
757 {0x266a, "musicalnote"},
758 {0x266b, "musicalnotedbl"},
759
760 {0xf000, "applelogo"},
761 {0xf001, "fi"},
762 {0xf002, "fl"},
763 {0xf004, "commaaccent"},
764 {0xf005, "undercommaaccent"},
765 {0xfb01, "fi"},
766 {0xfb02, "fl"},
767 };
768
769 struct encoding_table mac_table[] =
770 {
771 {-1, ".notdef"},
772 {0x0000, ".notdef"}, /* null */
773 {0x0008, ".notdef"}, /* backspace */
774 {0x0009, ".notdef"}, /* horizontal tabulation */
775 {0x000d, ".notdef"}, /* carriage return */
776 {0x001d, ".notdef"}, /* group separator */
777 {0x0020, "space"},
778 {0x0021, "exclam"},
779 {0x0022, "quotedbl"},
780 {0x0023, "numbersign"},
781 {0x0024, "dollar"},
782 {0x0025, "percent"},
783 {0x0026, "ampersand"},
784 {0x0027, "quotesingle"},
785 {0x0028, "parenleft"},
786 {0x0029, "parenright"},
787 {0x002a, "asterisk"},
788 {0x002b, "plus"},
789 {0x002c, "comma"},
790 {0x002d, "hyphen"},
791 {0x002e, "period"},
792 {0x002f, "slash"},
793
794 {0x0030, "zero"},
795 {0x0031, "one"},
796 {0x0032, "two"},
797 {0x0033, "three"},
798 {0x0034, "four"},
799 {0x0035, "five"},
800 {0x0036, "six"},
801 {0x0037, "seven"},
802 {0x0038, "eight"},
803 {0x0039, "nine"},
804 {0x003a, "colon"},
805 {0x003b, "semicolon"},
806 {0x003c, "less"},
807 {0x003d, "equal"},
808 {0x003e, "greater"},
809 {0x003f, "question"},
810
811 {0x0040, "at"},
812 {0x0041, "A"},
813 {0x0042, "B"},
814 {0x0043, "C"},
815 {0x0044, "D"},
816 {0x0045, "E"},
817 {0x0046, "F"},
818 {0x0047, "G"},
819 {0x0048, "H"},
820 {0x0049, "I"},
821 {0x004a, "J"},
822 {0x004b, "K"},
823 {0x004c, "L"},
824 {0x004d, "M"},
825 {0x004e, "N"},
826 {0x004f, "O"},
827
828 {0x0050, "P"},
829 {0x0051, "Q"},
830 {0x0052, "R"},
831 {0x0053, "S"},
832 {0x0054, "T"},
833 {0x0055, "U"},
834 {0x0056, "V"},
835 {0x0057, "W"},
836 {0x0058, "X"},
837 {0x0059, "Y"},
838 {0x005a, "Z"},
839 {0x005b, "bracketleft"},
840 {0x005c, "backslash"},
841 {0x005d, "bracketright"},
842 {0x005e, "asciicircum"},
843 {0x005f, "underscore"},
844
845 {0x0060, "grave"},
846 {0x0061, "a"},
847 {0x0062, "b"},
848 {0x0063, "c"},
849 {0x0064, "d"},
850 {0x0065, "e"},
851 {0x0066, "f"},
852 {0x0067, "g"},
853 {0x0068, "h"},
854 {0x0069, "i"},
855 {0x006a, "j"},
856 {0x006b, "k"},
857 {0x006c, "l"},
858 {0x006d, "m"},
859 {0x006e, "n"},
860 {0x006f, "o"},
861
862 {0x0070, "p"},
863 {0x0071, "q"},
864 {0x0072, "r"},
865 {0x0073, "s"},
866 {0x0074, "t"},
867 {0x0075, "u"},
868 {0x0076, "v"},
869 {0x0077, "w"},
870 {0x0078, "x"},
871 {0x0079, "y"},
872 {0x007a, "z"},
873 {0x007b, "braceleft"},
874 {0x007c, "bar"},
875 {0x007d, "braceright"},
876 {0x007e, "asciitilde"},
877
878 {0x0080, "Adieresis"},
879 {0x0081, "Aring"},
880 {0x0082, "Ccedilla"},
881 {0x0083, "Eacute"},
882 {0x0084, "Ntilde"},
883 {0x0085, "Odieresis"},
884 {0x0086, "Udieresis"},
885 {0x0087, "aacute"},
886 {0x0088, "agrave"},
887 {0x0089, "acircumflex"},
888 {0x008a, "adieresis"},
889 {0x008b, "atilde"},
890 {0x008c, "aring"},
891 {0x008d, "ccedilla"},
892 {0x008e, "eacute"},
893 {0x008f, "egrave"},
894
895 {0x0090, "ecircumflex"},
896 {0x0091, "edieresis"},
897 {0x0092, "iacute"},
898 {0x0093, "igrave"},
899 {0x0094, "icircumflex"},
900 {0x0095, "idieresis"},
901 {0x0096, "ntilde"},
902 {0x0097, "oacute"},
903 {0x0098, "ograve"},
904 {0x0099, "ocircumflex"},
905 {0x009a, "odieresis"},
906 {0x009b, "otilde"},
907 {0x009c, "uacute"},
908 {0x009d, "ugrave"},
909 {0x009e, "ucircumflex"},
910 {0x009f, "udieresis"},
911
912 {0x00a0, "dagger"},
913 {0x00a1, "degree"},
914 {0x00a2, "cent"},
915 {0x00a3, "sterling"},
916 {0x00a4, "section"},
917 {0x00a5, "bullet"},
918 {0x00a6, "paragraph"},
919 {0x00a7, "germandbls"},
920 {0x00a8, "registered"},
921 {0x00a9, "copyright"},
922 {0x00aa, "trademark"},
923 {0x00ab, "acute"},
924 {0x00ac, "dieresis"},
925 {0x00ad, "notequal"},
926 {0x00ae, "AE"},
927 {0x00af, "Oslash"},
928
929 {0x00b0, "infinity"},
930 {0x00b1, "plusminus"},
931 {0x00b2, "lessequal"},
932 {0x00b3, "greaterequal"},
933 {0x00b4, "yen"},
934 {0x00b5, "mu"},
935 {0x00b6, "partialdiff"},
936 {0x00b7, "summation"},
937 {0x00b8, "product"},
938 {0x00b9, "pi"},
939 {0x00ba, "integral"},
940 {0x00bb, "ordfeminine"},
941 {0x00bc, "ordmasculine"},
942 {0x00bd, "Omega"},
943 {0x00be, "ae"},
944 {0x00bf, "oslash"},
945
946 {0x00c0, "questiondown"},
947 {0x00c1, "exclamdown"},
948 {0x00c2, "logicalnot"},
949 {0x00c3, "radical"},
950 {0x00c4, "florin"},
951 {0x00c5, "approxequal"},
952 {0x00c6, "Delta"},
953 {0x00c7, "guillemotleft"},
954 {0x00c8, "guillemotright"},
955 {0x00c9, "ellipsis"},
956 {0x00ca, "nbspace"},
957 {0x00cb, "Agrave"},
958 {0x00cc, "Atilde"},
959 {0x00cd, "Otilde"},
960 {0x00ce, "OE"},
961 {0x00cf, "oe"},
962
963 {0x00d0, "endash"},
964 {0x00d1, "emdash"},
965 {0x00d2, "quotedblleft"},
966 {0x00d3, "quotedblright"},
967 {0x00d4, "quoteleft"},
968 {0x00d5, "quoteright"},
969 {0x00d6, "divide"},
970 {0x00d7, "lozenge"},
971 {0x00d8, "ydieresis"},
972 {0x00d9, "Ydieresis"},
973 {0x00da, "fraction"},
974 {0x00db, "currency"},
975 {0x00dc, "guilsinglleft"},
976 {0x00dd, "guilsinglright"},
977 {0x00de, "fi"},
978 {0x00df, "fl"},
979
980 {0x00e0, "daggerdbl"},
981 {0x00e1, "periodcentered"},
982 {0x00e2, "quotesinglbase"},
983 {0x00e3, "quotedblbase"},
984 {0x00e4, "perthousand"},
985 {0x00e5, "Acircumflex"},
986 {0x00e6, "Ecircumflex"},
987 {0x00e7, "Aacute"},
988 {0x00e8, "Edieresis"},
989 {0x00e9, "Egrave"},
990 {0x00ea, "Iacute"},
991 {0x00eb, "Icircumflex"},
992 {0x00ec, "Idieresis"},
993 {0x00ed, "Igrave"},
994 {0x00ee, "Oacute"},
995 {0x00ef, "Ocircumflex"},
996
997 {0x00f0, "apple"},
998 {0x00f1, "Ograve"},
999 {0x00f2, "Uacute"},
1000 {0x00f3, "Ucircumflex"},
1001 {0x00f4, "Ugrave"},
1002 {0x00f5, "dotlessi"},
1003 {0x00f6, "circumflex"},
1004 {0x00f7, "tilde"},
1005 {0x00f8, "macron"},
1006 {0x00f9, "breve"},
1007 {0x00fa, "dotaccent"},
1008 {0x00fb, "ring"},
1009 {0x00fc, "cedilla"},
1010 {0x00fd, "hungarumlaut"},
1011 {0x00fe, "ogonek"},
1012 {0x00ff, "caron"},
1013 };
1014
1015
1016 struct encoding_table *current_table;
1017 size_t current_table_len;
1018
1019
1020 void
1021 set_encoding_scheme(EncodingScheme e, Font *fnt)
1022 {
1023 current_encoding_scheme = e;
1024
1025 switch (e)
1026 {
1027 case encUnicode:
1028 current_table = unicode_table;
1029 current_table_len = sizeof (unicode_table) / sizeof (unicode_table[0]);
1030 break;
1031
1032 case encMac:
1033 current_table = mac_table;
1034 current_table_len = sizeof (mac_table) / sizeof (mac_table[0]);
1035 break;
1036
1037 case encFontSpecific:
1038 break;
1039 }
1040 }
1041
1042
1043 /*
1044 * We return ".c0x<code point in hexadecimal representation>"
1045 * if no name is found.
1046 *
1047 * We return ".g0x<code point in hexadecimal representation>"
1048 * if it's a glyph index (code >= 0x1000000).
1049 */
1050
1051 const char *
1052 code_to_adobename(long code)
1053 {
1054 unsigned int n, n1 = 0, n2 = current_table_len - 1;
1055 char *p;
1056
1057
1058 if (current_encoding_scheme == encFontSpecific)
1059 {
1060 p = (char *)mymalloc(11);
1061 sprintf(p, ".%c0x%lx", (code >= 0x1000000) ? 'g' : 'c',
1062 (code & 0xFFFFFF));
1063 return p;
1064 }
1065
1066 while (n1 <= n2)
1067 {
1068 n = (n1 + n2) / 2;
1069 if (code < current_table[n].code)
1070 n2 = n - 1;
1071 else if (code > current_table[n].code)
1072 n1 = n + 1;
1073 else
1074 return current_table[n].adobename;
1075 }
1076
1077 p = (char *)mymalloc(11);
1078 sprintf(p, ".%c0x%lx", (code >= 0x1000000) ? 'g' : 'c',
1079 (code & 0xFFFFFF));
1080 return p;
1081 }
1082
1083
1084 /*
1085 * The first of two identical entries will win.
1086 */
1087
1088 long
1089 adobename_to_code(const char *s)
1090 {
1091 size_t i;
1092 long j;
1093 char p;
1094 char *e;
1095
1096
1097 if (s == NULL)
1098 return -1;
1099
1100 if (current_encoding_scheme == encFontSpecific)
1101 {
1102 if (*(s++) != '.')
1103 return -1;
1104
1105 p = *(s++);
1106 if (!(p == 'c' || p == 'g'))
1107 return -1;
1108
1109 j = strtol(s, &e, 0);
1110 if (*e == '\0')
1111 return (p == 'g') ? (j | 0x1000000) : j;
1112 else
1113 return -1;
1114 }
1115
1116 for (i = 0; i < current_table_len; i++)
1117 {
1118 if (strcmp(current_table[i].adobename, s) == 0)
1119 return current_table[i].code;
1120 }
1121
1122 if (*(s++) != '.')
1123 return -1;
1124
1125 p = *(s++);
1126 if (!(p == 'c' || p == 'g'))
1127 return -1;
1128
1129 j = strtol(s, &e, 0);
1130 if (*e == '\0')
1131 return (p == 'g') ? (j | 0x1000000) : j;
1132 else
1133 return -1;
1134 }
1135
1136
1137 ttfinfo *
1138 findglyph(unsigned short g, ttfinfo *p)
1139 {
1140 register ttfinfo *ti;
1141
1142
1143 if (!p)
1144 return NULL;
1145
1146 for (ti = p; ti; ti = ti->next)
1147 if (g == ti->glyphindex)
1148 return ti;
1149
1150 return NULL;
1151 }
1152
1153
1154 ttfinfo *
1155 findadobe(const char *p, ttfinfo *ap)
1156 {
1157 register ttfinfo *ti;
1158 register long l = -1;
1159 register char c = '\0', d = '\0';
1160
1161
1162 if (!p)
1163 return NULL;
1164
1165 if (p[0] == '.' &&
1166 (c = p[1]) && (c == 'c' || c == 'g') &&
1167 (d = p[2]) && '0' <= d && d <= '9')
1168 l = strtol(p + 2, NULL, 0);
1169
1170 for (ti = ap; ti; ti = ti->next)
1171 {
1172 if (l >= 0)
1173 {
1174 if (c == 'c')
1175 {
1176 if (ti->charcode == l)
1177 return ti;
1178 }
1179 else
1180 {
1181 if (ti->glyphindex == l)
1182 return ti;
1183 }
1184 }
1185 else if (strcmp(p, ti->adobename) == 0)
1186 return ti;
1187 }
1188
1189 return NULL;
1190 }
1191
1192
1193 ttfinfo *
1194 findmappedadobe(const char *p, ttfinfo **array)
1195 {
1196 register int i;
1197 register ttfinfo *ti;
1198 register long l = -1;
1199 register char c = '\0', d = '\0';
1200
1201
1202 if (!p)
1203 return NULL;
1204
1205 if (p[0] == '.' &&
1206 (c = p[1]) && (c == 'c' || c == 'g') &&
1207 (d = p[2]) && '0' <= d && d <= '9')
1208 l = strtol(p + 2, NULL, 0);
1209
1210 for (i = 0; i <= 0xFF; i++)
1211 if ((ti = array[i]))
1212 {
1213 if (l >= 0)
1214 {
1215 if (c == 'c')
1216 {
1217 if (ti->charcode == l)
1218 return ti;
1219 }
1220 else
1221 {
1222 if (ti->glyphindex == l)
1223 return ti;
1224 }
1225 }
1226 else if (strcmp(p, ti->adobename) == 0)
1227 return ti;
1228 }
1229
1230 return NULL;
1231 }
1232
1233
1234 void
1235 replace_glyphs(Font *fnt)
1236 {
1237 stringlist *sl, *sl_old;
1238 ttfinfo *ti;
1239
1240
1241 for (sl = fnt->replacements, sl_old = NULL; sl; sl_old = sl, sl = sl->next)
1242 {
1243 if ((ti = findadobe(sl->old_name, fnt->charlist)))
1244 ti->adobename = sl->new_name;
1245 else
1246 {
1247 warning("Glyph name `%s' not found.", sl->old_name);
1248 warning("Replacement glyph name `%s' thus ignored.", sl->new_name);
1249 if (sl_old == NULL)
1250 fnt->replacements = sl->next;
1251 else
1252 sl_old->next = sl->next;
1253 }
1254 }
1255 }
1256
1257
1258 /* the opposite of replace_glyph() */
1259
1260 void
1261 restore_glyph(encoding *enc, Font *fnt)
1262 {
1263 stringlist *sl;
1264 int i;
1265
1266
1267 for (sl = fnt->replacements; sl; sl = sl->next)
1268 {
1269 for (i = 0; i <= 0xFF; i++)
1270 {
1271 if (strcmp(enc->vec[i], sl->new_name) == 0)
1272 {
1273 enc->vec[i] = sl->old_name;
1274 goto success;
1275 }
1276 }
1277 warning("Glyph name `%s' not found in encoding.", sl->new_name);
1278 warning("Replacement for glyph name `%s' thus ignored.", sl->old_name);
1279
1280 success:
1281 ;
1282 }
1283 }
1284
1285
1286 /* end */