df9dd9b7f0d573e0b402e0ee787ee78336c8aa49
[framework/uifw/harfbuzz.git] / src / hb-ot-layout-gsubgpos-private.h
1 /*
2  * Copyright (C) 2007,2008,2009  Red Hat, Inc.
3  *
4  *  This is part of HarfBuzz, an OpenType Layout engine library.
5  *
6  * 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.
11  *
12  * 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.
17  *
18  * 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): Behdad Esfahbod
25  */
26
27 #ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_H
28 #define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_H
29
30 #include "hb-ot-layout-gdef-private.h"
31 #include "harfbuzz-buffer-private.h" /* XXX */
32
33
34 #define LOOKUP_ARGS_DEF \
35         hb_ot_layout_t *layout, \
36         hb_buffer_t    *buffer, \
37         unsigned int    context_length HB_GNUC_UNUSED, \
38         unsigned int    nesting_level_left HB_GNUC_UNUSED, \
39         unsigned int    lookup_flag, \
40         unsigned int    property HB_GNUC_UNUSED /* propety of first glyph */
41 #define LOOKUP_ARGS \
42         layout, \
43         buffer, \
44         context_length, \
45         nesting_level_left, \
46         lookup_flag, \
47         property
48
49
50 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, char *data);
51 typedef bool (*apply_lookup_func_t) (LOOKUP_ARGS_DEF, unsigned int lookup_index);
52
53 struct ContextFuncs {
54   match_func_t match;
55   apply_lookup_func_t apply;
56 };
57
58
59 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, char *data) {
60   return glyph_id == value;
61 }
62
63 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, char *data) {
64   const ClassDef &class_def = * (const ClassDef *) data;
65   return class_def.get_class (glyph_id) == value;
66 }
67
68 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, char *data) {
69   const OffsetTo<Coverage> &coverage = * (const OffsetTo<Coverage> *) &value;
70   return (data+coverage) (glyph_id) != NOT_COVERED;
71 }
72
73
74 static inline bool match_input (LOOKUP_ARGS_DEF,
75                                 unsigned int count, /* Including the first glyph (not matched) */
76                                 const USHORT input[], /* Array of input values--start with second glyph */
77                                 match_func_t match_func,
78                                 char *match_data,
79                                 unsigned int *context_length_out)
80 {
81   unsigned int i, j;
82
83   /* XXX context_length should also be checked when skipping glyphs, right?
84    * What does context_length really mean, anyway? */
85
86   for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) {
87     while (!_hb_ot_layout_check_glyph_property (layout, IN_ITEM (j), lookup_flag, &property)) {
88       if (HB_UNLIKELY (j + count - i == buffer->in_length))
89         return false;
90       j++;
91     }
92
93     if (HB_LIKELY (!match_func (IN_GLYPH(j), input[i - 1], match_data)))
94       return false;
95   }
96
97   *context_length_out = j - buffer->in_pos;
98
99   return true;
100 }
101
102 static inline bool match_backtrack (LOOKUP_ARGS_DEF,
103                                     unsigned int count,
104                                     const USHORT backtrack[],
105                                     match_func_t match_func,
106                                     char *match_data)
107 {
108   unsigned int i, j;
109
110   for (i = 0, j = buffer->out_pos - 1; i < count; i++, j--) {
111     while (!_hb_ot_layout_check_glyph_property (layout, OUT_ITEM (j), lookup_flag, &property)) {
112       if (HB_UNLIKELY (j + 1 == count - i))
113         return false;
114       j--;
115     }
116
117     if (HB_LIKELY (!match_func (OUT_GLYPH(j), backtrack[i], match_data)))
118       return false;
119   }
120
121   return true;
122 }
123
124 static inline bool match_lookahead (LOOKUP_ARGS_DEF,
125                                     unsigned int count,
126                                     const USHORT lookahead[],
127                                     match_func_t match_func,
128                                     char *match_data,
129                                     unsigned int offset)
130 {
131   unsigned int i, j;
132
133   for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++) {
134     while (!_hb_ot_layout_check_glyph_property (layout, OUT_ITEM (j), lookup_flag, &property)) {
135       if (HB_UNLIKELY (j + count - i == buffer->in_length))
136         return false;
137       j++;
138     }
139
140     if (HB_LIKELY (!match_func (IN_GLYPH(j), lookahead[i], match_data)))
141       return false;
142   }
143
144   return true;
145 }
146
147
148 struct LookupRecord {
149
150   USHORT        sequenceIndex;          /* Index into current glyph
151                                          * sequence--first glyph = 0 */
152   USHORT        lookupListIndex;        /* Lookup to apply to that
153                                          * position--zero--based */
154 };
155 ASSERT_SIZE (LookupRecord, 4);
156
157 static inline bool apply_lookup (LOOKUP_ARGS_DEF,
158                                  unsigned int count, /* Including the first glyph */
159                                  unsigned int lookupCount,
160                                  const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
161                                  apply_lookup_func_t apply_func)
162 {
163   unsigned int record_count = lookupCount;
164   const LookupRecord *record = lookupRecord;
165
166   /* XXX We have to jump non-matching glyphs when applying too, right? */
167   /* XXX We don't support lookupRecord arrays that are not increasing:
168    *     Should be easy for in_place ones at least. */
169   for (unsigned int i = 0; i < count;)
170   {
171     if (record_count && i == record->sequenceIndex)
172     {
173       unsigned int old_pos = buffer->in_pos;
174
175       /* Apply a lookup */
176       bool done = apply_func (LOOKUP_ARGS, record->lookupListIndex);
177
178       record++;
179       record_count--;
180       i += buffer->in_pos - old_pos;
181
182       if (!done)
183         goto not_applied;
184     }
185     else
186     {
187     not_applied:
188       /* No lookup applied for this index */
189       _hb_buffer_next_glyph (buffer);
190       i++;
191     }
192   }
193
194   return true;
195 }
196
197
198 /* Contextual lookups */
199
200 struct ContextLookupContext {
201   ContextFuncs funcs;
202   char *match_data;
203 };
204
205 static inline bool context_lookup (LOOKUP_ARGS_DEF,
206                                    unsigned int inputCount, /* Including the first glyph (not matched) */
207                                    const USHORT input[], /* Array of input values--start with second glyph */
208                                    unsigned int lookupCount,
209                                    const LookupRecord lookupRecord[],
210                                    ContextLookupContext &context)
211 {
212   /* First guess */
213   if (HB_UNLIKELY (buffer->in_pos + inputCount > buffer->in_length ||
214                    context_length < inputCount))
215     return false;
216
217   return match_input (LOOKUP_ARGS,
218                       inputCount, input,
219                       context.funcs.match, context.match_data,
220                       &context_length) &&
221          apply_lookup (LOOKUP_ARGS,
222                        inputCount,
223                        lookupCount, lookupRecord,
224                        context.funcs.apply);
225 }
226
227 struct Rule {
228
229   friend struct RuleSet;
230
231   private:
232   inline bool apply (LOOKUP_ARGS_DEF, ContextLookupContext &context) const {
233     const LookupRecord *lookupRecord = (const LookupRecord *)
234                                        ((const char *) input +
235                                         sizeof (input[0]) * (inputCount ? inputCount - 1 : 0));
236     return context_lookup (LOOKUP_ARGS,
237                            inputCount,
238                            input,
239                            lookupCount,
240                            lookupRecord,
241                            context);
242   }
243
244   private:
245   USHORT        inputCount;             /* Total number of glyphs in input
246                                          * glyph sequence--includes the  first
247                                          * glyph */
248   USHORT        lookupCount;            /* Number of LookupRecords */
249   USHORT        input[];                /* Array of match inputs--start with
250                                          * second glyph */
251   LookupRecord  lookupRecordX[];        /* Array of LookupRecords--in
252                                          * design order */
253 };
254 ASSERT_SIZE (Rule, 4);
255
256 struct RuleSet {
257
258   inline bool apply (LOOKUP_ARGS_DEF, ContextLookupContext &context) const {
259
260     unsigned int num_rules = rule.len;
261     for (unsigned int i = 0; i < num_rules; i++) {
262       if ((this+rule[i]).apply (LOOKUP_ARGS, context))
263         return true;
264     }
265
266     return false;
267   }
268
269   private:
270   OffsetArrayOf<Rule>
271                 rule;                   /* Array of Rule tables
272                                          * ordered by preference */
273 };
274
275
276 struct ContextFormat1 {
277
278   friend struct Context;
279
280   private:
281   inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
282
283     unsigned int index = (this+coverage) (IN_CURGLYPH ());
284     if (G_LIKELY (index == NOT_COVERED))
285       return false;
286
287     const RuleSet &rule_set = this+ruleSet[index];
288     struct ContextLookupContext context = {
289       {match_glyph, apply_func},
290       NULL
291     };
292     return rule_set.apply (LOOKUP_ARGS, context);
293   }
294
295   private:
296   USHORT        format;                 /* Format identifier--format = 1 */
297   OffsetTo<Coverage>
298                 coverage;               /* Offset to Coverage table--from
299                                          * beginning of table */
300   OffsetArrayOf<RuleSet>
301                 ruleSet;                /* Array of RuleSet tables
302                                          * ordered by Coverage Index */
303 };
304 ASSERT_SIZE (ContextFormat1, 6);
305
306
307 struct ContextFormat2 {
308
309   friend struct Context;
310
311   private:
312   inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
313
314     unsigned int index = (this+coverage) (IN_CURGLYPH ());
315     if (G_LIKELY (index == NOT_COVERED))
316       return false;
317
318     const ClassDef &class_def = this+classDef;
319     index = class_def (IN_CURGLYPH ());
320     const RuleSet &rule_set = this+ruleSet[index];
321     /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
322      * them across subrule lookups.  Not sure it's worth it.
323      */
324     struct ContextLookupContext context = {
325      {match_class, apply_func},
326       (char *) &class_def
327     };
328     return rule_set.apply (LOOKUP_ARGS, context);
329   }
330
331   private:
332   USHORT        format;                 /* Format identifier--format = 2 */
333   OffsetTo<Coverage>
334                 coverage;               /* Offset to Coverage table--from
335                                          * beginning of table */
336   OffsetTo<ClassDef>
337                 classDef;               /* Offset to glyph ClassDef table--from
338                                          * beginning of table */
339   OffsetArrayOf<RuleSet>
340                 ruleSet;                /* Array of RuleSet tables
341                                          * ordered by class */
342 };
343 ASSERT_SIZE (ContextFormat2, 8);
344
345
346 struct ContextFormat3 {
347
348   friend struct Context;
349
350   private:
351   inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
352
353     unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
354     if (G_LIKELY (index == NOT_COVERED))
355       return false;
356
357     const LookupRecord *lookupRecord = (const LookupRecord *)
358                                        ((const char *) coverage +
359                                         sizeof (coverage[0]) * glyphCount);
360     struct ContextLookupContext context = {
361       {match_coverage, apply_func},
362       (char *) this
363     };
364     return context_lookup (LOOKUP_ARGS,
365                            glyphCount,
366                            (const USHORT *) (coverage + 1),
367                            lookupCount,
368                            lookupRecord,
369                            context);
370   }
371
372   private:
373   USHORT        format;                 /* Format identifier--format = 3 */
374   USHORT        glyphCount;             /* Number of glyphs in the input glyph
375                                          * sequence */
376   USHORT        lookupCount;            /* Number of LookupRecords */
377   OffsetTo<Coverage>
378                 coverage[];             /* Array of offsets to Coverage
379                                          * table in glyph sequence order */
380   LookupRecord  lookupRecordX[];        /* Array of LookupRecords--in
381                                          * design order */
382 };
383 ASSERT_SIZE (ContextFormat3, 6);
384
385 struct Context {
386
387   protected:
388   bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
389     switch (u.format) {
390     case 1: return u.format1->apply (LOOKUP_ARGS, apply_func);
391     case 2: return u.format2->apply (LOOKUP_ARGS, apply_func);
392     case 3: return u.format3->apply (LOOKUP_ARGS, apply_func);
393     default:return false;
394     }
395   }
396
397   private:
398   union {
399   USHORT                format;         /* Format identifier */
400   ContextFormat1        format1[];
401   ContextFormat2        format2[];
402   ContextFormat3        format3[];
403   } u;
404 };
405 ASSERT_SIZE (Context, 2);
406
407
408 /* Chaining Contextual lookups */
409
410 struct ChainContextLookupContext {
411   ContextFuncs funcs;
412   char *match_data[3];
413 };
414
415 static inline bool chain_context_lookup (LOOKUP_ARGS_DEF,
416                                          unsigned int backtrackCount,
417                                          const USHORT backtrack[],
418                                          unsigned int inputCount, /* Including the first glyph (not matched) */
419                                          const USHORT input[], /* Array of input values--start with second glyph */
420                                          unsigned int lookaheadCount,
421                                          const USHORT lookahead[],
422                                          unsigned int lookupCount,
423                                          const LookupRecord lookupRecord[],
424                                          ChainContextLookupContext &context)
425 {
426   /* First guess */
427   if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
428                    buffer->in_pos + inputCount + lookaheadCount > buffer->in_length))
429     return false;
430
431   unsigned int offset;
432   return match_backtrack (LOOKUP_ARGS,
433                           backtrackCount, backtrack,
434                           context.funcs.match, context.match_data[0]) &&
435          match_input (LOOKUP_ARGS,
436                       inputCount, input,
437                       context.funcs.match, context.match_data[1],
438                       &offset) &&
439          (context_length -= offset, true) &&
440          match_lookahead (LOOKUP_ARGS,
441                           lookaheadCount, lookahead,
442                           context.funcs.match, context.match_data[2],
443                           offset) &&
444          (context_length = offset, true) &&
445          apply_lookup (LOOKUP_ARGS,
446                        inputCount,
447                        lookupCount, lookupRecord,
448                        context.funcs.apply);
449 }
450
451 struct ChainRule {
452
453   friend struct ChainRuleSet;
454
455   private:
456   inline bool apply (LOOKUP_ARGS_DEF, ChainContextLookupContext &context) const {
457     const HeadlessArrayOf<USHORT> &input = * (const HeadlessArrayOf<USHORT> *)
458                                              ((const char *) &backtrack + backtrack.get_size ());
459     const ArrayOf<USHORT> &lookahead = * (const ArrayOf<USHORT> *)
460                                          ((const char *) &input + input.get_size ());
461     const ArrayOf<LookupRecord> &lookup = * (const ArrayOf<LookupRecord> *)
462                                             ((const char *) &lookahead + lookahead.get_size ());
463     return chain_context_lookup (LOOKUP_ARGS,
464                                  backtrack.len,
465                                  backtrack.array,
466                                  input.len,
467                                  input.array + 1,
468                                  lookahead.len,
469                                  lookahead.array,
470                                  lookup.len,
471                                  lookup.array,
472                                  context);
473     return false;
474   }
475
476
477   private:
478   ArrayOf<USHORT>
479                 backtrack;              /* Array of backtracking values
480                                          * (to be matched before the input
481                                          * sequence) */
482   HeadlessArrayOf<USHORT>
483                 inputX;                 /* Array of input values (start with
484                                          * second glyph) */
485   ArrayOf<USHORT>
486                 lookaheadX;             /* Array of lookahead values's (to be
487                                          * matched after the input sequence) */
488   ArrayOf<LookupRecord>
489                 lookupX;                /* Array of LookupRecords--in
490                                          * design order) */
491 };
492 ASSERT_SIZE (ChainRule, 8);
493
494 struct ChainRuleSet {
495
496   inline bool apply (LOOKUP_ARGS_DEF, ChainContextLookupContext &context) const {
497
498     unsigned int num_rules = rule.len;
499     for (unsigned int i = 0; i < num_rules; i++) {
500       if ((this+rule[i]).apply (LOOKUP_ARGS, context))
501         return true;
502     }
503
504     return false;
505   }
506
507   private:
508   OffsetArrayOf<ChainRule>
509                 rule;                   /* Array of ChainRule tables
510                                          * ordered by preference */
511 };
512 ASSERT_SIZE (ChainRuleSet, 2);
513
514 struct ChainContextFormat1 {
515
516   friend struct ChainContext;
517
518   private:
519   inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
520
521     unsigned int index = (this+coverage) (IN_CURGLYPH ());
522     if (G_LIKELY (index == NOT_COVERED))
523       return false;
524
525     const ChainRuleSet &rule_set = this+ruleSet[index];
526     struct ChainContextLookupContext context = {
527       {match_glyph, apply_func},
528       {NULL, NULL, NULL}
529     };
530     return rule_set.apply (LOOKUP_ARGS, context);
531   }
532   private:
533   USHORT        format;                 /* Format identifier--format = 1 */
534   OffsetTo<Coverage>
535                 coverage;               /* Offset to Coverage table--from
536                                          * beginning of table */
537   OffsetArrayOf<ChainRuleSet>
538                 ruleSet;                /* Array of ChainRuleSet tables
539                                          * ordered by Coverage Index */
540 };
541 ASSERT_SIZE (ChainContextFormat1, 6);
542
543 struct ChainContextFormat2 {
544
545   friend struct ChainContext;
546
547   private:
548   inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
549
550     unsigned int index = (this+coverage) (IN_CURGLYPH ());
551     if (G_LIKELY (index == NOT_COVERED))
552       return false;
553
554     const ClassDef &backtrack_class_def = this+backtrackClassDef;
555     const ClassDef &input_class_def = this+inputClassDef;
556     const ClassDef &lookahead_class_def = this+lookaheadClassDef;
557
558     index = input_class_def (IN_CURGLYPH ());
559     const ChainRuleSet &rule_set = this+ruleSet[index];
560     /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
561      * them across subrule lookups.  Not sure it's worth it.
562      */
563     struct ChainContextLookupContext context = {
564      {match_class, apply_func},
565      {(char *) &backtrack_class_def,
566       (char *) &input_class_def,
567       (char *) &lookahead_class_def}
568     };
569     return rule_set.apply (LOOKUP_ARGS, context);
570   }
571
572   private:
573   USHORT        format;                 /* Format identifier--format = 2 */
574   OffsetTo<Coverage>
575                 coverage;               /* Offset to Coverage table--from
576                                          * beginning of table */
577   OffsetTo<ClassDef>
578                 backtrackClassDef;      /* Offset to glyph ClassDef table
579                                          * containing backtrack sequence
580                                          * data--from beginning of table */
581   OffsetTo<ClassDef>
582                 inputClassDef;          /* Offset to glyph ClassDef
583                                          * table containing input sequence
584                                          * data--from beginning of table */
585   OffsetTo<ClassDef>
586                 lookaheadClassDef;      /* Offset to glyph ClassDef table
587                                          * containing lookahead sequence
588                                          * data--from beginning of table */
589   OffsetArrayOf<ChainRuleSet>
590                 ruleSet;                /* Array of ChainRuleSet tables
591                                          * ordered by class */
592 };
593 ASSERT_SIZE (ChainContextFormat2, 12);
594
595 struct ChainContextFormat3 {
596
597   friend struct ChainContext;
598
599   private:
600
601   inline bool apply_coverage (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
602   }
603
604   inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
605
606     const OffsetArrayOf<Coverage> &input = * (const OffsetArrayOf<Coverage> *)
607                                              ((const char *) &backtrack + backtrack.get_size ());
608
609     unsigned int index = (this+input[0]) (IN_CURGLYPH ());
610     if (G_LIKELY (index == NOT_COVERED))
611       return false;
612
613     const OffsetArrayOf<Coverage> &lookahead = * (const OffsetArrayOf<Coverage> *)
614                                          ((const char *) &input + input.get_size ());
615     const ArrayOf<LookupRecord> &lookup = * (const ArrayOf<LookupRecord> *)
616                                             ((const char *) &lookahead + lookahead.get_size ());
617     struct ChainContextLookupContext context = {
618       {match_coverage, apply_func},
619       {(char *) this, (char *) this, (char *) this}
620     };
621     return chain_context_lookup (LOOKUP_ARGS,
622                                  backtrack.len,
623                                  (USHORT *) backtrack.array,
624                                  input.len,
625                                  (USHORT *) input.array,
626                                  lookahead.len,
627                                  (USHORT *) lookahead.array,
628                                  lookup.len,
629                                  lookup.array,
630                                  context);
631     return false;
632   }
633
634   private:
635   USHORT        format;                 /* Format identifier--format = 3 */
636   OffsetArrayOf<Coverage>
637                 backtrack;              /* Array of coverage tables
638                                          * in backtracking sequence, in  glyph
639                                          * sequence order */
640   OffsetArrayOf<Coverage>
641                 inputX          ;       /* Array of coverage
642                                          * tables in input sequence, in glyph
643                                          * sequence order */
644   OffsetArrayOf<Coverage>
645                 lookaheadX;             /* Array of coverage tables
646                                          * in lookahead sequence, in glyph
647                                          * sequence order */
648   ArrayOf<LookupRecord>
649                 lookupX;                /* Array of LookupRecords--in
650                                          * design order) */
651 };
652 ASSERT_SIZE (ChainContextFormat3, 10);
653
654 struct ChainContext {
655
656   protected:
657   bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
658     switch (u.format) {
659     case 1: return u.format1->apply (LOOKUP_ARGS, apply_func);
660     case 2: return u.format2->apply (LOOKUP_ARGS, apply_func);
661     case 3: return u.format3->apply (LOOKUP_ARGS, apply_func);
662     default:return false;
663     }
664   }
665
666   private:
667   union {
668   USHORT                format; /* Format identifier */
669   ChainContextFormat1   format1[];
670   ChainContextFormat2   format2[];
671   ChainContextFormat3   format3[];
672   } u;
673 };
674 ASSERT_SIZE (ChainContext, 2);
675
676
677 /*
678  * GSUB/GPOS Common
679  */
680
681 struct GSUBGPOS {
682   static const hb_tag_t GSUBTag         = HB_TAG ('G','S','U','B');
683   static const hb_tag_t GPOSTag         = HB_TAG ('G','P','O','S');
684
685   STATIC_DEFINE_GET_FOR_DATA (GSUBGPOS);
686   /* XXX check version here? */
687
688   DEFINE_TAG_LIST_INTERFACE (Script,  script ); /* get_script_count (), get_script (i), get_script_tag (i) */
689   DEFINE_TAG_LIST_INTERFACE (Feature, feature); /* get_feature_count(), get_feature(i), get_feature_tag(i) */
690   DEFINE_LIST_INTERFACE     (Lookup,  lookup ); /* get_lookup_count (), get_lookup (i) */
691
692   // LONGTERMTODO bsearch
693   DEFINE_TAG_FIND_INTERFACE (Script,  script ); /* find_script_index (), get_script_by_tag (tag) */
694   DEFINE_TAG_FIND_INTERFACE (Feature, feature); /* find_feature_index(), get_feature_by_tag(tag) */
695
696   private:
697   Fixed_Version version;        /* Version of the GSUB/GPOS table--initially set
698                                  * to 0x00010000 */
699   OffsetTo<ScriptList>
700                 scriptList;     /* ScriptList table */
701   OffsetTo<FeatureList>
702                 featureList;    /* FeatureList table */
703   OffsetTo<LookupList>
704                 lookupList;     /* LookupList table */
705 };
706 ASSERT_SIZE (GSUBGPOS, 10);
707
708
709 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_H */