2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc.
3 * Copyright © 2010 Google, Inc.
5 * This is part of HarfBuzz, a text shaping library.
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 * Red Hat Author(s): Behdad Esfahbod
26 * Google Author(s): Behdad Esfahbod
29 #ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
30 #define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
32 #include "hb-buffer-private.hh"
33 #include "hb-ot-layout-gdef-private.hh"
38 /* buffer var allocations */
39 #define lig_id() var2.u16[0] /* unique ligature id */
40 #define lig_comp() var2.u16[1] /* component number in the ligature (0 = base) */
43 #ifndef HB_DEBUG_APPLY
44 #define HB_DEBUG_APPLY (HB_DEBUG+0)
47 #define TRACE_APPLY() \
48 hb_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", HB_FUNC, this); \
53 struct hb_apply_context_t
55 unsigned int debug_depth;
59 hb_direction_t direction;
60 hb_mask_t lookup_mask;
61 unsigned int context_length;
62 unsigned int nesting_level_left;
63 unsigned int lookup_props;
64 unsigned int property; /* propety of first glyph */
67 inline void replace_glyph (hb_codepoint_t glyph_index) const
70 buffer->replace_glyph (glyph_index);
72 inline void replace_glyphs_be16 (unsigned int num_in,
74 const uint16_t *glyph_data_be) const
77 buffer->replace_glyphs_be16 (num_in, num_out, glyph_data_be);
80 inline void guess_glyph_class (unsigned int klass)
82 /* XXX if ! has gdef */
83 buffer->info[buffer->i].props_cache() = klass;
87 inline void clear_property (void) const
90 buffer->info[buffer->i].props_cache() = 0;
96 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const void *data);
97 typedef bool (*apply_lookup_func_t) (hb_apply_context_t *c, unsigned int lookup_index);
102 apply_lookup_func_t apply;
106 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED)
108 return glyph_id == value;
111 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
113 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
114 return class_def.get_class (glyph_id) == value;
117 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
119 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
120 return (data+coverage) (glyph_id) != NOT_COVERED;
124 static inline bool match_input (hb_apply_context_t *c,
125 unsigned int count, /* Including the first glyph (not matched) */
126 const USHORT input[], /* Array of input values--start with second glyph */
127 match_func_t match_func,
128 const void *match_data,
129 unsigned int *context_length_out)
132 unsigned int end = MIN (c->buffer->len, c->buffer->i + c->context_length);
133 if (unlikely (c->buffer->i + count > end))
136 for (i = 1, j = c->buffer->i + 1; i < count; i++, j++)
138 while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, NULL))
140 if (unlikely (j + count - i == end))
145 if (likely (!match_func (c->buffer->info[j].codepoint, input[i - 1], match_data)))
149 *context_length_out = j - c->buffer->i;
154 static inline bool match_backtrack (hb_apply_context_t *c,
156 const USHORT backtrack[],
157 match_func_t match_func,
158 const void *match_data)
160 if (unlikely (c->buffer->backtrack_len () < count))
163 for (unsigned int i = 0, j = c->buffer->backtrack_len () - 1; i < count; i++, j--)
165 while (_hb_ot_layout_skip_mark (c->face, &c->buffer->out_info[j], c->lookup_props, NULL))
167 if (unlikely (j + 1 == count - i))
172 if (likely (!match_func (c->buffer->out_info[j].codepoint, backtrack[i], match_data)))
179 static inline bool match_lookahead (hb_apply_context_t *c,
181 const USHORT lookahead[],
182 match_func_t match_func,
183 const void *match_data,
187 unsigned int end = MIN (c->buffer->len, c->buffer->i + c->context_length);
188 if (unlikely (c->buffer->i + offset + count > end))
191 for (i = 0, j = c->buffer->i + offset; i < count; i++, j++)
193 while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, NULL))
195 if (unlikely (j + count - i == end))
200 if (likely (!match_func (c->buffer->info[j].codepoint, lookahead[i], match_data)))
212 inline bool sanitize (hb_sanitize_context_t *c) {
214 return c->check_struct (this);
217 USHORT sequenceIndex; /* Index into current glyph
218 * sequence--first glyph = 0 */
219 USHORT lookupListIndex; /* Lookup to apply to that
220 * position--zero--based */
222 DEFINE_SIZE_STATIC (4);
228 static inline bool apply_lookup (hb_apply_context_t *c,
229 unsigned int count, /* Including the first glyph */
230 unsigned int lookupCount,
231 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
232 apply_lookup_func_t apply_func)
234 unsigned int end = MIN (c->buffer->len, c->buffer->i + c->context_length);
235 if (unlikely (count == 0 || c->buffer->i + count > end))
238 /* TODO We don't support lookupRecord arrays that are not increasing:
239 * Should be easy for in_place ones at least. */
241 /* Note: If sublookup is reverse, it will underflow after the first loop
242 * and we jump out of it. Not entirely disastrous. So we don't check
243 * for reverse lookup here.
245 for (unsigned int i = 0; i < count; /* NOP */)
247 while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[c->buffer->i], c->lookup_props, NULL))
249 if (unlikely (c->buffer->i == end))
251 /* No lookup applied for this index */
252 c->buffer->next_glyph ();
255 if (lookupCount && i == lookupRecord->sequenceIndex)
257 unsigned int old_pos = c->buffer->i;
260 bool done = apply_func (c, lookupRecord->lookupListIndex);
264 /* Err, this is wrong if the lookup jumped over some glyphs */
265 i += c->buffer->i - old_pos;
266 if (unlikely (c->buffer->i == end))
275 /* No lookup applied for this index */
276 c->buffer->next_glyph ();
287 /* Contextual lookups */
289 struct ContextLookupContext
292 const void *match_data;
295 static inline bool context_lookup (hb_apply_context_t *c,
296 unsigned int inputCount, /* Including the first glyph (not matched) */
297 const USHORT input[], /* Array of input values--start with second glyph */
298 unsigned int lookupCount,
299 const LookupRecord lookupRecord[],
300 ContextLookupContext &lookup_context)
302 hb_apply_context_t new_context = *c;
303 return match_input (c,
305 lookup_context.funcs.match, lookup_context.match_data,
306 &new_context.context_length)
307 && apply_lookup (&new_context,
309 lookupCount, lookupRecord,
310 lookup_context.funcs.apply);
315 friend struct RuleSet;
318 inline bool apply (hb_apply_context_t *c, ContextLookupContext &lookup_context) const
321 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0));
322 return context_lookup (c,
324 lookupCount, lookupRecord,
329 inline bool sanitize (hb_sanitize_context_t *c) {
331 return inputCount.sanitize (c)
332 && lookupCount.sanitize (c)
333 && c->check_range (input,
334 input[0].static_size * inputCount
335 + lookupRecordX[0].static_size * lookupCount);
339 USHORT inputCount; /* Total number of glyphs in input
340 * glyph sequence--includes the first
342 USHORT lookupCount; /* Number of LookupRecords */
343 USHORT input[VAR]; /* Array of match inputs--start with
345 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
348 DEFINE_SIZE_ARRAY2 (4, input, lookupRecordX);
353 inline bool apply (hb_apply_context_t *c, ContextLookupContext &lookup_context) const
356 unsigned int num_rules = rule.len;
357 for (unsigned int i = 0; i < num_rules; i++)
359 if ((this+rule[i]).apply (c, lookup_context))
366 inline bool sanitize (hb_sanitize_context_t *c) {
368 return rule.sanitize (c, this);
373 rule; /* Array of Rule tables
374 * ordered by preference */
376 DEFINE_SIZE_ARRAY (2, rule);
380 struct ContextFormat1
382 friend struct Context;
385 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
388 unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
389 if (likely (index == NOT_COVERED))
392 const RuleSet &rule_set = this+ruleSet[index];
393 struct ContextLookupContext lookup_context = {
394 {match_glyph, apply_func},
397 return rule_set.apply (c, lookup_context);
400 inline bool sanitize (hb_sanitize_context_t *c) {
402 return coverage.sanitize (c, this)
403 && ruleSet.sanitize (c, this);
407 USHORT format; /* Format identifier--format = 1 */
409 coverage; /* Offset to Coverage table--from
410 * beginning of table */
411 OffsetArrayOf<RuleSet>
412 ruleSet; /* Array of RuleSet tables
413 * ordered by Coverage Index */
415 DEFINE_SIZE_ARRAY (6, ruleSet);
419 struct ContextFormat2
421 friend struct Context;
424 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
427 unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
428 if (likely (index == NOT_COVERED))
431 const ClassDef &class_def = this+classDef;
432 index = class_def (c->buffer->info[c->buffer->i].codepoint);
433 const RuleSet &rule_set = this+ruleSet[index];
434 struct ContextLookupContext lookup_context = {
435 {match_class, apply_func},
438 return rule_set.apply (c, lookup_context);
441 inline bool sanitize (hb_sanitize_context_t *c) {
443 return coverage.sanitize (c, this)
444 && classDef.sanitize (c, this)
445 && ruleSet.sanitize (c, this);
449 USHORT format; /* Format identifier--format = 2 */
451 coverage; /* Offset to Coverage table--from
452 * beginning of table */
454 classDef; /* Offset to glyph ClassDef table--from
455 * beginning of table */
456 OffsetArrayOf<RuleSet>
457 ruleSet; /* Array of RuleSet tables
458 * ordered by class */
460 DEFINE_SIZE_ARRAY (8, ruleSet);
464 struct ContextFormat3
466 friend struct Context;
469 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
472 unsigned int index = (this+coverage[0]) (c->buffer->info[c->buffer->i].codepoint);
473 if (likely (index == NOT_COVERED))
476 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
477 struct ContextLookupContext lookup_context = {
478 {match_coverage, apply_func},
481 return context_lookup (c,
482 glyphCount, (const USHORT *) (coverage + 1),
483 lookupCount, lookupRecord,
487 inline bool sanitize (hb_sanitize_context_t *c) {
489 if (!c->check_struct (this)) return false;
490 unsigned int count = glyphCount;
491 if (!c->check_array (coverage, coverage[0].static_size, count)) return false;
492 for (unsigned int i = 0; i < count; i++)
493 if (!coverage[i].sanitize (c, this)) return false;
494 LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * count);
495 return c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount);
499 USHORT format; /* Format identifier--format = 3 */
500 USHORT glyphCount; /* Number of glyphs in the input glyph
502 USHORT lookupCount; /* Number of LookupRecords */
504 coverage[VAR]; /* Array of offsets to Coverage
505 * table in glyph sequence order */
506 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
509 DEFINE_SIZE_ARRAY2 (6, coverage, lookupRecordX);
515 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
519 case 1: return u.format1.apply (c, apply_func);
520 case 2: return u.format2.apply (c, apply_func);
521 case 3: return u.format3.apply (c, apply_func);
522 default:return false;
526 inline bool sanitize (hb_sanitize_context_t *c) {
528 if (!u.format.sanitize (c)) return false;
530 case 1: return u.format1.sanitize (c);
531 case 2: return u.format2.sanitize (c);
532 case 3: return u.format3.sanitize (c);
539 USHORT format; /* Format identifier */
540 ContextFormat1 format1;
541 ContextFormat2 format2;
542 ContextFormat3 format3;
547 /* Chaining Contextual lookups */
549 struct ChainContextLookupContext
552 const void *match_data[3];
555 static inline bool chain_context_lookup (hb_apply_context_t *c,
556 unsigned int backtrackCount,
557 const USHORT backtrack[],
558 unsigned int inputCount, /* Including the first glyph (not matched) */
559 const USHORT input[], /* Array of input values--start with second glyph */
560 unsigned int lookaheadCount,
561 const USHORT lookahead[],
562 unsigned int lookupCount,
563 const LookupRecord lookupRecord[],
564 ChainContextLookupContext &lookup_context)
567 if (unlikely (c->buffer->backtrack_len () < backtrackCount ||
568 c->buffer->i + inputCount + lookaheadCount > c->buffer->len ||
569 inputCount + lookaheadCount > c->context_length))
572 hb_apply_context_t new_context = *c;
573 return match_backtrack (c,
574 backtrackCount, backtrack,
575 lookup_context.funcs.match, lookup_context.match_data[0])
578 lookup_context.funcs.match, lookup_context.match_data[1],
579 &new_context.context_length)
580 && match_lookahead (c,
581 lookaheadCount, lookahead,
582 lookup_context.funcs.match, lookup_context.match_data[2],
583 new_context.context_length)
584 && apply_lookup (&new_context,
586 lookupCount, lookupRecord,
587 lookup_context.funcs.apply);
592 friend struct ChainRuleSet;
595 inline bool apply (hb_apply_context_t *c, ChainContextLookupContext &lookup_context) const
598 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
599 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
600 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
601 return chain_context_lookup (c,
602 backtrack.len, backtrack.array,
603 input.len, input.array,
604 lookahead.len, lookahead.array,
605 lookup.len, lookup.array,
610 inline bool sanitize (hb_sanitize_context_t *c) {
612 if (!backtrack.sanitize (c)) return false;
613 HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
614 if (!input.sanitize (c)) return false;
615 ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
616 if (!lookahead.sanitize (c)) return false;
617 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
618 return lookup.sanitize (c);
623 backtrack; /* Array of backtracking values
624 * (to be matched before the input
626 HeadlessArrayOf<USHORT>
627 inputX; /* Array of input values (start with
630 lookaheadX; /* Array of lookahead values's (to be
631 * matched after the input sequence) */
632 ArrayOf<LookupRecord>
633 lookupX; /* Array of LookupRecords--in
641 inline bool apply (hb_apply_context_t *c, ChainContextLookupContext &lookup_context) const
644 unsigned int num_rules = rule.len;
645 for (unsigned int i = 0; i < num_rules; i++)
647 if ((this+rule[i]).apply (c, lookup_context))
654 inline bool sanitize (hb_sanitize_context_t *c) {
656 return rule.sanitize (c, this);
660 OffsetArrayOf<ChainRule>
661 rule; /* Array of ChainRule tables
662 * ordered by preference */
664 DEFINE_SIZE_ARRAY (2, rule);
667 struct ChainContextFormat1
669 friend struct ChainContext;
672 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
675 unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
676 if (likely (index == NOT_COVERED))
679 const ChainRuleSet &rule_set = this+ruleSet[index];
680 struct ChainContextLookupContext lookup_context = {
681 {match_glyph, apply_func},
684 return rule_set.apply (c, lookup_context);
687 inline bool sanitize (hb_sanitize_context_t *c) {
689 return coverage.sanitize (c, this)
690 && ruleSet.sanitize (c, this);
694 USHORT format; /* Format identifier--format = 1 */
696 coverage; /* Offset to Coverage table--from
697 * beginning of table */
698 OffsetArrayOf<ChainRuleSet>
699 ruleSet; /* Array of ChainRuleSet tables
700 * ordered by Coverage Index */
702 DEFINE_SIZE_ARRAY (6, ruleSet);
705 struct ChainContextFormat2
707 friend struct ChainContext;
710 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
713 unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
714 if (likely (index == NOT_COVERED))
717 const ClassDef &backtrack_class_def = this+backtrackClassDef;
718 const ClassDef &input_class_def = this+inputClassDef;
719 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
721 index = input_class_def (c->buffer->info[c->buffer->i].codepoint);
722 const ChainRuleSet &rule_set = this+ruleSet[index];
723 struct ChainContextLookupContext lookup_context = {
724 {match_class, apply_func},
725 {&backtrack_class_def,
727 &lookahead_class_def}
729 return rule_set.apply (c, lookup_context);
732 inline bool sanitize (hb_sanitize_context_t *c) {
734 return coverage.sanitize (c, this)
735 && backtrackClassDef.sanitize (c, this)
736 && inputClassDef.sanitize (c, this)
737 && lookaheadClassDef.sanitize (c, this)
738 && ruleSet.sanitize (c, this);
742 USHORT format; /* Format identifier--format = 2 */
744 coverage; /* Offset to Coverage table--from
745 * beginning of table */
747 backtrackClassDef; /* Offset to glyph ClassDef table
748 * containing backtrack sequence
749 * data--from beginning of table */
751 inputClassDef; /* Offset to glyph ClassDef
752 * table containing input sequence
753 * data--from beginning of table */
755 lookaheadClassDef; /* Offset to glyph ClassDef table
756 * containing lookahead sequence
757 * data--from beginning of table */
758 OffsetArrayOf<ChainRuleSet>
759 ruleSet; /* Array of ChainRuleSet tables
760 * ordered by class */
762 DEFINE_SIZE_ARRAY (12, ruleSet);
765 struct ChainContextFormat3
767 friend struct ChainContext;
771 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
774 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
776 unsigned int index = (this+input[0]) (c->buffer->info[c->buffer->i].codepoint);
777 if (likely (index == NOT_COVERED))
780 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
781 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
782 struct ChainContextLookupContext lookup_context = {
783 {match_coverage, apply_func},
786 return chain_context_lookup (c,
787 backtrack.len, (const USHORT *) backtrack.array,
788 input.len, (const USHORT *) input.array + 1,
789 lookahead.len, (const USHORT *) lookahead.array,
790 lookup.len, lookup.array,
794 inline bool sanitize (hb_sanitize_context_t *c) {
796 if (!backtrack.sanitize (c, this)) return false;
797 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
798 if (!input.sanitize (c, this)) return false;
799 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
800 if (!lookahead.sanitize (c, this)) return false;
801 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
802 return lookup.sanitize (c);
806 USHORT format; /* Format identifier--format = 3 */
807 OffsetArrayOf<Coverage>
808 backtrack; /* Array of coverage tables
809 * in backtracking sequence, in glyph
811 OffsetArrayOf<Coverage>
812 inputX ; /* Array of coverage
813 * tables in input sequence, in glyph
815 OffsetArrayOf<Coverage>
816 lookaheadX; /* Array of coverage tables
817 * in lookahead sequence, in glyph
819 ArrayOf<LookupRecord>
820 lookupX; /* Array of LookupRecords--in
823 DEFINE_SIZE_MIN (10);
829 inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
833 case 1: return u.format1.apply (c, apply_func);
834 case 2: return u.format2.apply (c, apply_func);
835 case 3: return u.format3.apply (c, apply_func);
836 default:return false;
840 inline bool sanitize (hb_sanitize_context_t *c) {
842 if (!u.format.sanitize (c)) return false;
844 case 1: return u.format1.sanitize (c);
845 case 2: return u.format2.sanitize (c);
846 case 3: return u.format3.sanitize (c);
853 USHORT format; /* Format identifier */
854 ChainContextFormat1 format1;
855 ChainContextFormat2 format2;
856 ChainContextFormat3 format3;
861 struct ExtensionFormat1
863 friend struct Extension;
866 inline unsigned int get_type (void) const { return extensionLookupType; }
867 inline unsigned int get_offset (void) const { return extensionOffset; }
869 inline bool sanitize (hb_sanitize_context_t *c) {
871 return c->check_struct (this);
875 USHORT format; /* Format identifier. Set to 1. */
876 USHORT extensionLookupType; /* Lookup type of subtable referenced
877 * by ExtensionOffset (i.e. the
878 * extension subtable). */
879 ULONG extensionOffset; /* Offset to the extension subtable,
880 * of lookup type subtable. */
882 DEFINE_SIZE_STATIC (8);
887 inline unsigned int get_type (void) const
890 case 1: return u.format1.get_type ();
894 inline unsigned int get_offset (void) const
897 case 1: return u.format1.get_offset ();
902 inline bool sanitize (hb_sanitize_context_t *c) {
904 if (!u.format.sanitize (c)) return false;
906 case 1: return u.format1.sanitize (c);
913 USHORT format; /* Format identifier */
914 ExtensionFormat1 format1;
925 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
926 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
928 inline unsigned int get_script_count (void) const
929 { return (this+scriptList).len; }
930 inline const Tag& get_script_tag (unsigned int i) const
931 { return (this+scriptList).get_tag (i); }
932 inline unsigned int get_script_tags (unsigned int start_offset,
933 unsigned int *script_count /* IN/OUT */,
934 hb_tag_t *script_tags /* OUT */) const
935 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
936 inline const Script& get_script (unsigned int i) const
937 { return (this+scriptList)[i]; }
938 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
939 { return (this+scriptList).find_index (tag, index); }
941 inline unsigned int get_feature_count (void) const
942 { return (this+featureList).len; }
943 inline const Tag& get_feature_tag (unsigned int i) const
944 { return (this+featureList).get_tag (i); }
945 inline unsigned int get_feature_tags (unsigned int start_offset,
946 unsigned int *feature_count /* IN/OUT */,
947 hb_tag_t *feature_tags /* OUT */) const
948 { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); }
949 inline const Feature& get_feature (unsigned int i) const
950 { return (this+featureList)[i]; }
951 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
952 { return (this+featureList).find_index (tag, index); }
954 inline unsigned int get_lookup_count (void) const
955 { return (this+lookupList).len; }
956 inline const Lookup& get_lookup (unsigned int i) const
957 { return (this+lookupList)[i]; }
959 inline bool sanitize (hb_sanitize_context_t *c) {
961 return version.sanitize (c) && likely (version.major == 1)
962 && scriptList.sanitize (c, this)
963 && featureList.sanitize (c, this)
964 && lookupList.sanitize (c, this);
968 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
971 scriptList; /* ScriptList table */
972 OffsetTo<FeatureList>
973 featureList; /* FeatureList table */
975 lookupList; /* LookupList table */
977 DEFINE_SIZE_STATIC (10);
983 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */