Debian Codegraph @

texk/ttfdump/libttf/otfcommon.c

raw
1 /* otfcommon.c -- OpenType Common Table Formats
2 */
3 #ifdef HAVE_CONFIG_H
4 #include <config.h>
5 #endif
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "ttf.h"
10 #include "ttfutil.h"
11
12 static LangSysPtr
13 otfMakeLangSys (FILE *fp, ULONG offset)
14 {
15 LangSysPtr langSys = XCALLOC1 (LangSys);
16 USHORT lookupOrder;
17
18 xfseek (fp, offset, SEEK_SET, "otfMakeLangSys");
19
20 if ((lookupOrder = ttfGetUSHORT (fp)) != 0)
21 ttfError ("Non-zero lookupOrder\n");
22 langSys->reqFeatureIndex = ttfGetUSHORT (fp);
23 langSys->featureCount = ttfGetUSHORT (fp);
24 langSys->featureIndex = ttfMakeUSHORT (langSys->featureCount, fp);
25
26 return langSys;
27 }
28
29 static void
30 otfLoadScriptRecord (FILE *fp, ScriptRecordPtr scriptRecord, ULONG offset)
31 {
32 int i;
33 USHORT dOffset;
34 USHORT *lOffset;
35
36 xfseek (fp, offset, SEEK_SET, "otfLoadScriptRecord");
37
38 dOffset = ttfGetUSHORT (fp);
39
40 scriptRecord->langSysCount = ttfGetUSHORT (fp);
41 if (scriptRecord->langSysCount) {
42 scriptRecord->langSysRecord = XCALLOC (scriptRecord->langSysCount, LangSysRecord);
43 lOffset = XTALLOC (scriptRecord->langSysCount, USHORT);
44
45 for (i = 0; i < scriptRecord->langSysCount; i++) {
46 scriptRecord->langSysRecord[i].tag = ttfGetULONG (fp);
47 lOffset[i] = ttfGetUSHORT (fp);
48 }
49
50 for (i = 0; i < scriptRecord->langSysCount; i++)
51 scriptRecord->langSysRecord[i].langSys = otfMakeLangSys (fp, offset + lOffset[i]);
52
53 free (lOffset);
54 }
55
56 if (dOffset)
57 scriptRecord->defaultLangSys = otfMakeLangSys (fp, offset + dOffset);
58 }
59
60 ScriptListPtr
61 otfMakeScriptList (FILE *fp, ULONG offset)
62 {
63 int i;
64 USHORT *sOffset;
65 ScriptListPtr scriptList = XCALLOC1 (ScriptList);
66
67 xfseek (fp, offset, SEEK_SET, "otfMakeScriptList");
68
69 scriptList->scriptCount = ttfGetUSHORT (fp);
70 scriptList->scriptRecord = XCALLOC (scriptList->scriptCount, ScriptRecord);
71 sOffset = XTALLOC (scriptList->scriptCount, USHORT);
72
73 for (i = 0; i < scriptList->scriptCount; i++) {
74 scriptList->scriptRecord[i].tag = ttfGetULONG (fp);
75 sOffset[i] = ttfGetUSHORT (fp);
76 }
77
78 for (i = 0; i < scriptList->scriptCount; i++)
79 otfLoadScriptRecord (fp, &scriptList->scriptRecord[i], offset + sOffset[i]);
80
81 free (sOffset);
82
83 return scriptList;
84 }
85
86 static void
87 otfPrintLangSys (FILE *fp, LangSysPtr langSys)
88 {
89 int i;
90
91 fprintf (fp, " lang - featureCount: %d\n", langSys->featureCount);
92 if (langSys->reqFeatureIndex != 0xffff)
93 fprintf (fp, "\t\t reqFeatureIndex: %d\n", langSys->reqFeatureIndex);
94 if (langSys->featureCount) {
95 fprintf (fp, "\t\t featureIndex: %d", langSys->featureIndex[0]);
96 for (i = 1; i < langSys->featureCount; i++)
97 fprintf (fp, i % 8 ? ", %d" : ",\n\t\t\t\t%d",
98 langSys->featureIndex[i]);
99 fprintf (fp, "\n");
100 }
101 }
102
103 static void
104 otfPrintScriptRecord (FILE *fp, ScriptRecordPtr scriptRecord)
105 {
106 int i;
107
108 fprintf (fp, "'%s' script - langSysCount: %d\n",
109 TagToStr (scriptRecord->tag), scriptRecord->langSysCount);
110 if (scriptRecord->defaultLangSys) {
111 fprintf (fp, "\t default");
112 otfPrintLangSys (fp, scriptRecord->defaultLangSys);
113 }
114 for (i = 0; i < scriptRecord->langSysCount; i++) {
115 fprintf (fp, " %2d. '%s'", i,
116 TagToStr (scriptRecord->langSysRecord[i].tag));
117 otfPrintLangSys (fp, scriptRecord->langSysRecord[i].langSys);
118 }
119 }
120
121 void
122 otfPrintScriptList (FILE *fp, ScriptListPtr scriptList)
123 {
124 int i;
125
126 fprintf (fp, " scriptCount: %d\n", scriptList->scriptCount);
127
128 for (i = 0; i < scriptList->scriptCount; i++) {
129 fprintf (fp, " %2d. ", i);
130 otfPrintScriptRecord (fp, &scriptList->scriptRecord[i]);
131 }
132 fprintf (fp, "\n");
133 }
134
135 static void
136 otfFreeLangSys (LangSysPtr langSys)
137 {
138 free (langSys->featureIndex);
139 free (langSys);
140 }
141
142 static void
143 otfFreeScriptRecord (ScriptRecordPtr scriptRecord)
144 {
145 int i;
146
147 if (scriptRecord->defaultLangSys)
148 otfFreeLangSys (scriptRecord->defaultLangSys);
149 for (i = 0; i < scriptRecord->langSysCount; i++)
150 otfFreeLangSys (scriptRecord->langSysRecord[i].langSys);
151 free (scriptRecord->langSysRecord);
152 }
153
154 void
155 otfFreeScriptList (ScriptListPtr scriptList)
156 {
157 int i;
158
159 for (i = 0; i < scriptList->scriptCount; i++)
160 otfFreeScriptRecord (&scriptList->scriptRecord[i]);
161 free (scriptList->scriptRecord);
162 free (scriptList);
163 }
164
165 static void
166 otfLoadFeatureRecord (FILE *fp, FeatureRecordPtr featureRecord, ULONG offset)
167 {
168 xfseek (fp, offset, SEEK_SET, "otfLoadFeatureRecord");
169
170 featureRecord->featureParams = ttfGetUSHORT (fp);
171 featureRecord->lookupCount = ttfGetUSHORT (fp);
172 featureRecord->lookupListIndex = ttfMakeUSHORT (featureRecord->lookupCount, fp);
173 }
174
175 FeatureListPtr
176 otfMakeFeatureList (FILE *fp, ULONG offset)
177 {
178 int i;
179 USHORT *fOffset;
180 FeatureListPtr featureList = XCALLOC1 (FeatureList);
181
182 xfseek (fp, offset, SEEK_SET, "otfMakeFeatureList");
183
184 featureList->featureCount = ttfGetUSHORT (fp);
185 if (featureList->featureCount) {
186 featureList->featureRecord = XCALLOC (featureList->featureCount, FeatureRecord);
187 fOffset = XTALLOC (featureList->featureCount, USHORT);
188
189 for (i = 0; i < featureList->featureCount; i++) {
190 featureList->featureRecord[i].tag = ttfGetULONG (fp);
191 fOffset[i] = ttfGetUSHORT (fp);
192 }
193
194 for (i = 0; i < featureList->featureCount; i++)
195 otfLoadFeatureRecord (fp, &featureList->featureRecord[i], offset + fOffset[i]);
196
197 free (fOffset);
198 }
199
200 return featureList;
201 }
202
203 static void
204 otfPrintFeatureRecord (FILE *fp, FeatureRecordPtr featureRecord)
205 {
206 int i;
207
208 fprintf (fp, "'%s' feature - lookupCount: %d\n",
209 TagToStr (featureRecord->tag), featureRecord->lookupCount);
210 fprintf (fp, "\t\tlookupListIndex: %d", featureRecord->lookupListIndex[0]);
211 for (i = 1; i < featureRecord->lookupCount; i++)
212 fprintf (fp, i % 8 ? ", %d" : ",\n\t\t\t\t %d",
213 featureRecord->lookupListIndex[i]);
214 fprintf (fp, "\n");
215 if (featureRecord->featureParams)
216 fprintf (fp, "\t\tfeatureParams Offset: 0x%04x\n", featureRecord->featureParams);
217 }
218
219 void
220 otfPrintFeatureList (FILE *fp, FeatureListPtr featureList)
221 {
222 int i;
223
224 fprintf (fp, " featureCount: %d\n", featureList->featureCount);
225
226 for (i = 0; i < featureList->featureCount; i++) {
227 fprintf (fp, " %2d. ", i);
228 otfPrintFeatureRecord (fp, &featureList->featureRecord[i]);
229 }
230 fprintf (fp, "\n");
231 }
232
233 void
234 otfFreeFeatureList (FeatureListPtr featureList)
235 {
236 int i;
237
238 if (featureList->featureCount) {
239 for (i = 0; i < featureList->featureCount; i++)
240 free (featureList->featureRecord[i].lookupListIndex);
241 free (featureList->featureRecord);
242 }
243 free (featureList);
244 }
245
246 static void
247 otfLoadLookupRecord (FILE *fp, LookupRecordPtr lookupRecord, ULONG offset, MakeLookupFunc makeLookup)
248 {
249 int i;
250 USHORT lookupType;
251 USHORT *lOffset;
252
253 xfseek (fp, offset, SEEK_SET, "otfLoadLookupRecord");
254
255 lookupType = ttfGetUSHORT (fp);
256 lookupRecord->lookupFlag = ttfGetUSHORT (fp);
257 lookupRecord->subTableCount = ttfGetUSHORT (fp);
258 lookupRecord->lookup = XCALLOC (lookupRecord->subTableCount, LookupPtr);
259 lOffset = ttfMakeUSHORT (lookupRecord->subTableCount, fp);
260 if (lookupRecord->lookupFlag & lookupFlag_UseMarkFilteringSet)
261 lookupRecord->markFilteringSet = ttfGetUSHORT (fp);
262 for (i = 0; i < lookupRecord->subTableCount; i++)
263 lookupRecord->lookup[i] = (*makeLookup) (fp, lookupType, offset + lOffset[i]);
264 free (lOffset);
265 }
266
267 LookupListPtr
268 otfMakeLookupList (FILE *fp, ULONG offset, MakeLookupFunc makeLookup)
269 {
270 int i;
271 USHORT *lOffset;
272 LookupListPtr lookupList = XCALLOC1 (LookupList);
273
274 xfseek (fp, offset, SEEK_SET, "otfMakeLookupList");
275
276 lookupList->lookupCount = ttfGetUSHORT (fp);
277 if (lookupList->lookupCount) {
278 lookupList->lookupRecord = XCALLOC (lookupList->lookupCount, LookupRecord);
279 lOffset = ttfMakeUSHORT (lookupList->lookupCount, fp);
280
281 for (i = 0; i < lookupList->lookupCount; i++)
282 otfLoadLookupRecord (fp, &lookupList->lookupRecord[i], offset + lOffset[i], makeLookup);
283
284 free (lOffset);
285 }
286
287 return lookupList;
288 }
289
290 void
291 otfPrintLookupList (FILE *fp, LookupListPtr lookupList, PrintLookupFunc printLookup)
292 {
293 int i;
294
295 fprintf (fp, " lookupCount: %d\n", lookupList->lookupCount);
296
297 for (i = 0; i < lookupList->lookupCount; i++) {
298 int j;
299
300 fprintf (fp, " %2d. lookupType: %d, lookupFlag: 0x%04x", i,
301 lookupList->lookupRecord[i].lookup[0].otf->lookupType,
302 lookupList->lookupRecord[i].lookupFlag);
303 if (lookupList->lookupRecord[i].lookupFlag & lookupFlag_UseMarkFilteringSet)
304 fprintf (fp, ", markFilteringSet: %d", lookupList->lookupRecord[i].markFilteringSet);
305 fprintf (fp, "\n\tsubTableCount:\t%d\n", lookupList->lookupRecord[i].subTableCount);
306 for (j = 0; j < lookupList->lookupRecord[i].subTableCount; j++) {
307 fprintf (fp, " %2d. lookupFormat: %d", j,
308 lookupList->lookupRecord[i].lookup[j].otf->lookupFormat);
309 (*printLookup) (fp, lookupList->lookupRecord[i].lookup[j]);
310 }
311 }
312 fprintf (fp, "\n");
313 }
314
315 void
316 otfFreeLookupList (LookupListPtr lookupList, FreeLookupFunc freeLookup)
317 {
318 int i;
319
320 if (lookupList->lookupCount) {
321 for (i = 0; i < lookupList->lookupCount; i++) {
322 int j;
323
324 for (j = 0; j < lookupList->lookupRecord[i].subTableCount; j++) {
325 (*freeLookup) (lookupList->lookupRecord[i].lookup[j]);
326 free (lookupList->lookupRecord[i].lookup[j].otf);
327 }
328 free (lookupList->lookupRecord[i].lookup);
329 }
330 free (lookupList->lookupRecord);
331 }
332 free (lookupList);
333 }
334
335 CoveragePtr
336 otfMakeCoverage (FILE *fp, ULONG offset)
337 {
338 CoveragePtr coverage;
339 int i;
340 USHORT format;
341
342 xfseek (fp, offset, SEEK_SET, "otfMakeCoverage");
343
344 format = ttfGetUSHORT (fp);
345 switch (format)
346 {
347 case 1:
348 coverage.coverage1 = XCALLOC1 (Coverage1);
349 coverage.coverage1->glyphCount = ttfGetUSHORT (fp);
350 coverage.coverage1->glyphArray = ttfMakeUSHORT (coverage.coverage1->glyphCount, fp);
351 break;
352 case 2:
353 coverage.coverage2 = XCALLOC1 (Coverage2);
354 coverage.coverage2->rangeCount = ttfGetUSHORT (fp);
355 coverage.coverage2->rangeRecord = XTALLOC (coverage.coverage2->rangeCount, RangeRecord);
356 for (i = 0; i < coverage.coverage2->rangeCount; i++) {
357 coverage.coverage2->rangeRecord[i].start = ttfGetUSHORT (fp);
358 coverage.coverage2->rangeRecord[i].end = ttfGetUSHORT (fp);
359 coverage.coverage2->rangeRecord[i].startCoverageIndex = ttfGetUSHORT (fp);
360 }
361 break;
362 default:
363 ttfError ("Unrecognized coverageFormat\n");
364 }
365
366 *coverage.format = format;
367 return coverage;
368 }
369
370 void
371 otfPrintCoverage (FILE *fp, CoveragePtr coverage)
372 {
373 int i;
374
375 fprintf (fp, "Coverage - ");
376 switch (*coverage.format)
377 {
378 case 1:
379 fprintf (fp, "glyphCount: %d\n\t\t glyphArray: %d",
380 coverage.coverage1->glyphCount, coverage.coverage1->glyphArray[0]);
381 for (i = 1; i < coverage.coverage1->glyphCount; i++)
382 fprintf (fp, i % 8 ? ", %d" : ",\n\t\t\t %d",
383 coverage.coverage1->glyphArray[i]);
384 fprintf (fp, "\n");
385 break;
386 case 2:
387 fprintf (fp, "rangeCount: %d\n", coverage.coverage2->rangeCount);
388 for (i = 0; i < coverage.coverage2->rangeCount; i++) {
389 fprintf (fp, "\t %2d. start: %d, end: %d, startCoverageIndex: %d\n", i,
390 coverage.coverage2->rangeRecord[i].start,
391 coverage.coverage2->rangeRecord[i].end,
392 coverage.coverage2->rangeRecord[i].startCoverageIndex);
393 }
394 break;
395 default:
396 ttfError ("Internal error: otfPrintCoverage\n");
397 }
398 }
399
400 void
401 otfFreeCoverage (CoveragePtr coverage)
402 {
403 switch (*coverage.format)
404 {
405 case 1:
406 free (coverage.coverage1->glyphArray);
407 break;
408 case 2:
409 free (coverage.coverage2->rangeRecord);
410 break;
411 default:
412 ttfError ("Internal error: otfFreeCoverage\n");
413 }
414 free (coverage.format);
415 }
416
417 ClassDefPtr
418 otfMakeClassDef (FILE *fp, ULONG offset)
419 {
420 ClassDefPtr classDef;
421 int i;
422 USHORT format;
423
424 xfseek (fp, offset, SEEK_SET, "otfMakeClassDef");
425
426 format = ttfGetUSHORT (fp);
427 switch (format)
428 {
429 case 1:
430 classDef.classDef1 = XCALLOC1 (ClassDef1);
431 classDef.classDef1->startGlyph = ttfGetUSHORT (fp);
432 classDef.classDef1->glyphCount = ttfGetUSHORT (fp);
433 classDef.classDef1->classValueArray = ttfMakeUSHORT (classDef.classDef1->glyphCount, fp);
434 break;
435 case 2:
436 classDef.classDef2 = XCALLOC1 (ClassDef2);
437 classDef.classDef2->classRangeCount = ttfGetUSHORT (fp);
438 classDef.classDef2->classRangeRecord = XTALLOC (classDef.classDef2->classRangeCount, ClassRangeRecord);
439 for (i = 0; i < classDef.classDef2->classRangeCount; i++) {
440 classDef.classDef2->classRangeRecord[i].start = ttfGetUSHORT (fp);
441 classDef.classDef2->classRangeRecord[i].end = ttfGetUSHORT (fp);
442 classDef.classDef2->classRangeRecord[i].classValue = ttfGetUSHORT (fp);
443 }
444 break;
445 default:
446 ttfError ("Unrecognized classDefFormat\n");
447 }
448
449 *classDef.format = format;
450 return classDef;
451 }
452
453 void
454 otfPrintClassDef (FILE *fp, ClassDefPtr classDef)
455 {
456 int i;
457
458 switch (*classDef.format)
459 {
460 case 1:
461 fprintf (fp, "startGlyph: %d, glyphCount: %d\n\t\tclassValueArray ",
462 classDef.classDef1->startGlyph, classDef.classDef1->glyphCount);
463 for (i = 0; i < classDef.classDef1->glyphCount; i++)
464 fprintf (fp, i == 0 ? "- %d" : i % 8 ? ", %d" : ",\n\t\t\t\t %d",
465 classDef.classDef1->classValueArray[i]);
466 fprintf (fp, "\n");
467 break;
468 case 2:
469 fprintf (fp, "classRangeCount: %d\n", classDef.classDef2->classRangeCount);
470 for (i = 0; i < classDef.classDef2->classRangeCount; i++)
471 fprintf (fp, "\t\t%2d. start: %d, end: %d, classValue: %d\n", i,
472 classDef.classDef2->classRangeRecord[i].start,
473 classDef.classDef2->classRangeRecord[i].end,
474 classDef.classDef2->classRangeRecord[i].classValue);
475 break;
476 default:
477 ttfError ("Internal error: otfPrintClassDef\n");
478 }
479 }
480
481 void
482 otfFreeClassDef (ClassDefPtr classDef)
483 {
484 switch (*classDef.format)
485 {
486 case 1:
487 free (classDef.classDef1->classValueArray);
488 break;
489 case 2:
490 free (classDef.classDef2->classRangeRecord);
491 break;
492 default:
493 ttfError ("Internal error: otfFreeClassDef\n");
494 }
495 free (classDef.format);
496 }
497
498 DevicePtr
499 otfMakeDevice (FILE *fp, ULONG offset)
500 {
501 size_t num;
502 DevicePtr device;
503 USHORT startSize, endSize, deltaFormat;
504
505 xfseek (fp, offset, SEEK_SET, "otfMakeDevice");
506
507 startSize = ttfGetUSHORT (fp);
508 endSize = ttfGetUSHORT (fp);
509 deltaFormat = ttfGetUSHORT (fp);
510 if (deltaFormat < 1 || deltaFormat > 3)
511 ttfError ("Unrecognized deltaFormat\n");
512 num = (endSize - startSize) >> (4 - deltaFormat);
513 device = (DevicePtr) xcalloc (1, sizeof (Device) + num * sizeof (USHORT));
514 device->startSize = startSize;
515 device->endSize = endSize;
516 device->deltaFormat = deltaFormat;
517 ttfReadUSHORT (device->deltaValue, num + 1, fp);
518
519 return device;
520 }
521
522 void
523 otfPrintDevice (FILE *fp, DevicePtr device)
524 {
525 int i;
526 size_t num = (device->endSize - device->startSize) >> (4 - device->deltaFormat);
527
528 fprintf (fp, "startSize = %d, endSize = %d, deltaFormat = %d, deltaValue = 0x",
529 device->startSize, device->endSize, device->deltaFormat);
530 for (i = 0; i < num; i++)
531 fprintf (fp, "%04x", device->deltaValue[i]);
532 fprintf (fp, "%04x\n", device->deltaValue[num]);
533 }
534
535 static OtfLookupRecordPtr
536 makeOtfLookupRecord (USHORT otfCount, FILE *fp)
537 {
538 int i;
539 OtfLookupRecordPtr otf = XCALLOC (otfCount, OtfLookupRecord);
540
541 for (i = 0; i < otfCount; i++) {
542 otf[i].sequenceIndex = ttfGetUSHORT (fp);
543 otf[i].lookupListIndex = ttfGetUSHORT (fp);
544 }
545 return otf;
546 }
547
548 static void
549 printOtfLookupRecord (FILE * fp, const char *str, USHORT otfCount, OtfLookupRecordPtr otf)
550 {
551 int i;
552
553 fprintf (fp, "\t%sotfCount: %d\n", str, otfCount);
554 for (i = 0; i < otfCount; i++)
555 fprintf (fp, "\t%s%2d. sequenceIndex: %d, lookupListIndex: %d\n",
556 str, i, otf[i].sequenceIndex, otf[i].lookupListIndex);
557 }
558
559 static void loadOtfRule (OtfRulePtr otfRule, FILE *fp, ULONG offset)
560 {
561 xfseek (fp, offset, SEEK_SET, "loadOtfRule");
562
563 otfRule->glyphCount = ttfGetUSHORT (fp);
564 otfRule->otfCount = ttfGetUSHORT (fp);
565 otfRule->input = ttfMakeUSHORT (otfRule->glyphCount - 1, fp);
566 otfRule->otf = makeOtfLookupRecord (otfRule->otfCount, fp);
567 }
568
569 static void loadOtfRuleSet (OtfRuleSetPtr otfRuleSet, FILE *fp, ULONG offset)
570 {
571 int i;
572 USHORT *rOffset;
573
574 xfseek (fp, offset, SEEK_SET, "loadOtfRuleSet");
575
576 otfRuleSet->otfRuleCount = ttfGetUSHORT (fp);
577 rOffset = ttfMakeUSHORT (otfRuleSet->otfRuleCount, fp);
578 otfRuleSet->otfRule = XCALLOC (otfRuleSet->otfRuleCount, OtfRule);
579 for (i = 0; i < otfRuleSet->otfRuleCount; i++)
580 loadOtfRule (&otfRuleSet->otfRule[i], fp, offset + rOffset[i]);
581 free (rOffset);
582 }
583
584 OtfCtx1Ptr makeOTFCtx1 (FILE *fp, ULONG offset)
585 {
586 int i;
587 USHORT cOffset;
588 USHORT *rOffset;
589 OtfCtx1Ptr otf = XCALLOC1 (OtfCtx1);
590
591 cOffset = ttfGetUSHORT (fp);
592 otf->otfRuleSetCount = ttfGetUSHORT (fp);
593 rOffset = ttfMakeUSHORT (otf->otfRuleSetCount, fp);
594 otf->otfRuleSet = XCALLOC (otf->otfRuleSetCount, OtfRuleSet);
595 otf->coverage = otfMakeCoverage (fp, offset + cOffset);
596 for (i = 0; i < otf->otfRuleSetCount; i++)
597 loadOtfRuleSet (&otf->otfRuleSet[i], fp, offset + rOffset[i]);
598 free (rOffset);
599
600 return otf;
601 }
602
603 void printOTFCtx1 (FILE *fp, OtfCtx1Ptr otf)
604 {
605 int i;
606
607 fprintf (fp, " - Context %s Simple\n\t ",
608 otf->lookupType == 7 ? "Positioning" : "Substitution");
609 otfPrintCoverage (fp, otf->coverage);
610 fprintf (fp, "\t otfRuleSetCount: %d\n", otf->otfRuleSetCount);
611 for (i = 0; i < otf->otfRuleSetCount; i++) {
612 int j;
613
614 fprintf (fp, "\t %2d. otfRuleCount: %d\n", i, otf->otfRuleSet[i].otfRuleCount);
615 for (j = 0; j < otf->otfRuleSet[i].otfRuleCount; j++) {
616 int k;
617
618 fprintf (fp, "\t %2d. glyphCount: %d ", j,
619 otf->otfRuleSet[i].otfRule[j].glyphCount);
620 for (k = 0; k < otf->otfRuleSet[i].otfRule[j].glyphCount - 1; k++)
621 fprintf (fp, k == 0 ? "- %d" : ", %d", otf->otfRuleSet[i].otfRule[j].input[k]);
622 fprintf (fp, "\n");
623 printOtfLookupRecord (fp, " ",
624 otf->otfRuleSet[i].otfRule[j].otfCount,
625 otf->otfRuleSet[i].otfRule[j].otf);
626 }
627 }
628 }
629
630 void freeOTFCtx1 (OtfCtx1Ptr otf)
631 {
632 int i;
633
634 otfFreeCoverage (otf->coverage);
635 for (i = 0; i < otf->otfRuleSetCount; i++) {
636 int j;
637
638 for (j = 0; j < otf->otfRuleSet[i].otfRuleCount; j++) {
639 free (otf->otfRuleSet[i].otfRule[j].input);
640 free (otf->otfRuleSet[i].otfRule[j].otf);
641 }
642 free (otf->otfRuleSet[i].otfRule);
643 }
644 free (otf->otfRuleSet);
645 }
646
647 static void loadOtfClassRule (OtfClassRulePtr otfClassRule, FILE *fp, ULONG offset)
648 {
649 xfseek (fp, offset, SEEK_SET, "loadOtfClassRule");
650
651 otfClassRule->glyphCount = ttfGetUSHORT (fp);
652 otfClassRule->otfCount = ttfGetUSHORT (fp);
653 otfClassRule->class = ttfMakeUSHORT (otfClassRule->glyphCount - 1, fp);
654 otfClassRule->otf = makeOtfLookupRecord (otfClassRule->otfCount, fp);
655 }
656
657 static void loadOtfClassSet (OtfClassSetPtr otfClassSet, FILE *fp, ULONG offset)
658 {
659 int i;
660 USHORT *sOffset;
661
662 xfseek (fp, offset, SEEK_SET, "loadOtfClassSet");
663
664 otfClassSet->otfClassRuleCnt = ttfGetUSHORT (fp);
665 sOffset = ttfMakeUSHORT (otfClassSet->otfClassRuleCnt, fp);
666 otfClassSet->otfClassRule = XCALLOC (otfClassSet->otfClassRuleCnt, OtfClassRule);
667 for (i = 0; i < otfClassSet->otfClassRuleCnt; i++)
668 loadOtfClassRule (&otfClassSet->otfClassRule[i], fp, offset + sOffset[i]);
669 free (sOffset);
670 }
671
672 OtfCtx2Ptr makeOTFCtx2 (FILE *fp, ULONG offset)
673 {
674 int i;
675 USHORT cOffset;
676 USHORT clOffset;
677 USHORT *sOffset;
678 OtfCtx2Ptr otf = XCALLOC1 (OtfCtx2);
679
680 cOffset = ttfGetUSHORT (fp);
681 clOffset = ttfGetUSHORT (fp);
682 otf->otfClassSetCnt = ttfGetUSHORT (fp);
683 sOffset = ttfMakeUSHORT (otf->otfClassSetCnt, fp);
684 otf->otfClassSet = XCALLOC (otf->otfClassSetCnt, OtfClassSet);
685 otf->coverage = otfMakeCoverage (fp, offset + cOffset);
686 otf->classDef = otfMakeClassDef (fp, offset + clOffset);
687 for (i = 0; i < otf->otfClassSetCnt; i++)
688 if (sOffset[i])
689 loadOtfClassSet (&otf->otfClassSet[i], fp, offset + sOffset[i]);
690 free (sOffset);
691
692 return otf;
693 }
694
695 void printOTFCtx2 (FILE *fp, OtfCtx2Ptr otf)
696 {
697 int i;
698
699 fprintf (fp, " - Context %s Class-based\n\t ",
700 otf->lookupType == 7 ? "Positioning" : "Substitution");
701 otfPrintCoverage (fp, otf->coverage);
702 fprintf (fp, "\t ClassDef - ");
703 otfPrintClassDef (fp, otf->classDef);
704 fprintf (fp, "\t otfClassSetCnt: %d\n", otf->otfClassSetCnt);
705 for (i = 0; i < otf->otfClassSetCnt; i++) {
706 int j;
707
708 fprintf (fp, "\t %2d. otfClassRuleCnt: %d\n", i, otf->otfClassSet[i].otfClassRuleCnt);
709 for (j = 0; j < otf->otfClassSet[i].otfClassRuleCnt; j++) {
710 int k;
711
712 fprintf (fp, "\t %2d. glyphCount: %d ", j,
713 otf->otfClassSet[i].otfClassRule[j].glyphCount);
714 for (k = 0; k < otf->otfClassSet[i].otfClassRule[j].glyphCount - 1; k++)
715 fprintf (fp, k == 0 ? "- %d" : ", %d", otf->otfClassSet[i].otfClassRule[j].class[k]);
716 fprintf (fp, "\n");
717 printOtfLookupRecord (fp, " ",
718 otf->otfClassSet[i].otfClassRule[j].otfCount,
719 otf->otfClassSet[i].otfClassRule[j].otf);
720 }
721 }
722 }
723
724 void freeOTFCtx2 (OtfCtx2Ptr otf)
725 {
726 int i;
727
728 otfFreeCoverage (otf->coverage);
729 otfFreeClassDef (otf->classDef);
730 for (i = 0; i < otf->otfClassSetCnt; i++) {
731 int j;
732
733 for (j = 0; j < otf->otfClassSet[i].otfClassRuleCnt; j++) {
734 free (otf->otfClassSet[i].otfClassRule[j].class);
735 free (otf->otfClassSet[i].otfClassRule[j].otf);
736 }
737 free (otf->otfClassSet[i].otfClassRule);
738 }
739 free (otf->otfClassSet);
740 }
741
742 OtfCtx3Ptr makeOTFCtx3 (FILE *fp, ULONG offset)
743 {
744 int i;
745 USHORT *gOffset;
746 OtfCtx3Ptr otf = XCALLOC1 (OtfCtx3);
747
748 otf->glyphCount = ttfGetUSHORT (fp);
749 otf->otfCount = ttfGetUSHORT (fp);
750 gOffset = ttfMakeUSHORT (otf->glyphCount, fp);
751 otf->otf = makeOtfLookupRecord (otf->otfCount, fp);
752 otf->glyphs = XCALLOC (otf->glyphCount, CoveragePtr);
753 for (i = 0; i < otf->glyphCount; i++)
754 otf->glyphs[i] = otfMakeCoverage (fp, offset + gOffset[i]);
755 free (gOffset);
756
757 return otf;
758 }
759
760 void printOTFCtx3 (FILE *fp, OtfCtx3Ptr otf)
761 {
762 int i;
763
764 fprintf (fp, " - Context %s Coverage-based\n",
765 otf->lookupType == 7 ? "Positioning" : "Substitution");
766 fprintf (fp, "\t glyphCount: %d\n", otf->glyphCount);
767 for (i = 0; i < otf->glyphCount; i++) {
768 fprintf (fp, "\t %2d. ", i);
769 otfPrintCoverage (fp, otf->glyphs[i]);
770 }
771 printOtfLookupRecord (fp, " ", otf->otfCount, otf->otf);
772 }
773
774 void freeOTFCtx3 (OtfCtx3Ptr otf)
775 {
776 int i;
777
778 for (i = 0; i < otf->glyphCount; i++)
779 otfFreeCoverage (otf->glyphs[i]);
780 free (otf->glyphs);
781 free (otf->otf);
782 }
783
784 static void
785 loadChainOtfRule (ChainOtfRulePtr chainOtfRule, FILE *fp, ULONG offset)
786 {
787 xfseek (fp, offset, SEEK_SET, "loadChainOtfRule");
788
789 chainOtfRule->backtrackGlyphCount = ttfGetUSHORT (fp);
790 chainOtfRule->backtrack = ttfMakeUSHORT (chainOtfRule->backtrackGlyphCount, fp);
791 chainOtfRule->inputGlyphCount = ttfGetUSHORT (fp);
792 chainOtfRule->input = ttfMakeUSHORT (chainOtfRule->inputGlyphCount - 1, fp);
793 chainOtfRule->lookaheadGlyphCount = ttfGetUSHORT (fp);
794 chainOtfRule->lookahead = ttfMakeUSHORT (chainOtfRule->lookaheadGlyphCount, fp);
795 chainOtfRule->otfCount = ttfGetUSHORT (fp);
796 chainOtfRule->otf = makeOtfLookupRecord (chainOtfRule->otfCount, fp);
797 }
798
799 static void
800 loadChainOtfRuleSet (ChainOtfRuleSetPtr chainOtfRuleSet, FILE *fp, ULONG offset)
801 {
802 int i;
803 USHORT *rOffset;
804
805 xfseek (fp, offset, SEEK_SET, "loadChainOtfRuleSet");
806
807 chainOtfRuleSet->chainOtfRuleCount = ttfGetUSHORT (fp);
808 rOffset = ttfMakeUSHORT (chainOtfRuleSet->chainOtfRuleCount, fp);
809 chainOtfRuleSet->chainOtfRule = XCALLOC (chainOtfRuleSet->chainOtfRuleCount, ChainOtfRule);
810 for (i = 0; i < chainOtfRuleSet->chainOtfRuleCount; i++)
811 loadChainOtfRule (&chainOtfRuleSet->chainOtfRule[i], fp, offset + rOffset[i]);
812 free (rOffset);
813 }
814
815 OtfChn1Ptr makeOTFChn1 (FILE *fp, ULONG offset)
816 {
817 int i;
818 USHORT cOffset;
819 USHORT *rOffset;
820 OtfChn1Ptr otf = XCALLOC1 (OtfChn1);
821
822 cOffset = ttfGetUSHORT (fp);
823 otf->chainOtfRuleSetCount = ttfGetUSHORT (fp);
824 rOffset = ttfMakeUSHORT (otf->chainOtfRuleSetCount, fp);
825 otf->coverage = otfMakeCoverage (fp, offset + cOffset);
826 otf->chainOtfRuleSet = XCALLOC (otf->chainOtfRuleSetCount, ChainOtfRuleSet);
827 for (i = 0; i < otf->chainOtfRuleSetCount; i++)
828 loadChainOtfRuleSet (&otf->chainOtfRuleSet[i], fp, offset + rOffset[i]);
829 free (rOffset);
830
831 return otf;
832 }
833
834 void printOTFChn1 (FILE *fp, OtfChn1Ptr otf)
835 {
836 int i;
837
838 fprintf (fp, " - Chained Context %s Simple\n\t ",
839 otf->lookupType == 8 ? "Positioning" : "Substitution");
840 otfPrintCoverage (fp, otf->coverage);
841 fprintf (fp, "\t chainOtfRuleSetCount: %d\n", otf->chainOtfRuleSetCount);
842 for (i = 0; i < otf->chainOtfRuleSetCount; i++) {
843 int j;
844
845 fprintf (fp, "\t %2d. chainOtfRuleCount: %d\n", i,
846 otf->chainOtfRuleSet[i].chainOtfRuleCount);
847 for (j = 0; j < otf->chainOtfRuleSet[i].chainOtfRuleCount; j++) {
848 int k;
849
850 fprintf (fp, "\t %2d. backtrackGlyphCount: %d ", j,
851 otf->chainOtfRuleSet[i].chainOtfRule[j].backtrackGlyphCount);
852 for (k = 0; k < otf->chainOtfRuleSet[i].chainOtfRule[j].backtrackGlyphCount; k++)
853 fprintf (fp, k == 0 ? "- %d" : ", %d", otf->chainOtfRuleSet[i].chainOtfRule[j].backtrack[k]);
854 fprintf (fp, "\n\t\tinputGlyphCount: %d ",
855 otf->chainOtfRuleSet[i].chainOtfRule[j].inputGlyphCount);
856 for (k = 0; k < otf->chainOtfRuleSet[i].chainOtfRule[j].inputGlyphCount; k++)
857 fprintf (fp, k == 0 ? "- %d" : ", %d", otf->chainOtfRuleSet[i].chainOtfRule[j].input[k]);
858 fprintf (fp, "\n\t\tlookaheadGlyphCount: %d ",
859 otf->chainOtfRuleSet[i].chainOtfRule[j].lookaheadGlyphCount);
860 for (k = 0; k < otf->chainOtfRuleSet[i].chainOtfRule[j].lookaheadGlyphCount; k++)
861 fprintf (fp, k == 0 ? "- %d" : ", %d", otf->chainOtfRuleSet[i].chainOtfRule[j].lookahead[k]);
862 fprintf (fp, "\n");
863 printOtfLookupRecord (fp, " ",
864 otf->chainOtfRuleSet[i].chainOtfRule[j].otfCount,
865 otf->chainOtfRuleSet[i].chainOtfRule[j].otf);
866 }
867 }
868 }
869
870 void freeOTFChn1 (OtfChn1Ptr otf)
871 {
872 int i;
873
874 otfFreeCoverage (otf->coverage);
875 for (i = 0; i < otf->chainOtfRuleSetCount; i++) {
876 int j;
877
878 for (j = 0; j < otf->chainOtfRuleSet[i].chainOtfRuleCount; j++) {
879 free (otf->chainOtfRuleSet[i].chainOtfRule[j].backtrack);
880 free (otf->chainOtfRuleSet[i].chainOtfRule[j].input);
881 free (otf->chainOtfRuleSet[i].chainOtfRule[j].lookahead);
882 free (otf->chainOtfRuleSet[i].chainOtfRule[j].otf);
883 }
884 free (otf->chainOtfRuleSet[i].chainOtfRule);
885 }
886 free (otf->chainOtfRuleSet);
887 }
888
889 static void
890 loadChainOtfClassRule (ChainOtfClassRulePtr chainOtfClassRule, FILE *fp, ULONG offset)
891 {
892 xfseek (fp, offset, SEEK_SET, "loadChainOtfClassRule");
893
894 chainOtfClassRule->backtrackGlyphCount = ttfGetUSHORT (fp);
895 chainOtfClassRule->backtrack = ttfMakeUSHORT (chainOtfClassRule->backtrackGlyphCount, fp);
896 chainOtfClassRule->inputGlyphCount = ttfGetUSHORT (fp);
897 chainOtfClassRule->input = ttfMakeUSHORT (chainOtfClassRule->inputGlyphCount - 1, fp);
898 chainOtfClassRule->lookaheadGlyphCount = ttfGetUSHORT (fp);
899 chainOtfClassRule->lookahead = ttfMakeUSHORT (chainOtfClassRule->lookaheadGlyphCount, fp);
900 chainOtfClassRule->otfCount = ttfGetUSHORT (fp);
901 chainOtfClassRule->otf = makeOtfLookupRecord (chainOtfClassRule->otfCount, fp);
902 }
903
904 static void
905 loadChainOtfClassSet (ChainOtfClassSetPtr chainOtfClassSet, FILE *fp, ULONG offset)
906 {
907 int i;
908 USHORT *rOffset;
909
910 xfseek (fp, offset, SEEK_SET, "loadChainOtfClassSet");
911
912 chainOtfClassSet->chainOtfClassRuleCnt = ttfGetUSHORT (fp);
913 rOffset = ttfMakeUSHORT (chainOtfClassSet->chainOtfClassRuleCnt, fp);
914 chainOtfClassSet->chainOtfClassRule = XCALLOC (chainOtfClassSet->chainOtfClassRuleCnt, ChainOtfClassRule);
915 for (i = 0; i < chainOtfClassSet->chainOtfClassRuleCnt; i++)
916 loadChainOtfClassRule (&chainOtfClassSet->chainOtfClassRule[i], fp, offset + rOffset[i]);
917 free (rOffset);
918 }
919
920 OtfChn2Ptr makeOTFChn2 (FILE *fp, ULONG offset)
921 {
922 int i;
923 USHORT cOffset;
924 USHORT bOffset, iOffset, lOffset;
925 USHORT *sOffset;
926 OtfChn2Ptr otf = XCALLOC1 (OtfChn2);
927
928 cOffset = ttfGetUSHORT (fp);
929 bOffset = ttfGetUSHORT (fp);
930 iOffset = ttfGetUSHORT (fp);
931 lOffset = ttfGetUSHORT (fp);
932 otf->chainOtfClassSetCnt = ttfGetUSHORT (fp);
933 sOffset = ttfMakeUSHORT (otf->chainOtfClassSetCnt, fp);
934 otf->coverage = otfMakeCoverage (fp, offset + cOffset);
935 otf->backtrackClassDef = otfMakeClassDef (fp, offset + bOffset);
936 otf->inputClassDef = otfMakeClassDef (fp, offset + iOffset);
937 otf->lookaheadClassDef = otfMakeClassDef (fp, offset + lOffset);
938 otf->chainOtfClassSet = XCALLOC (otf->chainOtfClassSetCnt, ChainOtfClassSet);
939 for (i = 0; i < otf->chainOtfClassSetCnt; i++)
940 if (sOffset[i])
941 loadChainOtfClassSet (&otf->chainOtfClassSet[i], fp, offset + sOffset[i]);
942 free (sOffset);
943
944 return otf;
945 }
946
947 void printOTFChn2 (FILE *fp, OtfChn2Ptr otf)
948 {
949 int i;
950
951 fprintf (fp, " - Chained Context %s Class-based\n\t ",
952 otf->lookupType == 8 ? "Positioning" : "Substitution");
953 otfPrintCoverage (fp, otf->coverage);
954 fprintf (fp, "\t backtrackClassDef - ");
955 otfPrintClassDef (fp, otf->backtrackClassDef);
956 fprintf (fp, "\t inputClassDef - ");
957 otfPrintClassDef (fp, otf->inputClassDef);
958 fprintf (fp, "\t lookaheadClassDef - ");
959 otfPrintClassDef (fp, otf->lookaheadClassDef);
960 fprintf (fp, "\t chainOtfClassSetCnt: %d\n", otf->chainOtfClassSetCnt);
961 for (i = 0; i < otf->chainOtfClassSetCnt; i++) {
962 int j;
963
964 fprintf (fp, "\t %2d. chainOtfClassRuleCnt: %d\n", i,
965 otf->chainOtfClassSet[i].chainOtfClassRuleCnt);
966 for (j = 0; j < otf->chainOtfClassSet[i].chainOtfClassRuleCnt; j++) {
967 int k;
968
969 fprintf (fp, "\t %2d. backtrackGlyphCount: %2d ", j,
970 otf->chainOtfClassSet[i].chainOtfClassRule[j].backtrackGlyphCount);
971 for (k = 0; k < otf->chainOtfClassSet[i].chainOtfClassRule[j].backtrackGlyphCount; k++)
972 fprintf (fp, k == 0 ? "- %d" : k % 8 ? ", %d" : ",\n\t\t\t\t\t %d",
973 otf->chainOtfClassSet[i].chainOtfClassRule[j].backtrack[k]);
974 fprintf (fp, "\n\t\tinputGlyphCount: %2d ",
975 otf->chainOtfClassSet[i].chainOtfClassRule[j].inputGlyphCount);
976 for (k = 0; k < otf->chainOtfClassSet[i].chainOtfClassRule[j].inputGlyphCount; k++)
977 fprintf (fp, k == 0 ? "- %d" : k % 8 ? ", %d" : ",\n\t\t\t\t %d",
978 otf->chainOtfClassSet[i].chainOtfClassRule[j].input[k]);
979 fprintf (fp, "\n\t\tlookaheadGlyphCount: %2d ",
980 otf->chainOtfClassSet[i].chainOtfClassRule[j].lookaheadGlyphCount);
981 for (k = 0; k < otf->chainOtfClassSet[i].chainOtfClassRule[j].lookaheadGlyphCount; k++)
982 fprintf (fp, k == 0 ? "- %d" : k % 8 ? ", %d" : ",\n\t\t\t\t\t %d",
983 otf->chainOtfClassSet[i].chainOtfClassRule[j].lookahead[k]);
984 fprintf (fp, "\n");
985 printOtfLookupRecord (fp, " ",
986 otf->chainOtfClassSet[i].chainOtfClassRule[j].otfCount,
987 otf->chainOtfClassSet[i].chainOtfClassRule[j].otf);
988 }
989 }
990 }
991
992 void freeOTFChn2 (OtfChn2Ptr otf)
993 {
994 int i;
995
996 otfFreeCoverage (otf->coverage);
997 otfFreeClassDef (otf->backtrackClassDef);
998 otfFreeClassDef (otf->inputClassDef);
999 otfFreeClassDef (otf->lookaheadClassDef);
1000 for (i = 0; i < otf->chainOtfClassSetCnt; i++) {
1001 int j;
1002
1003 for (j = 0; j < otf->chainOtfClassSet[i].chainOtfClassRuleCnt; j++) {
1004 free (otf->chainOtfClassSet[i].chainOtfClassRule[j].backtrack);
1005 free (otf->chainOtfClassSet[i].chainOtfClassRule[j].input);
1006 free (otf->chainOtfClassSet[i].chainOtfClassRule[j].lookahead);
1007 free (otf->chainOtfClassSet[i].chainOtfClassRule[j].otf);
1008 }
1009 free (otf->chainOtfClassSet[i].chainOtfClassRule);
1010 }
1011 free (otf->chainOtfClassSet);
1012 }
1013
1014 OtfChn3Ptr makeOTFChn3 (FILE *fp, ULONG offset)
1015 {
1016 int i;
1017 USHORT *bOffset, *iOffset, *lOffset;
1018 OtfChn3Ptr otf = XCALLOC1 (OtfChn3);
1019
1020 otf->backtrackGlyphCount = ttfGetUSHORT (fp);
1021 bOffset = ttfMakeUSHORT (otf->backtrackGlyphCount, fp);
1022 otf->inputGlyphCount = ttfGetUSHORT (fp);
1023 iOffset = ttfMakeUSHORT (otf->inputGlyphCount, fp);
1024 otf->lookaheadGlyphCount = ttfGetUSHORT (fp);
1025 lOffset = ttfMakeUSHORT (otf->lookaheadGlyphCount, fp);
1026 otf->otfCount = ttfGetUSHORT (fp);
1027 otf->otf = makeOtfLookupRecord (otf->otfCount, fp);
1028 otf->backtrack = XCALLOC (otf->backtrackGlyphCount, CoveragePtr);
1029 for (i = 0; i < otf->backtrackGlyphCount; i++)
1030 otf->backtrack[i] = otfMakeCoverage (fp, offset + bOffset[i]);
1031 free (bOffset);
1032 otf->input = XCALLOC (otf->inputGlyphCount, CoveragePtr);
1033 for (i = 0; i < otf->inputGlyphCount; i++)
1034 otf->input[i] = otfMakeCoverage (fp, offset + iOffset[i]);
1035 free (iOffset);
1036 otf->lookahead = XCALLOC (otf->lookaheadGlyphCount, CoveragePtr);
1037 for (i = 0; i < otf->lookaheadGlyphCount; i++)
1038 otf->lookahead[i] = otfMakeCoverage (fp, offset + lOffset[i]);
1039 free (lOffset);
1040
1041 return otf;
1042 }
1043
1044 void printOTFChn3 (FILE *fp, OtfChn3Ptr otf)
1045 {
1046 int i;
1047
1048 fprintf (fp, " - Chained Context %s Coverage-based\n",
1049 otf->lookupType == 8 ? "Positioning" : "Substitution");
1050 fprintf (fp, "\t backtrackGlyphCount: %d\n", otf->backtrackGlyphCount);
1051 for (i = 0; i < otf->backtrackGlyphCount; i++) {
1052 fprintf (fp, "\t %2d. backtrack", i);
1053 otfPrintCoverage (fp, otf->backtrack[i]);
1054 }
1055 fprintf (fp, "\t inputGlyphCount: %d\n", otf->inputGlyphCount);
1056 for (i = 0; i < otf->inputGlyphCount; i++) {
1057 fprintf (fp, "\t %2d. input", i);
1058 otfPrintCoverage (fp, otf->input[i]);
1059 }
1060 fprintf (fp, "\t lookaheadGlyphCount: %d\n", otf->lookaheadGlyphCount);
1061 for (i = 0; i < otf->lookaheadGlyphCount; i++) {
1062 fprintf (fp, "\t %2d. lookahead", i);
1063 otfPrintCoverage (fp, otf->lookahead[i]);
1064 }
1065 printOtfLookupRecord (fp, " ", otf->otfCount, otf->otf);
1066 }
1067
1068 void freeOTFChn3 (OtfChn3Ptr otf)
1069 {
1070 int i;
1071
1072 for (i = 0; i < otf->backtrackGlyphCount; i++)
1073 otfFreeCoverage (otf->backtrack[i]);
1074 free (otf->backtrack);
1075 for (i = 0; i < otf->inputGlyphCount; i++)
1076 otfFreeCoverage (otf->input[i]);
1077 free (otf->input);
1078 for (i = 0; i < otf->lookaheadGlyphCount; i++)
1079 otfFreeCoverage (otf->lookahead[i]);
1080 free (otf->lookahead);
1081 free (otf->otf);
1082 }
1083