~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/opentype/disasm.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Pango
 
2
 * disasm.c: Dump OpenType layout tables
 
3
 *
 
4
 * Copyright (C) 2000 Red Hat Software
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public
 
17
 * License along with this library; if not, write to the
 
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
 * Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include <stdarg.h>
 
23
 
 
24
#include "disasm.h"
 
25
 
 
26
#define G_HAVE_GNUC_VARARGS
 
27
#ifdef G_HAVE_ISO_VARARGS
 
28
#define DUMP(...) dump (stream, indent, __VA_ARGS__)
 
29
#elif defined (G_HAVE_GNUC_VARARGS)
 
30
#define DUMP(args...) dump (stream, indent, args)
 
31
#endif
 
32
#define DUMP_FINT(strct,fld) dump (stream, indent, "<" #fld ">%d</" #fld ">\n", (strct)->fld)
 
33
#define DUMP_FUINT(strct,fld) dump (stream, indent, "<" #fld ">%u</" #fld ">\n", (strct)->fld)
 
34
#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#4x</" #fld ">\n", (strct)->fld)
 
35
 
 
36
#define DEF_DUMP(type) static void Dump_ ## type (TTO_ ## type *type, FILE *stream, int indent, FT_Bool is_gsub)
 
37
#define RECURSE(name, type, val) do {  DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, is_gsub); DUMP ("</" #name ">\n"); } while (0)
 
38
#define RECURSE_NUM(name, i, type, val) do {  DUMP ("<" #name "> <!-- %d -->\n", i); Dump_ ## type (val, stream, indent + 1, is_gsub); DUMP ("</" #name ">\n"); } while (0)
 
39
#define DUMP_VALUE_RECORD(val, frmt) do {  DUMP ("<ValueRecord>\n"); Dump_ValueRecord (val, stream, indent + 1, is_gsub, frmt); DUMP ("</ValueRecord>\n"); } while (0)
 
40
 
 
41
static void
 
42
do_indent (FILE *stream, int indent)
 
43
{
 
44
  int i;
 
45
 
 
46
  for (i = 0; i < indent * 3; i++)
 
47
    fputc (' ', stream);
 
48
}
 
49
 
 
50
static void
 
51
dump (FILE *stream, int indent, const char *format, ...)
 
52
{
 
53
  va_list list;
 
54
 
 
55
  do_indent (stream, indent);
 
56
 
 
57
  va_start (list, format);
 
58
  vfprintf (stream, format, list);
 
59
  va_end (list);
 
60
}
 
61
 
 
62
static void
 
63
Print_Tag (FT_ULong tag, FILE *stream)
 
64
{
 
65
  fprintf (stream, "%c%c%c%c",
 
66
           (unsigned char)(tag >> 24),
 
67
           (unsigned char)((tag & 0xff0000) >> 16),
 
68
           (unsigned char)((tag & 0xff00) >> 8),
 
69
           (unsigned char)(tag & 0xff));
 
70
}
 
71
 
 
72
DEF_DUMP (LangSys)
 
73
{
 
74
  int i;
 
75
 
 
76
  DUMP_FUINT (LangSys, LookupOrderOffset);
 
77
  DUMP_FUINT (LangSys, ReqFeatureIndex);
 
78
  DUMP_FUINT (LangSys, FeatureCount);
 
79
 
 
80
  for (i=0; i < LangSys->FeatureCount; i++)
 
81
    DUMP("<FeatureIndex>%d</FeatureIndex>\n", LangSys->FeatureIndex[i]);
 
82
}
 
83
 
 
84
DEF_DUMP (Script)
 
85
{
 
86
  int i;
 
87
 
 
88
  RECURSE (DefaultLangSys, LangSys, &Script->DefaultLangSys);
 
89
 
 
90
  DUMP_FUINT (Script, LangSysCount);
 
91
 
 
92
  for (i=0; i < Script->LangSysCount; i++)
 
93
    {
 
94
      do_indent (stream, indent);
 
95
      fprintf (stream, "<LangSysTag>");
 
96
      Print_Tag (Script->LangSysRecord[i].LangSysTag, stream);
 
97
      fprintf (stream, "</LangSysTag>\n");
 
98
      RECURSE_NUM (LangSys, i, LangSys, &Script->LangSysRecord[i].LangSys);
 
99
    }
 
100
}
 
101
 
 
102
DEF_DUMP (ScriptList)
 
103
{
 
104
  int i;
 
105
 
 
106
  DUMP_FUINT (ScriptList, ScriptCount);
 
107
 
 
108
  for (i=0; i < ScriptList->ScriptCount; i++)
 
109
    {
 
110
      do_indent (stream, indent);
 
111
      fprintf (stream, "<ScriptTag>");
 
112
      Print_Tag (ScriptList->ScriptRecord[i].ScriptTag, stream);
 
113
      fprintf (stream, "</ScriptTag>\n");
 
114
      RECURSE_NUM (Script, i, Script, &ScriptList->ScriptRecord[i].Script);
 
115
    }
 
116
}
 
117
 
 
118
DEF_DUMP (Feature)
 
119
{
 
120
  int i;
 
121
 
 
122
  DUMP_FUINT (Feature, FeatureParams);
 
123
  DUMP_FUINT (Feature, LookupListCount);
 
124
 
 
125
  for (i=0; i < Feature->LookupListCount; i++)
 
126
    DUMP("<LookupIndex>%d</LookupIndex>\n", Feature->LookupListIndex[i]);
 
127
}
 
128
 
 
129
DEF_DUMP (MarkArray)
 
130
{
 
131
  int i;
 
132
 
 
133
  DUMP_FUINT (MarkArray, MarkCount);
 
134
 
 
135
  for (i=0; i < MarkArray->MarkCount; i++) {
 
136
      TTO_MarkRecord *r = &MarkArray->MarkRecord[i];
 
137
      DUMP("<MarkRecord> <!-- %d -->\n", i);
 
138
      DUMP("   <Class>%d</Class>\n", r->Class );
 
139
      DUMP("   <Anchor>%d</Anchor>\n", r->MarkAnchor.PosFormat );
 
140
      DUMP("</MarkRecord>\n");
 
141
  }
 
142
}
 
143
 
 
144
DEF_DUMP (FeatureList)
 
145
{
 
146
  int i;
 
147
 
 
148
  DUMP_FUINT (FeatureList, FeatureCount);
 
149
 
 
150
  for (i=0; i < FeatureList->FeatureCount; i++)
 
151
    {
 
152
      do_indent (stream, indent);
 
153
      fprintf (stream, "<FeatureTag %d>", i);
 
154
      Print_Tag (FeatureList->FeatureRecord[i].FeatureTag, stream);
 
155
      fprintf (stream, "</FeatureTag>\n");
 
156
      RECURSE_NUM (Feature, i, Feature, &FeatureList->FeatureRecord[i].Feature);
 
157
    }
 
158
}
 
159
 
 
160
DEF_DUMP (Coverage)
 
161
{
 
162
  DUMP_FUINT (Coverage, CoverageFormat);
 
163
 
 
164
  if (Coverage->CoverageFormat == 1) {
 
165
      int i;
 
166
      DUMP_FUINT (&Coverage->cf.cf1, GlyphCount);
 
167
 
 
168
      for (i = 0; i < Coverage->cf.cf1.GlyphCount; i++)
 
169
          DUMP("<Glyph>%#4x</Glyph> <!-- %d -->\n", Coverage->cf.cf1.GlyphArray[i], i);
 
170
  } else {
 
171
      int i;
 
172
      TTO_CoverageFormat2 *cf2 = &Coverage->cf.cf2;
 
173
      for ( i = 0; i < cf2->RangeCount; i++ ) {
 
174
          DUMP("<Glyph>%4x - %4x</Glyph>\n", cf2->RangeRecord[i].Start, cf2->RangeRecord[i].End );
 
175
      }
 
176
  }
 
177
}
 
178
 
 
179
DEF_DUMP (ClassDefinition)
 
180
{
 
181
    DUMP_FUINT( ClassDefinition, ClassFormat );
 
182
    DUMP_FUINT( ClassDefinition, loaded );
 
183
 
 
184
 
 
185
    if (ClassDefinition->ClassFormat == 1) {
 
186
        int i;
 
187
        TTO_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1;
 
188
        DUMP("<ClassDefinition>\n");
 
189
        DUMP_FUINT( ClassDefFormat1, StartGlyph );
 
190
        DUMP_FUINT( ClassDefFormat1, GlyphCount );
 
191
        for ( i = 0; i < ClassDefFormat1->GlyphCount; i++ ) {
 
192
            DUMP("   <Class>%d</Class> <!-- %x -->", ClassDefFormat1->ClassValueArray[i],
 
193
                 ClassDefFormat1->StartGlyph+i );
 
194
        }
 
195
    }
 
196
    else if (ClassDefinition->ClassFormat == 2) {
 
197
        int i;
 
198
        TTO_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2;
 
199
        DUMP_FUINT (ClassDefFormat2, ClassRangeCount);
 
200
 
 
201
        for (i = 0; i < ClassDefFormat2->ClassRangeCount; i++) {
 
202
            DUMP("<ClassRangeRecord> <!-- %d -->\n",  i);
 
203
            DUMP("   <Start>%#4x</Start> \n", ClassDefFormat2->ClassRangeRecord[i].Start);
 
204
            DUMP("   <End>%#4x</End>\n", ClassDefFormat2->ClassRangeRecord[i].End);
 
205
            DUMP("   <Class>%#4x</Class>\n", ClassDefFormat2->ClassRangeRecord[i].Class);
 
206
            DUMP("</ClassRangeRecord>\n");
 
207
        }
 
208
    } else {
 
209
        printf("invalid class def table!!!\n");
 
210
    }
 
211
}
 
212
 
 
213
DEF_DUMP (ChainSubClassSet)
 
214
{
 
215
    int i;
 
216
    DUMP("<ChainSubClassSet>\n");
 
217
    DUMP_FUINT( ChainSubClassSet, ChainSubClassRuleCount );
 
218
    indent++;
 
219
    for ( i = 0; i < ChainSubClassSet->ChainSubClassRuleCount; i++ ) {
 
220
        int j;
 
221
        TTO_ChainSubClassRule *rule = &ChainSubClassSet->ChainSubClassRule[i];
 
222
        DUMP("<ChainSubClassRule> <!-- %d -->\n",  i );
 
223
        indent++;
 
224
        DUMP("<Backtrack> <!-- %d -->\n", rule->BacktrackGlyphCount );
 
225
        for ( j = 0; j <  rule->BacktrackGlyphCount; j++ )
 
226
            DUMP("   %d\n", (int)(FT_UShort) rule->Backtrack[j] );
 
227
        DUMP("</Backtrack>\n");
 
228
        DUMP("<Input> <!-- %d -->\n", rule->InputGlyphCount );
 
229
        for ( j = 0; j <  rule->InputGlyphCount-1; j++ )
 
230
            DUMP("   %d\n", (int)(FT_UShort) rule->Input[j] );
 
231
        DUMP("</Input>\n");
 
232
        DUMP("<Lookahead> <!-- %d -->\n", rule->LookaheadGlyphCount );
 
233
        for ( j = 0; j <  rule->LookaheadGlyphCount; j++ )
 
234
            DUMP("   %d\n", (int) (FT_UShort) rule->Lookahead[j] );
 
235
        DUMP("</Lookahead>\n");
 
236
        for ( j = 0; j < rule->SubstCount; j++ ) {
 
237
            TTO_SubstLookupRecord *r = &rule->SubstLookupRecord[j];
 
238
            DUMP("<SubstLookupRecord> <!-- %d -->\n",  j);
 
239
            indent++;
 
240
            DUMP_FUINT( r, SequenceIndex );
 
241
            DUMP_FUINT( r, LookupListIndex );
 
242
            indent--;
 
243
            DUMP("</SubstLookupRecord>\n");
 
244
        }
 
245
        indent--;
 
246
        DUMP("</ChainSubClassRule>\n");
 
247
    }
 
248
    indent--;
 
249
    DUMP("</ChainSubClassSet>\n");
 
250
}
 
251
 
 
252
 
 
253
static void
 
254
Dump_GSUB_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
 
255
{
 
256
  TTO_SingleSubst *SingleSubst = &subtable->st.gsub.single;
 
257
 
 
258
  DUMP_FUINT (SingleSubst, SubstFormat);
 
259
  RECURSE (Coverage, Coverage, &SingleSubst->Coverage);
 
260
 
 
261
  if (SingleSubst->SubstFormat == 1)
 
262
    {
 
263
      DUMP_FINT (&SingleSubst->ssf.ssf1, DeltaGlyphID);
 
264
    }
 
265
  else
 
266
    {
 
267
      int i;
 
268
 
 
269
      DUMP_FINT (&SingleSubst->ssf.ssf2, GlyphCount);
 
270
      for (i=0; i < SingleSubst->ssf.ssf2.GlyphCount; i++)
 
271
        DUMP("<Substitute>%#4x</Substitute> <!-- %d -->\n", SingleSubst->ssf.ssf2.Substitute[i], i);
 
272
    }
 
273
}
 
274
 
 
275
DEF_DUMP (Ligature)
 
276
{
 
277
  int i;
 
278
 
 
279
  DUMP_FGLYPH (Ligature, LigGlyph);
 
280
  DUMP_FUINT (Ligature, ComponentCount);
 
281
 
 
282
  for (i=0; i < Ligature->ComponentCount - 1; i++)
 
283
    DUMP("<Component>%#4x</Component>\n", Ligature->Component[i]);
 
284
}
 
285
 
 
286
DEF_DUMP (LigatureSet)
 
287
{
 
288
  int i;
 
289
 
 
290
  DUMP_FUINT (LigatureSet, LigatureCount);
 
291
 
 
292
  for (i=0; i < LigatureSet->LigatureCount; i++)
 
293
    RECURSE_NUM (Ligature, i, Ligature, &LigatureSet->Ligature[i]);
 
294
}
 
295
 
 
296
static void
 
297
Dump_GSUB_Lookup_Ligature (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
 
298
{
 
299
  int i;
 
300
  TTO_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature;
 
301
 
 
302
  DUMP_FUINT (LigatureSubst, SubstFormat);
 
303
  RECURSE (Coverage, Coverage, &LigatureSubst->Coverage);
 
304
 
 
305
  DUMP_FUINT (LigatureSubst, LigatureSetCount);
 
306
 
 
307
  for (i=0; i < LigatureSubst->LigatureSetCount; i++)
 
308
    RECURSE_NUM (LigatureSet, i, LigatureSet, &LigatureSubst->LigatureSet[i]);
 
309
}
 
310
 
 
311
static void
 
312
Dump_GSUB_Lookup_ContextSubst1 (TTO_ContextSubstFormat1 *csf, FILE *stream, int indent, FT_Bool is_gsub)
 
313
{
 
314
    DUMP("Not implemented!!!\n");
 
315
}
 
316
 
 
317
 
 
318
static void
 
319
Dump_GSUB_Lookup_ContextSubst2 (TTO_ContextSubstFormat2 *csf, FILE *stream, int indent, FT_Bool is_gsub)
 
320
{
 
321
    DUMP_FUINT( csf, MaxContextLength );
 
322
    RECURSE (Coverage, Coverage, &csf->Coverage);
 
323
    RECURSE( ClassDefinition, ClassDefinition, &csf->ClassDef );
 
324
}
 
325
 
 
326
static void
 
327
Dump_GSUB_Lookup_ContextSubst3 (TTO_ContextSubstFormat3 *csf, FILE *stream, int indent, FT_Bool is_gsub)
 
328
{
 
329
    DUMP("Not implemented!!!\n");
 
330
}
 
331
 
 
332
static void
 
333
Dump_GSUB_Lookup_Context (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
 
334
{
 
335
  int i;
 
336
  TTO_ContextSubst *ContextSubst = &subtable->st.gsub.context;
 
337
 
 
338
  DUMP_FUINT (ContextSubst, SubstFormat);
 
339
  switch( ContextSubst->SubstFormat ) {
 
340
  case 1:
 
341
      Dump_GSUB_Lookup_ContextSubst1 (&ContextSubst->csf.csf1, stream, indent+2, is_gsub);
 
342
      break;
 
343
  case 2:
 
344
      Dump_GSUB_Lookup_ContextSubst2 (&ContextSubst->csf.csf2, stream, indent+2, is_gsub);
 
345
      break;
 
346
  case 3:
 
347
      Dump_GSUB_Lookup_ContextSubst3 (&ContextSubst->csf.csf3, stream, indent+2, is_gsub);
 
348
      break;
 
349
  default:
 
350
      printf("invalid subformat!!!!!\n");
 
351
  }
 
352
}
 
353
 
 
354
static void
 
355
Dump_GSUB_Lookup_ChainSubst1 (TTO_ChainContextSubstFormat1 *csf, FILE *stream, int indent, FT_Bool is_gsub)
 
356
{
 
357
    DUMP("Not implemented!!!\n");
 
358
}
 
359
static void
 
360
Dump_GSUB_Lookup_ChainSubst2 (TTO_ChainContextSubstFormat2 *csf, FILE *stream, int indent, FT_Bool is_gsub)
 
361
{
 
362
    int i;
 
363
    RECURSE (Coverage, Coverage, &csf->Coverage);
 
364
    DUMP_FUINT( csf, MaxBacktrackLength );
 
365
    RECURSE( ClassDefinition, ClassDefinition, &csf->BacktrackClassDef );
 
366
    DUMP_FUINT( csf, MaxInputLength );
 
367
    RECURSE( ClassDefinition, ClassDefinition, &csf->InputClassDef );
 
368
    DUMP_FUINT( csf, MaxLookaheadLength );
 
369
    RECURSE( ClassDefinition, ClassDefinition, &csf->LookaheadClassDef );
 
370
 
 
371
    DUMP_FUINT( csf, ChainSubClassSetCount );
 
372
    for ( i = 0; i < csf->ChainSubClassSetCount; i++ )
 
373
        RECURSE( ChainSubClassSet, ChainSubClassSet, &csf->ChainSubClassSet[i] );
 
374
}
 
375
static void
 
376
Dump_GSUB_Lookup_ChainSubst3 (TTO_ChainContextSubstFormat3 *csf, FILE *stream, int indent, FT_Bool is_gsub)
 
377
{
 
378
    DUMP("Not implemented!!!\n");
 
379
}
 
380
 
 
381
static void
 
382
Dump_GSUB_Lookup_Chain (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
 
383
{
 
384
  int i;
 
385
  TTO_ChainContextSubst *chain = &subtable->st.gsub.chain;
 
386
 
 
387
  DUMP_FUINT (chain, SubstFormat);
 
388
  switch( chain->SubstFormat ) {
 
389
  case 1:
 
390
      Dump_GSUB_Lookup_ChainSubst1 (&chain->ccsf.ccsf1, stream, indent+2, is_gsub);
 
391
      break;
 
392
  case 2:
 
393
      Dump_GSUB_Lookup_ChainSubst2 (&chain->ccsf.ccsf2, stream, indent+2, is_gsub);
 
394
      break;
 
395
  case 3:
 
396
      Dump_GSUB_Lookup_ChainSubst3 (&chain->ccsf.ccsf3, stream, indent+2, is_gsub);
 
397
      break;
 
398
  default:
 
399
      printf("invalid subformat!!!!!\n");
 
400
  }
 
401
}
 
402
 
 
403
 
 
404
static void
 
405
Dump_Device (TTO_Device *Device, FILE *stream, int indent, FT_Bool is_gsub)
 
406
{
 
407
  int i;
 
408
  int bits = 0;
 
409
  int n_per;
 
410
  unsigned int mask;
 
411
 
 
412
  DUMP_FUINT (Device, StartSize);
 
413
  DUMP_FUINT (Device, EndSize);
 
414
  DUMP_FUINT (Device, DeltaFormat);
 
415
  switch (Device->DeltaFormat)
 
416
    {
 
417
    case 1:
 
418
      bits = 2;
 
419
      break;
 
420
    case 2:
 
421
      bits = 4;
 
422
      break;
 
423
    case 3:
 
424
      bits = 8;
 
425
      break;
 
426
    }
 
427
 
 
428
  n_per = 16 / bits;
 
429
  mask = (1 << bits) - 1;
 
430
  mask = mask << (16 - bits);
 
431
 
 
432
  DUMP ("<DeltaValue>");
 
433
  for (i = Device->StartSize; i <= Device->EndSize ; i++)
 
434
    {
 
435
      FT_UShort val = Device->DeltaValue[i / n_per];
 
436
      FT_Short signed_val = ((val << ((i % n_per) * bits)) & mask);
 
437
      dump (stream, indent, "%d", signed_val >> (16 - bits));
 
438
      if (i != Device->EndSize)
 
439
        DUMP (", ");
 
440
    }
 
441
  DUMP ("</DeltaValue>\n");
 
442
}
 
443
 
 
444
static void
 
445
Dump_ValueRecord (TTO_ValueRecord *ValueRecord, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort value_format)
 
446
{
 
447
  if (value_format & HAVE_X_PLACEMENT)
 
448
    DUMP_FINT (ValueRecord, XPlacement);
 
449
  if (value_format & HAVE_Y_PLACEMENT)
 
450
    DUMP_FINT (ValueRecord, YPlacement);
 
451
  if (value_format & HAVE_X_ADVANCE)
 
452
    DUMP_FINT (ValueRecord, XAdvance);
 
453
  if (value_format & HAVE_Y_ADVANCE)
 
454
    DUMP_FINT (ValueRecord, XAdvance);
 
455
  if (value_format & HAVE_X_PLACEMENT_DEVICE)
 
456
    RECURSE (Device, Device, &ValueRecord->XPlacementDevice);
 
457
  if (value_format & HAVE_Y_PLACEMENT_DEVICE)
 
458
    RECURSE (Device, Device, &ValueRecord->YPlacementDevice);
 
459
  if (value_format & HAVE_X_ADVANCE_DEVICE)
 
460
    RECURSE (Device, Device, &ValueRecord->XAdvanceDevice);
 
461
  if (value_format & HAVE_Y_ADVANCE_DEVICE)
 
462
    RECURSE (Device, Device, &ValueRecord->YAdvanceDevice);
 
463
  if (value_format & HAVE_X_ID_PLACEMENT)
 
464
    DUMP_FUINT (ValueRecord, XIdPlacement);
 
465
  if (value_format & HAVE_Y_ID_PLACEMENT)
 
466
    DUMP_FUINT (ValueRecord, YIdPlacement);
 
467
  if (value_format & HAVE_X_ID_ADVANCE)
 
468
    DUMP_FUINT (ValueRecord, XIdAdvance);
 
469
  if (value_format & HAVE_Y_ID_ADVANCE)
 
470
    DUMP_FUINT (ValueRecord, XIdAdvance);
 
471
}
 
472
 
 
473
static void
 
474
Dump_GPOS_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
 
475
{
 
476
  TTO_SinglePos *SinglePos = &subtable->st.gpos.single;
 
477
 
 
478
  DUMP_FUINT (SinglePos, PosFormat);
 
479
  RECURSE (Coverage, Coverage, &SinglePos->Coverage);
 
480
 
 
481
  DUMP_FUINT (SinglePos, ValueFormat);
 
482
 
 
483
  if (SinglePos->PosFormat == 1)
 
484
    {
 
485
      DUMP_VALUE_RECORD (&SinglePos->spf.spf1.Value, SinglePos->ValueFormat);
 
486
    }
 
487
  else
 
488
    {
 
489
      int i;
 
490
 
 
491
      DUMP_FUINT (&SinglePos->spf.spf2, ValueCount);
 
492
      for (i = 0; i < SinglePos->spf.spf2.ValueCount; i++)
 
493
        DUMP_VALUE_RECORD (&SinglePos->spf.spf2.Value[i], SinglePos->ValueFormat);
 
494
    }
 
495
}
 
496
 
 
497
static void
 
498
Dump_PairValueRecord (TTO_PairValueRecord *PairValueRecord, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort ValueFormat1, FT_UShort ValueFormat2)
 
499
{
 
500
  DUMP_FUINT (PairValueRecord, SecondGlyph);
 
501
  DUMP_VALUE_RECORD (&PairValueRecord->Value1, ValueFormat1);
 
502
  DUMP_VALUE_RECORD (&PairValueRecord->Value2, ValueFormat2);
 
503
}
 
504
 
 
505
static void
 
506
Dump_PairSet (TTO_PairSet *PairSet, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort ValueFormat1, FT_UShort ValueFormat2)
 
507
{
 
508
  int i;
 
509
  DUMP_FUINT (PairSet, PairValueCount);
 
510
 
 
511
  for (i = 0; i < PairSet->PairValueCount; i++)
 
512
    {
 
513
      DUMP ("<PairValueRecord>\n");
 
514
      Dump_PairValueRecord (&PairSet->PairValueRecord[i], stream, indent + 1, is_gsub, ValueFormat1, ValueFormat2);
 
515
      DUMP ("</PairValueRecord>\n");
 
516
    }
 
517
}
 
518
 
 
519
static void
 
520
Dump_GPOS_Lookup_Pair (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
 
521
{
 
522
  TTO_PairPos *PairPos = &subtable->st.gpos.pair;
 
523
 
 
524
  DUMP_FUINT (PairPos, PosFormat);
 
525
  RECURSE (Coverage, Coverage, &PairPos->Coverage);
 
526
 
 
527
  DUMP_FUINT (PairPos, ValueFormat1);
 
528
  DUMP_FUINT (PairPos, ValueFormat2);
 
529
 
 
530
  if (PairPos->PosFormat == 1)
 
531
    {
 
532
      int i;
 
533
 
 
534
      DUMP_FUINT (&PairPos->ppf.ppf1, PairSetCount);
 
535
      for (i = 0; i < PairPos->ppf.ppf1.PairSetCount; i++)
 
536
        {
 
537
          DUMP ("<PairSet>\n");
 
538
          Dump_PairSet (&PairPos->ppf.ppf1.PairSet[i], stream, indent + 1, is_gsub, PairPos->ValueFormat1, PairPos->ValueFormat2);
 
539
          DUMP ("</PairSet>\n");
 
540
        }
 
541
    }
 
542
  else
 
543
    {
 
544
    }
 
545
}
 
546
 
 
547
static void
 
548
Dump_GPOS_Lookup_Markbase (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
 
549
{
 
550
    int i;
 
551
    TTO_MarkBasePos *markbase = &subtable->st.gpos.markbase;
 
552
 
 
553
    DUMP_FUINT( markbase, PosFormat );
 
554
    RECURSE( Coverage, Coverage, &markbase->MarkCoverage );
 
555
    RECURSE( Coverage, Coverage, &markbase->BaseCoverage );
 
556
    DUMP_FUINT( markbase, ClassCount );
 
557
    RECURSE( MarkArray, MarkArray, &markbase->MarkArray );
 
558
 
 
559
    DUMP("<BaseArray>\n");
 
560
    indent++;
 
561
    for ( i = 0; i < markbase->BaseArray.BaseCount; i++ ) {
 
562
        int j;
 
563
        TTO_BaseRecord *r = &markbase->BaseArray.BaseRecord[i];
 
564
        DUMP("<BaseRecord> <!-- %d -->\n",  i);
 
565
        for ( j = 0; j < markbase->ClassCount; j++ ) {
 
566
            DUMP("   <Anchor>%d</Anchor>\n", r->BaseAnchor->PosFormat );
 
567
        }
 
568
        DUMP("<BaseRecord>\n" );
 
569
    }
 
570
    indent--;
 
571
    DUMP("</BaseArray>\n");
 
572
}
 
573
 
 
574
 
 
575
DEF_DUMP (Lookup)
 
576
{
 
577
  int i;
 
578
  const char *lookup_name = NULL;
 
579
  void (*lookup_func) (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) = NULL;
 
580
 
 
581
  if (is_gsub)
 
582
    {
 
583
      switch (Lookup->LookupType)
 
584
        {
 
585
        case  GSUB_LOOKUP_SINGLE:
 
586
          lookup_name = "SINGLE";
 
587
          lookup_func = Dump_GSUB_Lookup_Single;
 
588
          break;
 
589
        case  GSUB_LOOKUP_MULTIPLE:
 
590
          lookup_name = "MULTIPLE";
 
591
          break;
 
592
        case  GSUB_LOOKUP_ALTERNATE:
 
593
          lookup_name = "ALTERNATE";
 
594
          break;
 
595
        case  GSUB_LOOKUP_LIGATURE:
 
596
          lookup_name = "LIGATURE";
 
597
          lookup_func = Dump_GSUB_Lookup_Ligature;
 
598
          break;
 
599
        case  GSUB_LOOKUP_CONTEXT:
 
600
          lookup_name = "CONTEXT";
 
601
          lookup_func = Dump_GSUB_Lookup_Context;
 
602
          break;
 
603
        case  GSUB_LOOKUP_CHAIN:
 
604
          lookup_name = "CHAIN";
 
605
          lookup_func = Dump_GSUB_Lookup_Chain;
 
606
          break;
 
607
        }
 
608
    }
 
609
  else
 
610
    {
 
611
      switch (Lookup->LookupType)
 
612
        {
 
613
        case GPOS_LOOKUP_SINGLE:
 
614
          lookup_name = "SINGLE";
 
615
          lookup_func = Dump_GPOS_Lookup_Single;
 
616
          break;
 
617
        case GPOS_LOOKUP_PAIR:
 
618
          lookup_name = "PAIR";
 
619
          lookup_func = Dump_GPOS_Lookup_Pair;
 
620
          break;
 
621
        case GPOS_LOOKUP_CURSIVE:
 
622
          lookup_name = "CURSIVE";
 
623
          break;
 
624
        case GPOS_LOOKUP_MARKBASE:
 
625
          lookup_name = "MARKBASE";
 
626
          lookup_func = Dump_GPOS_Lookup_Markbase;
 
627
          break;
 
628
        case GPOS_LOOKUP_MARKLIG:
 
629
          lookup_name = "MARKLIG";
 
630
          break;
 
631
        case GPOS_LOOKUP_MARKMARK:
 
632
          lookup_name = "MARKMARK";
 
633
          lookup_func = Dump_GPOS_Lookup_Markbase;
 
634
          break;
 
635
        case GPOS_LOOKUP_CONTEXT:
 
636
          lookup_name = "CONTEXT";
 
637
          break;
 
638
        case GPOS_LOOKUP_CHAIN:
 
639
          lookup_name = "CHAIN";
 
640
          break;
 
641
        }
 
642
    }
 
643
 
 
644
  DUMP("<LookupType>%s</LookupType>\n", lookup_name);
 
645
 
 
646
  for (i=0; i < Lookup->SubTableCount; i++)
 
647
    {
 
648
      DUMP ("<Subtable>\n");
 
649
      if (lookup_func)
 
650
        (*lookup_func) (&Lookup->SubTable[i], stream, indent + 1, is_gsub);
 
651
      DUMP ("</Subtable>\n");
 
652
    }
 
653
}
 
654
 
 
655
DEF_DUMP (LookupList)
 
656
{
 
657
  int i;
 
658
 
 
659
  DUMP_FUINT (LookupList, LookupCount);
 
660
 
 
661
  for (i=0; i < LookupList->LookupCount; i++)
 
662
    RECURSE_NUM (Lookup, i, Lookup, &LookupList->Lookup[i]);
 
663
}
 
664
 
 
665
void
 
666
TT_Dump_GSUB_Table (TTO_GSUB gsub, FILE *stream)
 
667
{
 
668
  int indent = 0;
 
669
  FT_Bool is_gsub = 1;
 
670
 
 
671
  RECURSE (ScriptList, ScriptList, &gsub->ScriptList);
 
672
  RECURSE (FeatureList, FeatureList, &gsub->FeatureList);
 
673
  RECURSE (LookupList, LookupList, &gsub->LookupList);
 
674
}
 
675
 
 
676
void
 
677
TT_Dump_GPOS_Table (TTO_GPOS gpos, FILE *stream)
 
678
{
 
679
  int indent = 0;
 
680
  FT_Bool is_gsub = 0;
 
681
 
 
682
  RECURSE (ScriptList, ScriptList, &gpos->ScriptList);
 
683
  RECURSE (FeatureList, FeatureList, &gpos->FeatureList);
 
684
  RECURSE (LookupList, LookupList, &gpos->LookupList);
 
685
}