1 /* This is a utility for making Links fonts from postscript files and
2  * Ghostscript fonts.
3  */
4 #include <stdio.h>
5 #include <string.h>
6 #include <stdlib.h>
7 
8 /* Here switch on which encoding the Ghostscript font is in. */
9 /* #define LATIN */
10 /* #define CYRILLIC */
11 /* #define HEBREW */
12 /* #define HIRAGANA */
13 /* #define KATAKANA */
14 /* #define DINGBATS */
15 /* #define GREEK */
16 /* #define ARABIC */
17 /* #define ARABIC2 */
18 /* #define GEORGIAN_MKHEDRULI */
19 # define STANDARD_SYMBOL
20 
21 #ifdef STANDARD_SYMBOL /* (s050000l.pfb) */
22 int copy[]={
23 	34,0x2200,
24 	36,0x2203,
25 	39,0x220d,
26 	64,0x2245,
27 	68,0x2206,
28 	92,0x2234,
29 	94,0x22a5,
30 	163,0x2264,
31 	165,0x221e,
32 	164,0x2215,
33 	177,0x00b1,
34 	179,0x2265,
35 	180,0x2062,
36 	181,0x221d,
37 	182,0x2202,
38 	183,0x2981,
39 	184,0x00f7,
40 	185,0x2260,
41 	186,0x2261,
42 	187,0x2248,
43 	188,0x20e8,
44 	189,0x2223,
45 	196,0x2297,
46 	197,0x2295,
47 	198,0x2205,
48 	198,0x2300,
49 	199,0x22c2,
50 	200,0x22c3,
51 	201,0x2283,
52 	202,0x2287,
53 	203,0x2284,
54 	204,0x2282,
55 	205,0x2286,
56 	206,0x220a,
57 	207,0x2209,
58 	208,0x2220,
59 	208,0x299f,
60 	209,0x2207,
61 	210,0x00ae,
62 	211,0x00a9,
63 	212,0x2122,
64 	213,0x220f,
65 	214,0x221a,
66 	215,0x2219,
67 	216,0x00ac,
68 	217,0x2227,
69 	217,0x22c0,
70 	218,0x22c1,
71 	218,0x2228,
72 	219,0x27fa,
73 	220,0x27f8,
74 	221,0x21d1,
75 	222,0x21d2,
76 	223,0x21d3,
77 	225,0x2329,
78 	229,0x2211,
79 	230,0x239b,
80 	231,0x239c,
81 	232,0x239d,
82 	233,0x23a1,
83 	234,0x23a2,
84 	235,0x23a3,
85 	236,0x23a7,
86 	237,0x23a8,
87 	238,0x23a9,
88 	239,0x23aa,
89 	241,0x232a,
90 	241,0x27e9,
91 	242,0x222b,
92 	246,0x239e,
93 	247,0x239f,
94 	248,0x23a0,
95 	249,0x23a4,
96 	250,0x23a5,
97 	251,0x23a6,
98 	252,0x23ab,
99 	253,0x23ac,
100 	254,0x23ad,
101 	242,0x222b
102 };
103 
104 int merge[]={};
105 #endif /* #ifdef STANDARD_SYMBOL */
106 
107 #ifdef GEORGIAN_MKHEDRULI  /* mkhedruli.pfb */
108 int copy[]={
109 	35,0x10d0,
110 	36,0x10d1,
111 	37,0x10d2,
112 	38,0x10d3,
113 	39,0x10d4,
114 	40,0x10d5,
115 	41,0x10d6,
116 	42,0x10f1,
117 	43,0x10d7,
118 	44,0x10d8,
119 	45,0x10d9,
120 	46,0x10da,
121 	47,0x10db,
122 	48,0x10dc,
123 	49,0x10f2,
124 	50,0x10dd,
125 	51,0x10de,
126 	52,0x10df,
127 	53,0x10e0,
128 	54,0x10e1,
129 	55,0x10e2,
130 	56,0x10e3,
131 	57,0x10f3,
132 	58,0x10e4,
133 	59,0x10e5,
134 	60,0x10e6,
135 	61,0x10e7,
136 	62,0x10e8,
137 	63,0x10e9,
138 	64,0x10ea,
139 	65,0x10eb,
140 	66,0x10ec,
141 	67,0x10ed,
142 	68,0x10ee,
143 	69,0x10f4,
144 	70,0x10ef,
145 	71,0x10f0,
146 	72,0x10f5,
147 	73,0x10f6,
148 };
149 
150 int merge[]={};
151 #endif /* #ifdef GEORGIAN_MKHEDRULI */
152 
153 #ifdef ARABIC2	/* irnafnt5.pfb */
154 int copy[]={
155 	48,0x06f0,
156 	49,0x06f1,
157 	50,0x06f2,
158 	51,0x06f3,
159 	52,0x06f4,
160 	53,0x06f5,
161 	54,0x06f6,
162 	55,0x06f7,
163 	56,0x06f8,
164 	57,0x06f9,
165 	76,0x0686,
166 	86,0x0698,
167 	111,0x06af,
168 	125,0x06cc,
169 	158,0x0640,
170 };
171 
172 int merge[]={};
173 #endif
174 
175 #ifdef ARABIC	/* ArabicNaskh.pfb */
176 int copy[]={
177 	37,0x066a,
178 	44,0x060c,
179 	48,0x0660,
180 	49,0x0661,
181 	50,0x0662,
182 	51,0x0663,
183 	52,0x0664,
184 	53,0x0665,
185 	54,0x0666,
186 	55,0x0667,
187 	56,0x0668,
188 	57,0x0669,
189 	59,0x061b,
190 	63,0x061f,
191 	64,0x0604,
192 	65,0x0627,
193 	67,0x0623,
194 	69,0x0622,
195 	71,0x0625,
196 	76,0x0628,
197 	80,0x062a,
198 	84,0x062b,
199 	88,0x062c,
200 	94,0x066c,
201 	95,0x0671,
202 	96,0x062d,
203 	100,0x062e,
204 	101,0x062f,
205 	103,0x0630,
206 	105,0x0631,
207 	107,0x0632,
208 	112,0x0633,
209 	116,0x0634,
210 	120,0x0635,
211 	123,0x0670,
212 	126,0x0636,
213 	162,0x0637,
214 	166,0x0638,
215 	167,0x0621,
216 	167,0x06f6,
217 	170,0x0639,
218 	174,0x063a,
219 	178,0x0641,
220 	182,0x0642,
221 	183,0x06a9,
222 	186,0x0643,
223 	190,0x0644,
224 	194,0x0645,
225 	198,0x0646,
226 	199,0x0647,
227 	199,0x06be,
228 	202,0x06d5,
229 	203,0x0648,
230 	205,0x068d,
231 	208,0x064a,
232 	212,0x0649,
233 	213,0x0674,
234 	215,0x06c2,
235 	217,0x0626,
236 	218,0x0624,
237 	220,0x06d9,
238 	228,0x064e,
239 	231,0x064b,
240 	232,0x064c,
241 	234,0x0650,
242 	235,0x064d,
243 	233,0x0651,
244 	230,0x0652,
245 	229,0x064f,
246 	42,0x066d,
247 	78,0x06c3,
248 };
249 
250 int merge[]={};
251 #endif
252 
253 #ifdef HEBREW	/* elronm.pfb - monospaced, hebrewmm.pfb - proportional */
254 int copy[]={	/* iso 8859-8 */
255 	0xE0,0x05D0,
256 	0xE1,0x05D1,
257 	0xE2,0x05D2,
258 	0xE3,0x05D3,
259 	0xE4,0x05D4,
260 	0xE5,0x05D5,
261 	0xE6,0x05D6,
262 	0xE7,0x05D7,
263 	0xE8,0x05D8,
264 	0xE9,0x05D9,
265 	0xEA,0x05DA,
266 	0xEB,0x05DB,
267 	0xEC,0x05DC,
268 	0xED,0x05DD,
269 	0xEE,0x05DE,
270 	0xEF,0x05DF,
271 	0xF0,0x05E0,
272 	0xF1,0x05E1,
273 	0xF2,0x05E2,
274 	0xF3,0x05E3,
275 	0xF4,0x05E4,
276 	0xF5,0x05E5,
277 	0xF6,0x05E6,
278 	0xF7,0x05E7,
279 	0xF8,0x05E8,
280 	0xF9,0x05E9,
281 	0xFA,0x05EA,
282 };
283 
284 
285 int merge[]={};
286 #endif
287 
288 
289 #ifdef KATAKANA
290 int copy[]={
291 	33,0x30ac,
292 	35,0x30f7,
293 	36,0x30b2,
294 	37,0x30b4,
295 	38,0x30d3,
296 	39,0x30ef,
297 	40,0x30d9,
298 	41,0x30dc,
299 	42,0x30d6,
300 	43,0x30c3,
301 	44,0x30e4,
302 	45,0x30e9,
303 	46,0x30e6,
304 	47,0x30e8,
305 	48,0x30ce,
306 	49,0x30de,
307 	50,0x30a4,
308 	51,0x30a6,
309 	52,0x30a8,
310 	53,0x30aa,
311 	54,0x30ca,
312 	55,0x30cb,
313 	56,0x30cc,
314 	57,0x30cd,
315 	58,0x30dd,
316 	59,0x30e2,
317 	60,0x30e3,
318 	61,0x30ea,
319 	62,0x30e5,
320 	63,0x30e7,
321 	64,0x30f8,
322 	65,0x30b6,
323 	66,0x30c9,
324 	67,0x30c5,
325 	68,0x30ba,
326 	70,0x30bc,
327 	71,0x30be,
328 	72,0x30d1,
329 	74,0x30d4,
330 	75,0x30d7,
331 	76,0x30da,
332 	77,0x30a3,
333 	78,0x30a9,
334 	83,0x30b8,
335 	85,0x30a7,
336 	86,0x30c7,
337 	88,0x30c2,
338 	89,0x30a1,
339 	90,0x30c0,
340 	91,0x30eb,
341 	92,0x30ed,
342 	93,0x30ec,
343 	94,0x30d0,
344 	95,0x30fc,
345 	97,0x30b5,
346 	98,0x30c8,
347 	99,0x30c4,
348 	100,0x30b9,
349 	101,0x30af,
350 	102,0x30bb,
351 	103,0x30bd,
352 	104,0x30de,
353 	105,0x30d5,
354 	106,0x30df,
355 	107,0x30e0,
356 	108,0x30e1,
357 	109,0x30f3,
358 	110,0x30f2,
359 	111,0x30d8,
360 	112,0x30db,
361 	113,0x30f5,
362 	114,0x30f6,
363 	115,0x30c4,
364 	116,0x30b3,
365 	117,0x30d2,
366 	118,0x30c6,
367 	119,0x30f0,
368 	120,0x30c1,
369 	121,0x30cf,
370 	122,0x30bf,
371 	124,0x30a5,
372 };
373 int merge[]={};
374 #endif
375 
376 
377 #ifdef HIRAGANA
378 int copy[]={
379 	33,0x304c,
380 	35,0x3050,
381 	36,0x3052,
382 	37,0x3054,
383 	38,0x3073,
384 	39,0x308f,
385 	40,0x3079,
386 	41,0x307c,
387 	42,0x3076,
388 	43,0x3063,
389 	44,0x3084,
390 	45,0x3089,
391 	46,0x3086,
392 	47,0x3088,
393 	48,0x306e,
394 	49,0x3042,
395 	50,0x3044,
396 	51,0x3046,
397 	52,0x3048,
398 	53,0x304a,
399 	54,0x306a,
400 	55,0x306b,
401 	56,0x306c,
402 	57,0x306d,
403 	58,0x307d,
404 	59,0x3082,
405 	60,0x3083,
406 	62,0x3085,
407 	63,0x3087,
408 	64,0x304e,
409 	65,0x3056,
410 	66,0x3069,
411 	67,0x3065,
412 	68,0x305a,
413 	70,0x305c,
414 	71,0x305e,
415 	72,0x3071,
416 	74,0x3074,
417 	75,0x3077,
418 	76,0x307a,
419 	77,0x3043,
420 	78,0x3049,
421 	79,0x309c,
422 	83,0x3058,
423 	85,0x3047,
424 	86,0x3067,
425 	88,0x3062,
426 	89,0x3041,
427 	90,0x3060,
428 	91,0x308b,
429 	92,0x308d,
430 	93,0x308c,
431 	94,0x3070,
432 	97,0x3055,
433 	98,0x3068,
434 	99,0x3064,
435 	100,0x3059,
436 	101,0x304f,
437 	102,0x305b,
438 	103,0x305d,
439 	104,0x307e,
440 	105,0x3075,
441 	106,0x307f,
442 	107,0x3080,
443 	108,0x3081,
444 	109,0x3093,
445 	110,0x3092,
446 	111,0x3078,
447 	112,0x307b,
448 	113,0x304b,
449 	114,0x3051,
450 	115,0x3057,
451 	116,0x3053,
452 	117,0x3072,
453 	118,0x3066,
454 	119,0x304d,
455 	120,0x3061,
456 	121,0x306f,
457 	122,0x305f,
458 	124,0x3045
459 };
460 
461 int merge[]={};
462 #endif
463 
464 #ifdef LATIN
465 
466 /* 0xc2: acute
467  */
468 int copy[]={
469 	161,0xa1,
470 	162,0xa2,
471 	163,0xa3,
472 	165,0xa5,
473 	167,0xa7,
474 	171,0xab,
475 	172,0x2039,
476 	173,0x203a,
477 	174,0xfb01,
478 	175,0xfb02,
479 	177,0x2013,
480 	178,0x2020,
481 	179,0x2021,
482 	182,0xb6,
483 	183,0x2022,
484 	187,0xbb,
485 	188,0x2026,
486 	189,0x2030,
487 	191,0xbf,
488 	196,0x2dc,
489 	208,0x2014,
490 	225,0xc6,
491 	232,0x141,
492 	233,0xd8,
493 	234,0x152,
494 	235,0x2116,
495 	241,0xe6,
496 	248,0x142,
497 	249,0xf8,
498 	250,0x153,
499 	251,0xdf,
500 
501 	193,0x300,
502 #define GRA 193		/* ` */
503 	194,0xb4,
504 #define ACU 194		/* ' */
505 	195,0x2c6,
506 #define CIR 195		/* ^ */
507 	196,0x2dc,
508 #define TIL 196		/* ~ */
509 	197,0xaf,
510 #define MAC 197		/* - above */
511 	198,0x306,
512 #define LSC 198		/* lower semicircle above */
513 	199,0x2d9,
514 	199,0xb7,
515 #define DOT 199		/* . above */
516 	200,0xa8,
517 #define UML 200		/* .. above */
518 	202,0x2da,
519 	202,0xb0,
520 #define RIN 202		/* o above */
521 	203,0xb8,
522 #define CED 203		/* (5 without the top stroke) under */
523 	205,0x30b,
524 #define DAC 205		/* " */
525 	206,0x2db,
526 #define OGO 206		/* left-right mirrored J under (ogonek) */
527 	207,0x2c7,
528 #define CAR 207		/* v above */
529 
530 
531 
532 };
533 
534 int merge[]={
535 	'+','-',0xb1,
536 	'A',GRA,0xc0,
537 	'A',ACU,0xc1,
538 	'A',CIR,0xc2,
539 	'A',TIL,0xc3,
540 	'A',UML,0xc4,
541 	'A',RIN,0xc5,
542 	'C',CED,0xc7,
543 	'E',GRA,0xc8,
544 	'E',ACU,0xc9,
545 	'E',CIR,0xca,
546 	'E',UML,0xcb,
547 	'I',GRA,0xcc,
548 	'I',ACU,0xcd,
549 	'I',CIR,0xce,
550 	'I',UML,0xcf,
551 	'D','-',0xd0,
552 	'N',TIL,0xd1,
553 	'O',GRA,0xd2,
554 	'O',ACU,0xd3,
555 	'O',CIR,0xd4,
556 	'O',TIL,0xd5,
557 	'O',UML,0xd6,
558 	'U',GRA,0xd9,
559 	'U',ACU,0xda,
560 	'U',CIR,0xdb,
561 	'U',UML,0xdc,
562 	'Y',ACU,0xdd,
563 	'a',GRA,0xe0,
564 	'a',ACU,0xe1,
565 	'a',CIR,0xe2,
566 	'a',TIL,0xe3,
567 	'a',UML,0xe4,
568 	'a',RIN,0xe5,
569 	'c',CED,0xe7,
570 	'e',GRA,0xe8,
571 	'e',ACU,0xe9,
572 	'e',CIR,0xea,
573 	'e',UML,0xeb,
574 	'i',GRA,0xec,
575 	'i',ACU,0xed,
576 	'i',CIR,0xee,
577 	'i',UML,0xef,
578 	'n',TIL,0xf1,
579 	'o',GRA,0xf2,
580 	'o',ACU,0xf3,
581 	'o',CIR,0xf4,
582 	'o',TIL,0xf5,
583 	'o',UML,0xf6,
584 	'u',GRA,0xf9,
585 	'u',ACU,0xfa,
586 	'u',CIR,0xfb,
587 	'u',UML,0xfc,
588 	'y',ACU,0xfd,
589 	'y',UML,0xff,
590 	'A',MAC,0x100,
591 	'a',MAC,0x101,
592 	'A',LSC,0x102,
593 	'a',LSC,0x103,
594 	'A',OGO,0x104,
595 	'a',OGO,0x105,
596 	'C',ACU,0x106,
597 	'c',ACU,0x107,
598 	'C',CIR,0x108,
599 	'c',CIR,0x109,
600 	'C',DOT,0x10a,
601 	'c',DOT,0x10b,
602 	'C',CAR,0x10c,
603 	'c',CAR,0x10d,
604 	'D',CAR,0x10e,
605 	'd',0x27,0x10f,
606 	'D','-',0x110,
607 	'd','-',0x111,
608 	'E',MAC,0x112,
609 	'e',MAC,0x113,
610 	'E',LSC,0x114,
611 	'e',LSC,0x115,
612 	'E',DOT,0x116,
613 	'e',DOT,0x117,
614 	'E',OGO,0x118,
615 	'e',OGO,0x119,
616 	'E',CAR,0x11a,
617 	'e',CAR,0x11b,
618 	'G',CIR,0x11c,
619 	'g',CIR,0x11d,
620 	'G',LSC,0x11e,
621 	'g',LSC,0x11f,
622 	'G',DOT,0x120,
623 	'g',DOT,0x121,
624 	'H',CIR,0x124,
625 	'h',CIR,0x125,
626 	'H','-',0x126,
627 	'h','-',0x127,
628 	'I',TIL,0x128,
629 	'i',TIL,0x129,
630 	'I',MAC,0x12a,
631 	'i',MAC,0x12b,
632 	'I',LSC,0x12c,
633 	'i',LSC,0x12d,
634 	'I',OGO,0x12e,
635 	'i',OGO,0x12f,
636 	'I',DOT,0x130,
637 	'I','J',0x132,
638 	'i','j',0x133,
639 	'J',CIR,0x134,
640 	'j',CIR,0x135,
641 	'L',ACU,0x139,
642 	'l',ACU,0x13a,
643 	'L',0x27,0x13d,
644 	'l',0x27,0x13e,
645 	'N',ACU,0x143,
646 	'n',ACU,0x144,
647 	'N',CAR,0x147,
648 	'n',CAR,0x148,
649 	'O',MAC,0x14c,
650 	'o',MAC,0x14d,
651 	'O',LSC,0x14e,
652 	'o',LSC,0x14f,
653 	'O',DAC,0x150,
654 	'o',DAC,0x151,
655 	'R',ACU,0x154,
656 	'r',ACU,0x155,
657 	'R',CAR,0x158,
658 	'r',CAR,0x159,
659 	'S',ACU,0x15a,
660 	's',ACU,0x15b,
661 	'S',CIR,0x15c,
662 	's',CIR,0x15d,
663 	'S',CED,0x15e,
664 	's',CED,0x15f,
665 	'S',CAR,0x160,
666 	's',CAR,0x161,
667 	'T',CED,0x162,
668 	't',CED,0x163,
669 	'T',CAR,0x164,
670 	't',0x27,0x165,
671 	'T','-',0x166,
672 	't','-',0x167,
673 	'U',TIL,0x168,
674 	'u',TIL,0x169,
675 	'U',MAC,0x16a,
676 	'u',MAC,0x16b,
677 	'U',LSC,0x16c,
678 	'u',LSC,0x16d,
679 	'U',RIN,0x16e,
680 	'u',RIN,0x16f,
681 	'U',DAC,0x170,
682 	'u',DAC,0x171,
683 	'U',OGO,0x172,
684 	'u',OGO,0x173,
685 	'W',CIR,0x174,
686 	'w',CIR,0x175,
687 	'Y',CIR,0x176,
688 	'y',CIR,0x177,
689 	'Y',UML,0x178,
690 	'Z',ACU,0x179,
691 	'z',ACU,0x17a,
692 	'Z',DOT,0x17b,
693 	'z',DOT,0x17c,
694 	'Z',CAR,0x17d,
695 	'z',CAR,0x17e,
696 	'A',CAR,0x1cd,
697 	'a',CAR,0x1ce,
698 	'I',CAR,0x1cf,
699 	'i',CAR,0x1d0,
700 	'O',CAR,0x1d1,
701 	'o',CAR,0x1d2,
702 	'U',CAR,0x1d3,
703 	'u',CAR,0x1d4,
704 	'G',CAR,0x1e6,
705 	'g',CAR,0x1e7,
706 	'K',CAR,0x1e8,
707 	'k',CAR,0x1e9,
708 	'O',OGO,0x1ea,
709 	'o',OGO,0x1eb,
710 	'j',CAR,0x1f0,
711 	'G',ACU,0x1f4,
712 	'g',ACU,0x1f5,
713 	'N',GRA,0x1f8,
714 	'n',GRA,0x1f9,
715 };
716 
717 #endif /* LATIN */
718 
719 #ifdef DINGBATS
720 
721 int merge[]={};
722 
723 int copy[]={
724 	43,0x261e,
725 };
726 
727 #endif /* DINGBATS */
728 
729 #ifdef CYRILLIC
730 
731 int merge[]={};
732 
733 int copy[]={
734 	45,0x044d,
735 	65,0x0410,
736 	66,0x0411,
737 	67,0x0426,
738 	68,0x0414,
739 	69,0x0415,
740 	70,0x0424,
741 	71,0x0413,
742 	72,0x0425,
743 	73,0x0418,
744 	74,0x0416,
745 	75,0x041a,
746 	76,0x041b,
747 	77,0x041c,
748 	78,0x041d,
749 	79,0x041e,
750 	80,0x041f,
751 	81,0x0427,
752 	82,0x0420,
753 	83,0x0421,
754 	84,0x0422,
755 	85,0x0423,
756 	86,0x0412,
757 	87,0x0428,
758 	88,0x0429,
759 	89,0x0419,
760 	90,0x0417,
761 	91,0x044b,
762 	93,0x044e,
763 	95,0x042d,
764 	97,0x0430,
765 	98,0x0431,
766 	99,0x0446,
767 	100,0x0434,
768 	101,0x0435,
769 	102,0x0444,
770 	103,0x0433,
771 	104,0x0445,
772 	105,0x0438,
773 	106,0x0436,
774 	107,0x043a,
775 	108,0x043b,
776 	109,0x043c,
777 	110,0x043d,
778 	111,0x043e,
779 	112,0x043f,
780 	113,0x0447,
781 	114,0x0440,
782 	115,0x0441,
783 	116,0x0442,
784 	117,0x0443,
785 	118,0x0432,
786 	119,0x0448,
787 	120,0x0449,
788 	121,0x0439,
789 	122,0x0437,
790 	123,0x042b,
791 	125,0x042e,
792 	161,0x044c,
793 	164,0x042c,
794 	168,0x042a,
795 	233,0x0401,
796 	249,0x0451
797 };
798 
799 #endif /* CYRILLIC */
800 
801 #ifdef GREEK
802 int copy[]={
803 	65,0x0391,
804 	66,0x0392,
805 	67,0x0393,
806 	68,0x0394,
807 	69,0x0395,
808 	70,0x0396,
809 	71,0x0397,
810 	72,0x0398,
811 	73,0x0399,
812 	74,0x039a,
813 	75,0x039b,
814 	76,0x039c,
815 	77,0x039d,
816 	78,0x039e,
817 	79,0x039f,
818 	80,0x03a0,
819 	81,0x03a1,
820 	82,0x03a3,
821 	83,0x03a4,
822 	84,0x03d2,
823 	85,0x03a6,
824 	86,0x03a7,
825 	87,0x03a8,
826 	88,0x03a9,
827 	97,0x03b1,
828 	98,0x03b2,
829 	99,0x03b3,
830 	100,0x03b4,
831 	101,0x03b5,
832 	102,0x03b6,
833 	103,0x03b7,
834 	104,0x03d1,
835 	105,0x03b8,
836 	106,0x03ba,
837 	107,0x03bb,
838 	108,0x03bc,
839 	109,0x03bd,
840 	110,0x03be,
841 	111,0x03bf,
842 	112,0x03c0,
843 	113,0x03c1,
844 	114,0x03c3,
845 	115,0x03c4,
846 	116,0x03c5,
847 	117,0x03c6,
848 	118,0x03c7,
849 	119,0x03c8,
850 	120,0x03c9,
851 };
852 
853 int merge[]={};
854 
855 #endif /* #ifdef GREEK */
856 unsigned char string[256];
857 
cp(int src,int dest)858 void cp(int src, int dest)
859 {
860 		sprintf(string,"cp font/new/orig_%04x.png font/new/%04x.png"
861 		"\n",src,dest);
862 		fputs(string,stderr);
863 		system(string);
864 }
865 
mrg(int letter,int accent,int dest)866 void mrg(int letter, int accent, int dest)
867 {
868 	sprintf(string,"convert +append font/new/orig_%04x.png spacer.png"
869 	" font/new/orig_%04x.png font/new/%04x.png\n",
870 	letter,accent,dest);
871 	fputs(string,stderr);
872 	system(string);
873 }
874 
main(int argc,char ** argv)875 int main(int argc, char **argv)
876 {
877 	int a,top_margin,bottom_margin;
878 	float dpi;
879 	unsigned char *txt;
880 	FILE *f;
881 
882 	if (!(txt=getenv("hundred_dpi"))){
883 		fprintf(stderr,"Can't find environment variable \"hundred_dpi\".\n");
884 		exit(1);
885 	}
886 	dpi=atof(txt)/100;
887 	if (!(txt=getenv("top_promile"))){
888 		fprintf(stderr,"Can't find environment variable \"top_promile\".\n");
889 		exit(1);
890 	}
891 	top_margin=atol(txt)*842*dpi/72000;
892 	if (!(txt=getenv("bottom_promile"))){
893 		fprintf(stderr,"Can't find environment variable \"bottom_promile\".\n");
894 		exit(1);
895 	}
896 	bottom_margin=atol(txt)*842*dpi/72000;
897 
898 	f=fopen("clip_improcess_program","w");
899 	if (!f){
900 		fprintf(stderr,"Can't open \"clip_improcess_program\" file for"
901 		" writing.\n");
902 		perror(argv[0]);
903 		exit(1);
904 	}
905 	fprintf(f,"detract %d\n",bottom_margin);
906 	fprintf(f,"mirror\nflip\nmirror\nflip\n");
907 	fprintf(f,"detract %d\n",top_margin);
908 	fprintf(f,"mirror\nflip\nmirror\nflip\n");
909 	fclose(f);
910 
911 	fprintf(stderr,"mkdir -p font/new\n");
912 	system("mkdir -p font/new");
913 	fprintf(stderr,"rm font/new/*\n");
914 	system("rm font/new/*");
915 	for (a=0;a<256;a++)
916 	{
917 		sprintf(string,"convert -crop 0x0 letters%d.png letters%d.png\n",a,a);
918 		fputs(string,stderr);
919 		system(string);
920 		sprintf(string,"./improcess letters%d.png clip_improcess_program"
921 			" font/new/orig_%04x.png\n",a,a);
922 		fputs(string,stderr);
923 		system(string);
924 	}
925 	sprintf(string,"rm letters*.png\n");
926 	fputs(string,stderr);
927 	system(string);
928 #ifdef LATIN
929 	for (a=32;a<127;a++){
930 		cp(a,a);
931 	}
932 #endif /* LATIN */
933 	for (a=0;a<sizeof(copy)/sizeof(*copy)/2;a++){
934 		cp(copy[a*2],copy[a*2+1]);
935 	}
936 	for (a=0;a<sizeof(merge)/sizeof(*merge)/3;a++){
937 		mrg(merge[a*3],merge[a*3+1],merge[a*3+2]);
938 	}
939 	fprintf(stderr,"rm font/new/orig_????.png\n");
940 	system("rm font/new/orig_????.png\n");
941 	return 0;
942 }
943 
944