blob: 86116647478a1abac40ca3e5e1acfdda247d8292 [file] [log] [blame]
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00001/*
2 * Copyright (C) 2000, 2007 Red Hat, Inc.
Owen Taylor80a15822000-12-20 04:41:36 +00003 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00004 * This is part of HarfBuzz, an OpenType Layout engine library.
Owen Taylor80a15822000-12-20 04:41:36 +00005 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00006 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
Owen Taylor80a15822000-12-20 04:41:36 +000011 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000012 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
Owen Taylor80a15822000-12-20 04:41:36 +000017 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000018 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
Owen Taylor80a15822000-12-20 04:41:36 +000025 */
26
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000027#include "harfbuzz-impl.h"
28#include "harfbuzz-dump.h"
29#include "harfbuzz-gdef-private.h"
30#include "harfbuzz-gsub-private.h"
31#include "harfbuzz-gpos-private.h"
32#include "harfbuzz-open-private.h"
Owen Taylor80a15822000-12-20 04:41:36 +000033#include <stdarg.h>
34
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000035#define DUMP(format) dump (stream, indent, format)
36#define DUMP1(format, arg1) dump (stream, indent, format, arg1)
37#define DUMP2(format, arg1, arg2) dump (stream, indent, format, arg1, arg2)
38#define DUMP3(format, arg1, arg2, arg3) dump (stream, indent, format, arg1, arg2, arg3)
Owen Taylor80a15822000-12-20 04:41:36 +000039
Owen Taylor80a15822000-12-20 04:41:36 +000040#define DUMP_FINT(strct,fld) dump (stream, indent, "<" #fld ">%d</" #fld ">\n", (strct)->fld)
41#define DUMP_FUINT(strct,fld) dump (stream, indent, "<" #fld ">%u</" #fld ">\n", (strct)->fld)
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +000042#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)
43#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)
44#define DUMP_USHORT_ARRAY(strct,fld,cnt) Dump_UShort_Array ((strct)->fld, cnt, #fld, stream, indent);
Owen Taylor80a15822000-12-20 04:41:36 +000045
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000046#define DEF_DUMP(type) static void Dump_ ## type (HB_ ## type *type, FILE *stream, int indent, HB_Type hb_type)
47#define RECURSE(name, type, val) do { DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)
48#define RECURSE_NUM(name, i, type, val) do { DUMP1 ("<" #name "> <!-- %d -->\n", i); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)
49#define DUMP_VALUE_RECORD(val, frmt) do { DUMP ("<ValueRecord>\n"); Dump_ValueRecord (val, stream, indent + 1, hb_type, frmt); DUMP ("</ValueRecord>\n"); } while (0)
Owen Taylor80a15822000-12-20 04:41:36 +000050
51static void
52do_indent (FILE *stream, int indent)
53{
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +000054 fprintf (stream, "%*s", indent * 3, "");
Owen Taylor80a15822000-12-20 04:41:36 +000055}
56
Behdad Esfahbod549be922008-12-26 02:31:47 +000057#if __GNUC__ >= 3
58__attribute__((__format__(__printf__, 3, 4)))
59#endif
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +000060static void
61dump (FILE *stream, int indent, const char *format, ...)
Owen Taylor80a15822000-12-20 04:41:36 +000062{
63 va_list list;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +000064
Owen Taylor80a15822000-12-20 04:41:36 +000065 do_indent (stream, indent);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +000066
Owen Taylor80a15822000-12-20 04:41:36 +000067 va_start (list, format);
68 vfprintf (stream, format, list);
69 va_end (list);
70}
71
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +000072static void
Behdad Esfahbod5716ae22007-10-24 22:44:47 +000073Dump_UShort_Array (HB_UShort *array, int count, const char *name, FILE *stream, int indent)
Owen Taylor378e1882003-07-26 02:10:42 +000074{
75 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +000076
Owen Taylor378e1882003-07-26 02:10:42 +000077 do_indent (stream, indent);
78
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +000079 fprintf (stream, "<%s>", name);
Owen Taylor378e1882003-07-26 02:10:42 +000080 for (i = 0; i < count; i++)
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +000081 fprintf (stream, "%d%s", array[i], i == 0 ? "" : " ");
82 fprintf (stream, "</%s>\n", name);
Owen Taylor378e1882003-07-26 02:10:42 +000083}
84
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +000085static void
Behdad Esfahbod5716ae22007-10-24 22:44:47 +000086Print_Tag (HB_UInt tag, FILE *stream)
Owen Taylor80a15822000-12-20 04:41:36 +000087{
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +000088 fprintf (stream, "%c%c%c%c",
Owen Taylor80a15822000-12-20 04:41:36 +000089 (unsigned char)(tag >> 24),
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +000090 (unsigned char)((tag >> 16) & 0xff),
91 (unsigned char)((tag >> 8) & 0xff),
Owen Taylor80a15822000-12-20 04:41:36 +000092 (unsigned char)(tag & 0xff));
93}
94
95DEF_DUMP (LangSys)
96{
97 int i;
98
Behdad Esfahbod4280ec42007-10-25 00:23:46 +000099 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000100
Owen Taylor80a15822000-12-20 04:41:36 +0000101 DUMP_FUINT (LangSys, LookupOrderOffset);
102 DUMP_FUINT (LangSys, ReqFeatureIndex);
103 DUMP_FUINT (LangSys, FeatureCount);
104
105 for (i=0; i < LangSys->FeatureCount; i++)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000106 DUMP1("<FeatureIndex>%d</FeatureIndex>\n", LangSys->FeatureIndex[i]);
Owen Taylor80a15822000-12-20 04:41:36 +0000107}
108
Behdad Esfahbod282c60a2007-10-25 23:22:17 +0000109DEF_DUMP (ScriptTable)
Owen Taylor80a15822000-12-20 04:41:36 +0000110{
111 int i;
112
Behdad Esfahbod282c60a2007-10-25 23:22:17 +0000113 RECURSE (DefaultLangSys, LangSys, &ScriptTable->DefaultLangSys);
Owen Taylor80a15822000-12-20 04:41:36 +0000114
Behdad Esfahbod282c60a2007-10-25 23:22:17 +0000115 DUMP_FUINT (ScriptTable, LangSysCount);
Owen Taylor80a15822000-12-20 04:41:36 +0000116
Behdad Esfahbod282c60a2007-10-25 23:22:17 +0000117 for (i=0; i < ScriptTable->LangSysCount; i++)
Owen Taylor80a15822000-12-20 04:41:36 +0000118 {
119 do_indent (stream, indent);
120 fprintf (stream, "<LangSysTag>");
Behdad Esfahbod282c60a2007-10-25 23:22:17 +0000121 Print_Tag (ScriptTable->LangSysRecord[i].LangSysTag, stream);
Owen Taylor80a15822000-12-20 04:41:36 +0000122 fprintf (stream, "</LangSysTag>\n");
Behdad Esfahbod282c60a2007-10-25 23:22:17 +0000123 RECURSE_NUM (LangSys, i, LangSys, &ScriptTable->LangSysRecord[i].LangSys);
Owen Taylor80a15822000-12-20 04:41:36 +0000124 }
125}
126
127DEF_DUMP (ScriptList)
128{
129 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000130
Owen Taylor80a15822000-12-20 04:41:36 +0000131 DUMP_FUINT (ScriptList, ScriptCount);
132
133 for (i=0; i < ScriptList->ScriptCount; i++)
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000134 {
Owen Taylor80a15822000-12-20 04:41:36 +0000135 do_indent (stream, indent);
136 fprintf (stream, "<ScriptTag>");
137 Print_Tag (ScriptList->ScriptRecord[i].ScriptTag, stream);
138 fprintf (stream, "</ScriptTag>\n");
Behdad Esfahbod282c60a2007-10-25 23:22:17 +0000139 RECURSE_NUM (Script, i, ScriptTable, &ScriptList->ScriptRecord[i].Script);
Owen Taylor80a15822000-12-20 04:41:36 +0000140 }
141}
142
143DEF_DUMP (Feature)
144{
145 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000146
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000147 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000148
Owen Taylor80a15822000-12-20 04:41:36 +0000149 DUMP_FUINT (Feature, FeatureParams);
150 DUMP_FUINT (Feature, LookupListCount);
151
152 for (i=0; i < Feature->LookupListCount; i++)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000153 DUMP1("<LookupIndex>%d</LookupIndex>\n", Feature->LookupListIndex[i]);
Owen Taylor80a15822000-12-20 04:41:36 +0000154}
155
Owen Taylor378e1882003-07-26 02:10:42 +0000156DEF_DUMP (MarkRecord)
157{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000158 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000159
Owen Taylor378e1882003-07-26 02:10:42 +0000160 DUMP_FUINT (MarkRecord, Class);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000161 DUMP1("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );
Owen Taylor378e1882003-07-26 02:10:42 +0000162}
163
164DEF_DUMP (MarkArray)
165{
166 int i;
167
168 DUMP_FUINT (MarkArray, MarkCount);
169
170 for (i=0; i < MarkArray->MarkCount; i++)
171 RECURSE_NUM (MarkRecord, i, MarkRecord, &MarkArray->MarkRecord[i]);
172}
173
Owen Taylor80a15822000-12-20 04:41:36 +0000174DEF_DUMP (FeatureList)
175{
176 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000177
Owen Taylor80a15822000-12-20 04:41:36 +0000178 DUMP_FUINT (FeatureList, FeatureCount);
179
180 for (i=0; i < FeatureList->FeatureCount; i++)
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000181 {
Owen Taylor80a15822000-12-20 04:41:36 +0000182 do_indent (stream, indent);
183 fprintf (stream, "<FeatureTag>");
184 Print_Tag (FeatureList->FeatureRecord[i].FeatureTag, stream);
Owen Taylor378e1882003-07-26 02:10:42 +0000185 fprintf (stream, "</FeatureTag> <!-- %d -->\n", i);
186 RECURSE_NUM (Feature, i, Feature, &FeatureList->FeatureRecord[i].Feature);
Owen Taylor80a15822000-12-20 04:41:36 +0000187 }
188}
189
190DEF_DUMP (Coverage)
191{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000192 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000193
Owen Taylor80a15822000-12-20 04:41:36 +0000194 DUMP_FUINT (Coverage, CoverageFormat);
195
196 if (Coverage->CoverageFormat == 1)
197 {
198 int i;
199 DUMP_FUINT (&Coverage->cf.cf1, GlyphCount);
200
201 for (i = 0; i < Coverage->cf.cf1.GlyphCount; i++)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000202 DUMP2("<Glyph>%#06x</Glyph> <!-- %d -->\n",
203 Coverage->cf.cf1.GlyphArray[i], i);
Owen Taylor80a15822000-12-20 04:41:36 +0000204 }
205 else
206 {
Owen Taylor378e1882003-07-26 02:10:42 +0000207 int i;
208 DUMP_FUINT (&Coverage->cf.cf2, RangeCount);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000209
Owen Taylor378e1882003-07-26 02:10:42 +0000210 for ( i = 0; i < Coverage->cf.cf2.RangeCount; i++ )
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000211 DUMP3("<Glyph>%#06x - %#06x</Glyph> <!-- %d -->\n",
212 Coverage->cf.cf2.RangeRecord[i].Start,
213 Coverage->cf.cf2.RangeRecord[i].End, i);
Owen Taylor80a15822000-12-20 04:41:36 +0000214 }
215}
216
Owen Taylor378e1882003-07-26 02:10:42 +0000217DEF_DUMP (ClassRangeRecord)
218{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000219 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000220
Owen Taylor378e1882003-07-26 02:10:42 +0000221 DUMP_FGLYPH (ClassRangeRecord, Start);
222 DUMP_FGLYPH (ClassRangeRecord, End);
223 DUMP_FUINT (ClassRangeRecord, Class);
224}
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000225
Owen Taylor378e1882003-07-26 02:10:42 +0000226DEF_DUMP (ClassDefinition)
227{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000228 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000229
Owen Taylor378e1882003-07-26 02:10:42 +0000230 DUMP_FUINT( ClassDefinition, ClassFormat);
231 DUMP_FUINT( ClassDefinition, loaded);
232
233 if (ClassDefinition->ClassFormat == 1)
234 {
235 int i;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000236 HB_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1;
Owen Taylor378e1882003-07-26 02:10:42 +0000237 DUMP("<ClassDefinition>\n");
238 DUMP_FUINT (ClassDefFormat1, StartGlyph );
239 DUMP_FUINT (ClassDefFormat1, GlyphCount );
240 for (i = 0; i < ClassDefFormat1->GlyphCount; i++)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000241 DUMP2(" <Class>%d</Class> <!-- %#06x -->", ClassDefFormat1->ClassValueArray[i],
242 ClassDefFormat1->StartGlyph+i );
Owen Taylor378e1882003-07-26 02:10:42 +0000243 }
244 else if (ClassDefinition->ClassFormat == 2)
245 {
246 int i;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000247 HB_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2;
Owen Taylor378e1882003-07-26 02:10:42 +0000248 DUMP_FUINT (ClassDefFormat2, ClassRangeCount);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000249
Owen Taylor378e1882003-07-26 02:10:42 +0000250 for (i = 0; i < ClassDefFormat2->ClassRangeCount; i++)
251 RECURSE_NUM (ClassRangeRecord, i, ClassRangeRecord, &ClassDefFormat2->ClassRangeRecord[i]);
252 }
253 else
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000254 fprintf(stderr, "invalid class def table!!!\n");
Owen Taylor378e1882003-07-26 02:10:42 +0000255}
256
257DEF_DUMP (SubstLookupRecord)
258{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000259 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000260
Owen Taylor378e1882003-07-26 02:10:42 +0000261 DUMP_FUINT (SubstLookupRecord, SequenceIndex);
262 DUMP_FUINT (SubstLookupRecord, LookupListIndex);
263}
264
265DEF_DUMP (ChainSubClassRule)
266{
267 int i;
268
269 DUMP_USHORT_ARRAY (ChainSubClassRule, Backtrack, ChainSubClassRule->BacktrackGlyphCount);
270 DUMP_USHORT_ARRAY (ChainSubClassRule, Input, ChainSubClassRule->InputGlyphCount - 1);
271 DUMP_USHORT_ARRAY (ChainSubClassRule, Lookahead, ChainSubClassRule->LookaheadGlyphCount);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000272
Owen Taylor378e1882003-07-26 02:10:42 +0000273 for (i = 0; i < ChainSubClassRule->SubstCount; i++)
274 RECURSE_NUM (SubstLookupRecord, i, SubstLookupRecord, &ChainSubClassRule->SubstLookupRecord[i]);
275
276 indent--;
277}
278
279DEF_DUMP (ChainSubClassSet)
280{
281 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000282
Owen Taylor378e1882003-07-26 02:10:42 +0000283 DUMP_FUINT( ChainSubClassSet, ChainSubClassRuleCount );
284 for (i = 0; i < ChainSubClassSet->ChainSubClassRuleCount; i++)
285 RECURSE_NUM (ChainSubClassRule, i, ChainSubClassRule, &ChainSubClassSet->ChainSubClassRule[i]);
286}
287
Owen Taylor80a15822000-12-20 04:41:36 +0000288static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000289Dump_GSUB_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor80a15822000-12-20 04:41:36 +0000290{
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000291 HB_SingleSubst *SingleSubst = &subtable->st.gsub.single;
Owen Taylor80a15822000-12-20 04:41:36 +0000292
293 DUMP_FUINT (SingleSubst, SubstFormat);
294 RECURSE (Coverage, Coverage, &SingleSubst->Coverage);
295
296 if (SingleSubst->SubstFormat == 1)
297 {
298 DUMP_FINT (&SingleSubst->ssf.ssf1, DeltaGlyphID);
299 }
300 else
301 {
302 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000303
Owen Taylor80a15822000-12-20 04:41:36 +0000304 DUMP_FINT (&SingleSubst->ssf.ssf2, GlyphCount);
305 for (i=0; i < SingleSubst->ssf.ssf2.GlyphCount; i++)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000306 DUMP2("<Substitute>%#06x</Substitute> <!-- %d -->\n", SingleSubst->ssf.ssf2.Substitute[i], i);
Owen Taylor80a15822000-12-20 04:41:36 +0000307 }
308}
309
310DEF_DUMP (Ligature)
311{
312 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000313
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000314 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000315
Owen Taylor80a15822000-12-20 04:41:36 +0000316 DUMP_FGLYPH (Ligature, LigGlyph);
317 DUMP_FUINT (Ligature, ComponentCount);
318
319 for (i=0; i < Ligature->ComponentCount - 1; i++)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000320 DUMP1("<Component>%#06x</Component>\n", Ligature->Component[i]);
Owen Taylor80a15822000-12-20 04:41:36 +0000321}
322
323DEF_DUMP (LigatureSet)
324{
325 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000326
Owen Taylor80a15822000-12-20 04:41:36 +0000327 DUMP_FUINT (LigatureSet, LigatureCount);
328
329 for (i=0; i < LigatureSet->LigatureCount; i++)
Owen Taylor378e1882003-07-26 02:10:42 +0000330 RECURSE_NUM (Ligature, i, Ligature, &LigatureSet->Ligature[i]);
Owen Taylor80a15822000-12-20 04:41:36 +0000331}
332
333static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000334Dump_GSUB_Lookup_Ligature (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor80a15822000-12-20 04:41:36 +0000335{
336 int i;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000337 HB_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature;
Owen Taylor80a15822000-12-20 04:41:36 +0000338
339 DUMP_FUINT (LigatureSubst, SubstFormat);
340 RECURSE (Coverage, Coverage, &LigatureSubst->Coverage);
341
342 DUMP_FUINT (LigatureSubst, LigatureSetCount);
343
344 for (i=0; i < LigatureSubst->LigatureSetCount; i++)
Owen Taylor378e1882003-07-26 02:10:42 +0000345 RECURSE_NUM (LigatureSet, i, LigatureSet, &LigatureSubst->LigatureSet[i]);
346}
347
348DEF_DUMP (ContextSubstFormat1)
349{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000350 HB_UNUSED(hb_type);
351 HB_UNUSED(ContextSubstFormat1);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000352
353
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000354 DUMP("<!-- Not implemented!!! -->\n");
Owen Taylor378e1882003-07-26 02:10:42 +0000355}
356
357DEF_DUMP (ContextSubstFormat2)
358{
359 DUMP_FUINT (ContextSubstFormat2, MaxContextLength);
360 RECURSE (Coverage, Coverage, &ContextSubstFormat2->Coverage);
361 RECURSE (ClassDefinition, ClassDefinition, &ContextSubstFormat2->ClassDef);
362}
363
364DEF_DUMP (ContextSubstFormat3)
365{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000366 HB_UNUSED(hb_type);
367 HB_UNUSED(ContextSubstFormat3);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000368
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000369 DUMP("<!-- Not implemented!!! -->\n");
Owen Taylor378e1882003-07-26 02:10:42 +0000370}
371
372static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000373Dump_GSUB_Lookup_Context (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor378e1882003-07-26 02:10:42 +0000374{
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000375 HB_ContextSubst *ContextSubst = &subtable->st.gsub.context;
Owen Taylor378e1882003-07-26 02:10:42 +0000376
377 DUMP_FUINT (ContextSubst, SubstFormat);
378 switch( ContextSubst->SubstFormat )
379 {
380 case 1:
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000381 Dump_ContextSubstFormat1 (&ContextSubst->csf.csf1, stream, indent+2, hb_type);
Owen Taylor378e1882003-07-26 02:10:42 +0000382 break;
383 case 2:
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000384 Dump_ContextSubstFormat2 (&ContextSubst->csf.csf2, stream, indent+2, hb_type);
Owen Taylor378e1882003-07-26 02:10:42 +0000385 break;
386 case 3:
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000387 Dump_ContextSubstFormat3 (&ContextSubst->csf.csf3, stream, indent+2, hb_type);
Owen Taylor378e1882003-07-26 02:10:42 +0000388 break;
389 default:
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000390 fprintf(stderr, "invalid subformat!!!!!\n");
Owen Taylor378e1882003-07-26 02:10:42 +0000391 }
392}
393
394DEF_DUMP (ChainContextSubstFormat1)
395{
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000396 HB_UNUSED(hb_type);
397 HB_UNUSED(ChainContextSubstFormat1);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000398
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000399 DUMP("<!-- Not implemented!!! -->\n");
Owen Taylor378e1882003-07-26 02:10:42 +0000400}
401
402DEF_DUMP (ChainContextSubstFormat2)
403{
404 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000405
Owen Taylor378e1882003-07-26 02:10:42 +0000406 RECURSE (Coverage, Coverage, &ChainContextSubstFormat2->Coverage);
407 DUMP_FUINT (ChainContextSubstFormat2, MaxBacktrackLength);
408 RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->BacktrackClassDef);
409 DUMP_FUINT (ChainContextSubstFormat2, MaxInputLength);
410 RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->InputClassDef);
411 DUMP_FUINT (ChainContextSubstFormat2, MaxLookaheadLength);
412 RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->LookaheadClassDef);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000413
Owen Taylor378e1882003-07-26 02:10:42 +0000414 DUMP_FUINT (ChainContextSubstFormat2, ChainSubClassSetCount);
415 for (i = 0; i < ChainContextSubstFormat2->ChainSubClassSetCount; i++)
416 RECURSE (ChainSubClassSet, ChainSubClassSet, &ChainContextSubstFormat2->ChainSubClassSet[i]);
417}
418
419DEF_DUMP (ChainContextSubstFormat3)
420{
Owen Taylor81b62af2004-07-19 21:13:23 +0000421 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000422
Owen Taylor81b62af2004-07-19 21:13:23 +0000423 DUMP_FUINT (ChainContextSubstFormat3, BacktrackGlyphCount);
424 for (i = 0; i < ChainContextSubstFormat3->BacktrackGlyphCount; i++)
425 RECURSE (BacktrackCoverage, Coverage, &ChainContextSubstFormat3->BacktrackCoverage[i]);
426 DUMP_FUINT (ChainContextSubstFormat3, InputGlyphCount);
427 for (i = 0; i < ChainContextSubstFormat3->InputGlyphCount; i++)
428 RECURSE (InputCoverage, Coverage, &ChainContextSubstFormat3->InputCoverage[i]);
429 DUMP_FUINT (ChainContextSubstFormat3, LookaheadGlyphCount);
430 for (i = 0; i < ChainContextSubstFormat3->LookaheadGlyphCount; i++)
431 RECURSE (LookaheadCoverage, Coverage, &ChainContextSubstFormat3->LookaheadCoverage[i]);
432
433 for (i = 0; i < ChainContextSubstFormat3->SubstCount; i++)
434 RECURSE_NUM (SubstLookupRecord, i, SubstLookupRecord, &ChainContextSubstFormat3->SubstLookupRecord[i]);
435
Owen Taylor378e1882003-07-26 02:10:42 +0000436}
437
438static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000439Dump_GSUB_Lookup_Chain (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor378e1882003-07-26 02:10:42 +0000440{
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000441 HB_ChainContextSubst *chain = &subtable->st.gsub.chain;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000442
Owen Taylor378e1882003-07-26 02:10:42 +0000443 DUMP_FUINT (chain, SubstFormat);
444 switch (chain->SubstFormat)
445 {
446 case 1:
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000447 Dump_ChainContextSubstFormat1 (&chain->ccsf.ccsf1, stream, indent+2, hb_type);
Owen Taylor378e1882003-07-26 02:10:42 +0000448 break;
449 case 2:
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000450 Dump_ChainContextSubstFormat2 (&chain->ccsf.ccsf2, stream, indent+2, hb_type);
Owen Taylor378e1882003-07-26 02:10:42 +0000451 break;
452 case 3:
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000453 Dump_ChainContextSubstFormat3 (&chain->ccsf.ccsf3, stream, indent+2, hb_type);
Owen Taylor378e1882003-07-26 02:10:42 +0000454 break;
455 default:
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000456 fprintf(stderr, "invalid subformat!!!!!\n");
Owen Taylor378e1882003-07-26 02:10:42 +0000457 }
Owen Taylor80a15822000-12-20 04:41:36 +0000458}
459
Owen Taylor60509332002-03-15 04:22:14 +0000460static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000461Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor60509332002-03-15 04:22:14 +0000462{
463 int i;
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +0000464 int bits;
Owen Taylor60509332002-03-15 04:22:14 +0000465 int n_per;
466 unsigned int mask;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000467
Behdad Esfahbod4280ec42007-10-25 00:23:46 +0000468 HB_UNUSED(hb_type);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000469
Owen Taylor60509332002-03-15 04:22:14 +0000470 DUMP_FUINT (Device, StartSize);
471 DUMP_FUINT (Device, EndSize);
472 DUMP_FUINT (Device, DeltaFormat);
473 switch (Device->DeltaFormat)
474 {
475 case 1:
476 bits = 2;
477 break;
478 case 2:
479 bits = 4;
480 break;
481 case 3:
482 bits = 8;
483 break;
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +0000484 default:
485 bits = 0;
486 break;
Owen Taylor60509332002-03-15 04:22:14 +0000487 }
488
Owen Taylor60509332002-03-15 04:22:14 +0000489 DUMP ("<DeltaValue>");
Behdad Esfahbod682db812005-11-23 15:19:48 +0000490 if (!bits)
Owen Taylor60509332002-03-15 04:22:14 +0000491 {
Behdad Esfahbod682db812005-11-23 15:19:48 +0000492
493 fprintf(stderr, "invalid DeltaFormat!!!!!\n");
494 }
495 else
496 {
497 n_per = 16 / bits;
498 mask = (1 << bits) - 1;
499 mask = mask << (16 - bits);
500
501 for (i = Device->StartSize; i <= Device->EndSize ; i++)
502 {
Behdad Esfahbod5716ae22007-10-24 22:44:47 +0000503 HB_UShort val = Device->DeltaValue[i / n_per];
504 HB_Short signed_val = ((val << ((i % n_per) * bits)) & mask);
Behdad Esfahbod682db812005-11-23 15:19:48 +0000505 dump (stream, indent, "%d", signed_val >> (16 - bits));
506 if (i != Device->EndSize)
507 DUMP (", ");
508 }
Owen Taylor60509332002-03-15 04:22:14 +0000509 }
510 DUMP ("</DeltaValue>\n");
511}
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000512
Owen Taylor60509332002-03-15 04:22:14 +0000513static void
Behdad Esfahbod5716ae22007-10-24 22:44:47 +0000514Dump_ValueRecord (HB_ValueRecord *ValueRecord, FILE *stream, int indent, HB_Type hb_type, HB_UShort value_format)
Owen Taylor60509332002-03-15 04:22:14 +0000515{
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000516 if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT)
Owen Taylor60509332002-03-15 04:22:14 +0000517 DUMP_FINT (ValueRecord, XPlacement);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000518 if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT)
Owen Taylor60509332002-03-15 04:22:14 +0000519 DUMP_FINT (ValueRecord, YPlacement);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000520 if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE)
Owen Taylor60509332002-03-15 04:22:14 +0000521 DUMP_FINT (ValueRecord, XAdvance);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000522 if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE)
Owen Taylor60509332002-03-15 04:22:14 +0000523 DUMP_FINT (ValueRecord, XAdvance);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000524 if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE)
Owen Taylor60509332002-03-15 04:22:14 +0000525 RECURSE (Device, Device, &ValueRecord->XPlacementDevice);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000526 if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE)
Owen Taylor60509332002-03-15 04:22:14 +0000527 RECURSE (Device, Device, &ValueRecord->YPlacementDevice);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000528 if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE)
Owen Taylor60509332002-03-15 04:22:14 +0000529 RECURSE (Device, Device, &ValueRecord->XAdvanceDevice);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000530 if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE)
Owen Taylor60509332002-03-15 04:22:14 +0000531 RECURSE (Device, Device, &ValueRecord->YAdvanceDevice);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000532 if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT)
Owen Taylor60509332002-03-15 04:22:14 +0000533 DUMP_FUINT (ValueRecord, XIdPlacement);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000534 if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT)
Owen Taylor60509332002-03-15 04:22:14 +0000535 DUMP_FUINT (ValueRecord, YIdPlacement);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000536 if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE)
Owen Taylor60509332002-03-15 04:22:14 +0000537 DUMP_FUINT (ValueRecord, XIdAdvance);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000538 if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE)
Owen Taylor60509332002-03-15 04:22:14 +0000539 DUMP_FUINT (ValueRecord, XIdAdvance);
540}
541
542static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000543Dump_GPOS_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor60509332002-03-15 04:22:14 +0000544{
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000545 HB_SinglePos *SinglePos = &subtable->st.gpos.single;
Owen Taylor60509332002-03-15 04:22:14 +0000546
547 DUMP_FUINT (SinglePos, PosFormat);
548 RECURSE (Coverage, Coverage, &SinglePos->Coverage);
549
550 DUMP_FUINT (SinglePos, ValueFormat);
551
552 if (SinglePos->PosFormat == 1)
553 {
554 DUMP_VALUE_RECORD (&SinglePos->spf.spf1.Value, SinglePos->ValueFormat);
555 }
556 else
557 {
558 int i;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000559
Owen Taylor60509332002-03-15 04:22:14 +0000560 DUMP_FUINT (&SinglePos->spf.spf2, ValueCount);
561 for (i = 0; i < SinglePos->spf.spf2.ValueCount; i++)
562 DUMP_VALUE_RECORD (&SinglePos->spf.spf2.Value[i], SinglePos->ValueFormat);
563 }
564}
565
566static void
Behdad Esfahbod5716ae22007-10-24 22:44:47 +0000567Dump_PairValueRecord (HB_PairValueRecord *PairValueRecord, FILE *stream, int indent, HB_Type hb_type, HB_UShort ValueFormat1, HB_UShort ValueFormat2)
Owen Taylor60509332002-03-15 04:22:14 +0000568{
569 DUMP_FUINT (PairValueRecord, SecondGlyph);
570 DUMP_VALUE_RECORD (&PairValueRecord->Value1, ValueFormat1);
571 DUMP_VALUE_RECORD (&PairValueRecord->Value2, ValueFormat2);
572}
573
574static void
Behdad Esfahbod5716ae22007-10-24 22:44:47 +0000575Dump_PairSet (HB_PairSet *PairSet, FILE *stream, int indent, HB_Type hb_type, HB_UShort ValueFormat1, HB_UShort ValueFormat2)
Owen Taylor60509332002-03-15 04:22:14 +0000576{
577 int i;
578 DUMP_FUINT (PairSet, PairValueCount);
579
580 for (i = 0; i < PairSet->PairValueCount; i++)
581 {
582 DUMP ("<PairValueRecord>\n");
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000583 Dump_PairValueRecord (&PairSet->PairValueRecord[i], stream, indent + 1, hb_type, ValueFormat1, ValueFormat2);
Owen Taylor60509332002-03-15 04:22:14 +0000584 DUMP ("</PairValueRecord>\n");
585 }
586}
587
588static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000589Dump_GPOS_Lookup_Pair (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor60509332002-03-15 04:22:14 +0000590{
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000591 HB_PairPos *PairPos = &subtable->st.gpos.pair;
Owen Taylor60509332002-03-15 04:22:14 +0000592
593 DUMP_FUINT (PairPos, PosFormat);
594 RECURSE (Coverage, Coverage, &PairPos->Coverage);
595
596 DUMP_FUINT (PairPos, ValueFormat1);
597 DUMP_FUINT (PairPos, ValueFormat2);
598
599 if (PairPos->PosFormat == 1)
600 {
601 int i;
602
603 DUMP_FUINT (&PairPos->ppf.ppf1, PairSetCount);
604 for (i = 0; i < PairPos->ppf.ppf1.PairSetCount; i++)
605 {
606 DUMP ("<PairSet>\n");
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000607 Dump_PairSet (&PairPos->ppf.ppf1.PairSet[i], stream, indent + 1, hb_type, PairPos->ValueFormat1, PairPos->ValueFormat2);
Owen Taylor60509332002-03-15 04:22:14 +0000608 DUMP ("</PairSet>\n");
609 }
610 }
611 else
612 {
613 }
614}
615
Owen Taylor378e1882003-07-26 02:10:42 +0000616static void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000617Dump_GPOS_Lookup_Markbase (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
Owen Taylor378e1882003-07-26 02:10:42 +0000618{
619 int i;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000620 HB_MarkBasePos *markbase = &subtable->st.gpos.markbase;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000621
Owen Taylor378e1882003-07-26 02:10:42 +0000622 DUMP_FUINT (markbase, PosFormat);
623 RECURSE (Coverage, Coverage, &markbase->MarkCoverage);
624 RECURSE (Coverage, Coverage, &markbase->BaseCoverage);
625 DUMP_FUINT (markbase, ClassCount);
626 RECURSE (MarkArray, MarkArray, &markbase->MarkArray);
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000627
Owen Taylor378e1882003-07-26 02:10:42 +0000628 DUMP ("<BaseArray>\n");
629 indent++;
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000630
Owen Taylor378e1882003-07-26 02:10:42 +0000631 DUMP_FUINT (&markbase->BaseArray, BaseCount);
632 for (i = 0; i < markbase->BaseArray.BaseCount; i++)
633 {
634 int j;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000635 HB_BaseRecord *r = &markbase->BaseArray.BaseRecord[i];
636 DUMP1 ("<BaseRecord> <!-- %d -->\n", i);
Owen Taylor378e1882003-07-26 02:10:42 +0000637 for (j = 0; j < markbase->ClassCount; j++)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000638 DUMP1 (" <Anchor>%d</Anchor>\n", r->BaseAnchor->PosFormat);
Owen Taylor378e1882003-07-26 02:10:42 +0000639 DUMP ("<BaseRecord>\n");
640 }
Behdad Esfahbodb31d6de2006-04-06 18:23:49 +0000641
Owen Taylor378e1882003-07-26 02:10:42 +0000642 indent--;
643 DUMP ("</BaseArray>\n");
644}
645
Owen Taylor80a15822000-12-20 04:41:36 +0000646DEF_DUMP (Lookup)
647{
648 int i;
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +0000649 const char *lookup_name;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000650 void (*lookup_func) (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type) = NULL;
Owen Taylor80a15822000-12-20 04:41:36 +0000651
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000652 if (hb_type == HB_Type_GSUB)
Owen Taylor80a15822000-12-20 04:41:36 +0000653 {
654 switch (Lookup->LookupType)
655 {
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000656 case HB_GSUB_LOOKUP_SINGLE:
Owen Taylor80a15822000-12-20 04:41:36 +0000657 lookup_name = "SINGLE";
658 lookup_func = Dump_GSUB_Lookup_Single;
659 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000660 case HB_GSUB_LOOKUP_MULTIPLE:
Owen Taylor80a15822000-12-20 04:41:36 +0000661 lookup_name = "MULTIPLE";
662 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000663 case HB_GSUB_LOOKUP_ALTERNATE:
Owen Taylor80a15822000-12-20 04:41:36 +0000664 lookup_name = "ALTERNATE";
665 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000666 case HB_GSUB_LOOKUP_LIGATURE:
Owen Taylor80a15822000-12-20 04:41:36 +0000667 lookup_name = "LIGATURE";
668 lookup_func = Dump_GSUB_Lookup_Ligature;
669 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000670 case HB_GSUB_LOOKUP_CONTEXT:
Owen Taylor80a15822000-12-20 04:41:36 +0000671 lookup_name = "CONTEXT";
Owen Taylor378e1882003-07-26 02:10:42 +0000672 lookup_func = Dump_GSUB_Lookup_Context;
Owen Taylor80a15822000-12-20 04:41:36 +0000673 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000674 case HB_GSUB_LOOKUP_CHAIN:
Owen Taylor80a15822000-12-20 04:41:36 +0000675 lookup_name = "CHAIN";
Owen Taylor378e1882003-07-26 02:10:42 +0000676 lookup_func = Dump_GSUB_Lookup_Chain;
Owen Taylor80a15822000-12-20 04:41:36 +0000677 break;
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +0000678 default:
679 lookup_name = "(unknown)";
680 lookup_func = NULL;
681 break;
Owen Taylor80a15822000-12-20 04:41:36 +0000682 }
683 }
684 else
685 {
686 switch (Lookup->LookupType)
687 {
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000688 case HB_GPOS_LOOKUP_SINGLE:
Owen Taylor80a15822000-12-20 04:41:36 +0000689 lookup_name = "SINGLE";
Owen Taylor60509332002-03-15 04:22:14 +0000690 lookup_func = Dump_GPOS_Lookup_Single;
Owen Taylor80a15822000-12-20 04:41:36 +0000691 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000692 case HB_GPOS_LOOKUP_PAIR:
Owen Taylor80a15822000-12-20 04:41:36 +0000693 lookup_name = "PAIR";
Owen Taylor60509332002-03-15 04:22:14 +0000694 lookup_func = Dump_GPOS_Lookup_Pair;
Owen Taylor80a15822000-12-20 04:41:36 +0000695 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000696 case HB_GPOS_LOOKUP_CURSIVE:
Owen Taylor80a15822000-12-20 04:41:36 +0000697 lookup_name = "CURSIVE";
698 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000699 case HB_GPOS_LOOKUP_MARKBASE:
Owen Taylor80a15822000-12-20 04:41:36 +0000700 lookup_name = "MARKBASE";
Owen Taylor378e1882003-07-26 02:10:42 +0000701 lookup_func = Dump_GPOS_Lookup_Markbase;
Owen Taylor80a15822000-12-20 04:41:36 +0000702 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000703 case HB_GPOS_LOOKUP_MARKLIG:
Owen Taylor80a15822000-12-20 04:41:36 +0000704 lookup_name = "MARKLIG";
705 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000706 case HB_GPOS_LOOKUP_MARKMARK:
Owen Taylor80a15822000-12-20 04:41:36 +0000707 lookup_name = "MARKMARK";
708 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000709 case HB_GPOS_LOOKUP_CONTEXT:
Owen Taylor80a15822000-12-20 04:41:36 +0000710 lookup_name = "CONTEXT";
711 break;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000712 case HB_GPOS_LOOKUP_CHAIN:
Owen Taylor80a15822000-12-20 04:41:36 +0000713 lookup_name = "CHAIN";
714 break;
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +0000715 default:
716 lookup_name = "(unknown)";
717 lookup_func = NULL;
718 break;
Owen Taylor80a15822000-12-20 04:41:36 +0000719 }
720 }
721
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000722 DUMP2("<LookupType>%s</LookupType> <!-- %d -->\n", lookup_name, Lookup->LookupType);
723 DUMP1("<LookupFlag>%#06x</LookupFlag>\n", Lookup->LookupFlag);
Owen Taylor80a15822000-12-20 04:41:36 +0000724
725 for (i=0; i < Lookup->SubTableCount; i++)
726 {
727 DUMP ("<Subtable>\n");
728 if (lookup_func)
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000729 (*lookup_func) (&Lookup->SubTable[i], stream, indent + 1, hb_type);
Owen Taylor80a15822000-12-20 04:41:36 +0000730 DUMP ("</Subtable>\n");
731 }
732}
733
734DEF_DUMP (LookupList)
735{
736 int i;
737
738 DUMP_FUINT (LookupList, LookupCount);
739
740 for (i=0; i < LookupList->LookupCount; i++)
Owen Taylor378e1882003-07-26 02:10:42 +0000741 RECURSE_NUM (Lookup, i, Lookup, &LookupList->Lookup[i]);
Owen Taylor80a15822000-12-20 04:41:36 +0000742}
743
744void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000745HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream)
Owen Taylor80a15822000-12-20 04:41:36 +0000746{
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000747 int indent = 1;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000748 HB_Type hb_type = HB_Type_GSUB;
Owen Taylor80a15822000-12-20 04:41:36 +0000749
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000750 do_indent (stream, indent);
751 fprintf(stream, "<!-- GSUB -->\n");
Owen Taylor80a15822000-12-20 04:41:36 +0000752 RECURSE (ScriptList, ScriptList, &gsub->ScriptList);
753 RECURSE (FeatureList, FeatureList, &gsub->FeatureList);
754 RECURSE (LookupList, LookupList, &gsub->LookupList);
755}
756
757void
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000758HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream)
Owen Taylor80a15822000-12-20 04:41:36 +0000759{
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000760 int indent = 1;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000761 HB_Type hb_type = HB_Type_GPOS;
Owen Taylor80a15822000-12-20 04:41:36 +0000762
Behdad Esfahbodc6b22b92005-08-29 10:06:40 +0000763 do_indent (stream, indent);
764 fprintf(stream, "<!-- GPOS -->\n");
Owen Taylor80a15822000-12-20 04:41:36 +0000765 RECURSE (ScriptList, ScriptList, &gpos->ScriptList);
766 RECURSE (FeatureList, FeatureList, &gpos->FeatureList);
767 RECURSE (LookupList, LookupList, &gpos->LookupList);
768}