2 * Copyright (C) 2007,2008,2009 Red Hat, Inc.
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
24 * Red Hat Author(s): Behdad Esfahbod
27 #ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
28 #define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
30 #include "hb-buffer-private.h"
31 #include "hb-ot-layout-gdef-private.hh"
34 #ifndef HB_DEBUG_APPLY
35 #define HB_DEBUG_APPLY HB_DEBUG+0
38 #define TRACE_APPLY() \
39 hb_trace_t<HB_DEBUG_APPLY> trace (&context->debug_depth); \
40 trace.log ("APPLY", HB_FUNC, this);
43 struct hb_apply_context_t
45 hb_ot_layout_context_t *layout;
47 unsigned int context_length;
48 unsigned int nesting_level_left;
49 unsigned int lookup_flag;
50 unsigned int property; /* propety of first glyph (TODO remove) */
51 unsigned int debug_depth;
58 #define BUFFER context->buffer
61 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
62 typedef bool (*apply_lookup_func_t) (hb_apply_context_t *context, unsigned int lookup_index);
67 apply_lookup_func_t apply;
71 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
73 return glyph_id == value;
76 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
78 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
79 return class_def.get_class (glyph_id) == value;
82 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
84 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
85 return (data+coverage) (glyph_id) != NOT_COVERED;
89 static inline bool match_input (hb_apply_context_t *context,
90 unsigned int count, /* Including the first glyph (not matched) */
91 const USHORT input[], /* Array of input values--start with second glyph */
92 match_func_t match_func,
93 const char *match_data,
94 unsigned int *context_length_out)
97 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
98 if (unlikely (context->buffer->in_pos + count > end))
101 for (i = 1, j = context->buffer->in_pos + 1; i < count; i++, j++)
103 while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
105 if (unlikely (j + count - i == end))
110 if (likely (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
114 *context_length_out = j - context->buffer->in_pos;
119 static inline bool match_backtrack (hb_apply_context_t *context,
121 const USHORT backtrack[],
122 match_func_t match_func,
123 const char *match_data)
125 if (unlikely (context->buffer->out_pos < count))
128 for (unsigned int i = 0, j = context->buffer->out_pos - 1; i < count; i++, j--)
130 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
132 if (unlikely (j + 1 == count - i))
137 if (likely (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
144 static inline bool match_lookahead (hb_apply_context_t *context,
146 const USHORT lookahead[],
147 match_func_t match_func,
148 const char *match_data,
152 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
153 if (unlikely (context->buffer->in_pos + offset + count > end))
156 for (i = 0, j = context->buffer->in_pos + offset; i < count; i++, j++)
158 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
160 if (unlikely (j + count - i == end))
165 if (likely (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
175 static inline unsigned int get_size () { return sizeof (LookupRecord); }
177 inline bool sanitize (hb_sanitize_context_t *context) {
179 return SANITIZE_SELF ();
182 USHORT sequenceIndex; /* Index into current glyph
183 * sequence--first glyph = 0 */
184 USHORT lookupListIndex; /* Lookup to apply to that
185 * position--zero--based */
187 ASSERT_SIZE (LookupRecord, 4);
189 static inline bool apply_lookup (hb_apply_context_t *context,
190 unsigned int count, /* Including the first glyph */
191 unsigned int lookupCount,
192 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
193 apply_lookup_func_t apply_func)
195 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
196 if (unlikely (context->buffer->in_pos + count > end))
199 /* TODO We don't support lookupRecord arrays that are not increasing:
200 * Should be easy for in_place ones at least. */
202 /* Note: If sublookup is reverse, i will underflow after the first loop
203 * and we jump out of it. Not entirely disastrous. So we don't check
204 * for reverse lookup here.
206 for (unsigned int i = 0; i < count; /* NOP */)
208 while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
210 if (unlikely (context->buffer->in_pos == end))
212 /* No lookup applied for this index */
213 _hb_buffer_next_glyph (context->buffer);
216 if (lookupCount && i == lookupRecord->sequenceIndex)
218 unsigned int old_pos = context->buffer->in_pos;
221 bool done = apply_func (context, lookupRecord->lookupListIndex);
225 /* Err, this is wrong if the lookup jumped over some glyphs */
226 i += context->buffer->in_pos - old_pos;
227 if (unlikely (context->buffer->in_pos == end))
236 /* No lookup applied for this index */
237 _hb_buffer_next_glyph (context->buffer);
246 /* Contextual lookups */
248 struct ContextLookupContext
251 const char *match_data;
254 static inline bool context_lookup (hb_apply_context_t *context,
255 unsigned int inputCount, /* Including the first glyph (not matched) */
256 const USHORT input[], /* Array of input values--start with second glyph */
257 unsigned int lookupCount,
258 const LookupRecord lookupRecord[],
259 ContextLookupContext &lookup_context)
261 unsigned int new_context_length;
262 if (!match_input (context,
264 lookup_context.funcs.match, lookup_context.match_data,
265 &new_context_length)) return false;
266 unsigned int old_context_length;
267 old_context_length = context->context_length;
268 context->context_length = new_context_length;
269 bool ret = apply_lookup (context,
271 lookupCount, lookupRecord,
272 lookup_context.funcs.apply);
273 context->context_length = old_context_length;
279 friend struct RuleSet;
282 inline bool apply (hb_apply_context_t *context, ContextLookupContext &lookup_context) const
285 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
286 return context_lookup (context,
288 lookupCount, lookupRecord,
293 inline bool sanitize (hb_sanitize_context_t *context) {
295 if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
296 return SANITIZE_MEM (input,
297 input[0].get_size () * inputCount +
298 lookupRecordX[0].get_size () * lookupCount);
302 USHORT inputCount; /* Total number of glyphs in input
303 * glyph sequence--includes the first
305 USHORT lookupCount; /* Number of LookupRecords */
306 USHORT input[VAR]; /* Array of match inputs--start with
308 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
311 ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
315 inline bool apply (hb_apply_context_t *context, ContextLookupContext &lookup_context) const
318 unsigned int num_rules = rule.len;
319 for (unsigned int i = 0; i < num_rules; i++)
321 if ((this+rule[i]).apply (context, lookup_context))
328 inline bool sanitize (hb_sanitize_context_t *context) {
330 return SANITIZE_WITH_BASE (this, rule);
335 rule; /* Array of Rule tables
336 * ordered by preference */
340 struct ContextFormat1
342 friend struct Context;
345 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
348 unsigned int index = (this+coverage) (IN_CURGLYPH ());
349 if (likely (index == NOT_COVERED))
352 const RuleSet &rule_set = this+ruleSet[index];
353 struct ContextLookupContext lookup_context = {
354 {match_glyph, apply_func},
357 return rule_set.apply (context, lookup_context);
360 inline bool sanitize (hb_sanitize_context_t *context) {
362 return SANITIZE_WITH_BASE (this, coverage)
363 && SANITIZE_WITH_BASE (this, ruleSet);
367 USHORT format; /* Format identifier--format = 1 */
369 coverage; /* Offset to Coverage table--from
370 * beginning of table */
371 OffsetArrayOf<RuleSet>
372 ruleSet; /* Array of RuleSet tables
373 * ordered by Coverage Index */
375 ASSERT_SIZE (ContextFormat1, 6);
378 struct ContextFormat2
380 friend struct Context;
383 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
386 unsigned int index = (this+coverage) (IN_CURGLYPH ());
387 if (likely (index == NOT_COVERED))
390 const ClassDef &class_def = this+classDef;
391 index = class_def (IN_CURGLYPH ());
392 const RuleSet &rule_set = this+ruleSet[index];
393 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
394 * them across subrule lookups. Not sure it's worth it.
396 struct ContextLookupContext lookup_context = {
397 {match_class, apply_func},
400 return rule_set.apply (context, lookup_context);
403 inline bool sanitize (hb_sanitize_context_t *context) {
405 return SANITIZE_WITH_BASE (this, coverage)
406 && SANITIZE_WITH_BASE (this, classDef)
407 && SANITIZE_WITH_BASE (this, ruleSet);
411 USHORT format; /* Format identifier--format = 2 */
413 coverage; /* Offset to Coverage table--from
414 * beginning of table */
416 classDef; /* Offset to glyph ClassDef table--from
417 * beginning of table */
418 OffsetArrayOf<RuleSet>
419 ruleSet; /* Array of RuleSet tables
420 * ordered by class */
422 ASSERT_SIZE (ContextFormat2, 8);
425 struct ContextFormat3
427 friend struct Context;
430 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
433 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
434 if (likely (index == NOT_COVERED))
437 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount);
438 struct ContextLookupContext lookup_context = {
439 {match_coverage, apply_func},
442 return context_lookup (context,
443 glyphCount, (const USHORT *) (coverage + 1),
444 lookupCount, lookupRecord,
448 inline bool sanitize (hb_sanitize_context_t *context) {
450 if (!SANITIZE_SELF ()) return false;
451 unsigned int count = glyphCount;
452 if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), glyphCount)) return false;
453 for (unsigned int i = 0; i < count; i++)
454 if (!SANITIZE_WITH_BASE (this, coverage[i])) return false;
455 LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * glyphCount);
456 return SANITIZE_ARRAY (lookupRecord, LookupRecord::get_size (), lookupCount);
460 USHORT format; /* Format identifier--format = 3 */
461 USHORT glyphCount; /* Number of glyphs in the input glyph
463 USHORT lookupCount; /* Number of LookupRecords */
465 coverage[VAR]; /* Array of offsets to Coverage
466 * table in glyph sequence order */
467 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
470 ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
475 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
479 case 1: return u.format1->apply (context, apply_func);
480 case 2: return u.format2->apply (context, apply_func);
481 case 3: return u.format3->apply (context, apply_func);
482 default:return false;
486 inline bool sanitize (hb_sanitize_context_t *context) {
488 if (!SANITIZE (u.format)) return false;
490 case 1: return u.format1->sanitize (context);
491 case 2: return u.format2->sanitize (context);
492 case 3: return u.format3->sanitize (context);
499 USHORT format; /* Format identifier */
500 ContextFormat1 format1[VAR];
501 ContextFormat2 format2[VAR];
502 ContextFormat3 format3[VAR];
507 /* Chaining Contextual lookups */
509 struct ChainContextLookupContext
512 const char *match_data[3];
515 static inline bool chain_context_lookup (hb_apply_context_t *context,
516 unsigned int backtrackCount,
517 const USHORT backtrack[],
518 unsigned int inputCount, /* Including the first glyph (not matched) */
519 const USHORT input[], /* Array of input values--start with second glyph */
520 unsigned int lookaheadCount,
521 const USHORT lookahead[],
522 unsigned int lookupCount,
523 const LookupRecord lookupRecord[],
524 ChainContextLookupContext &lookup_context)
527 if (unlikely (context->buffer->out_pos < backtrackCount ||
528 context->buffer->in_pos + inputCount + lookaheadCount > context->buffer->in_length ||
529 inputCount + lookaheadCount > context->context_length))
533 if (!(match_backtrack (context,
534 backtrackCount, backtrack,
535 lookup_context.funcs.match, lookup_context.match_data[0]) &&
536 match_input (context,
538 lookup_context.funcs.match, lookup_context.match_data[1],
540 match_lookahead (context,
541 lookaheadCount, lookahead,
542 lookup_context.funcs.match, lookup_context.match_data[2],
543 offset))) return false;
545 unsigned int old_context_length;
546 old_context_length = context->context_length;
547 context->context_length = offset;
548 bool ret = apply_lookup (context,
550 lookupCount, lookupRecord,
551 lookup_context.funcs.apply);
552 context->context_length = old_context_length;
558 friend struct ChainRuleSet;
561 inline bool apply (hb_apply_context_t *context, ChainContextLookupContext &lookup_context) const
564 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
565 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
566 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
567 return chain_context_lookup (context,
568 backtrack.len, backtrack.array(),
569 input.len, input.array(),
570 lookahead.len, lookahead.array(),
571 lookup.len, lookup.array(),
577 inline bool sanitize (hb_sanitize_context_t *context) {
579 if (!SANITIZE (backtrack)) return false;
580 HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
581 if (!SANITIZE (input)) return false;
582 ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
583 if (!SANITIZE (lookahead)) return false;
584 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
585 return SANITIZE (lookup);
590 backtrack; /* Array of backtracking values
591 * (to be matched before the input
593 HeadlessArrayOf<USHORT>
594 inputX; /* Array of input values (start with
597 lookaheadX; /* Array of lookahead values's (to be
598 * matched after the input sequence) */
599 ArrayOf<LookupRecord>
600 lookupX; /* Array of LookupRecords--in
603 ASSERT_SIZE (ChainRule, 8);
607 inline bool apply (hb_apply_context_t *context, ChainContextLookupContext &lookup_context) const
610 unsigned int num_rules = rule.len;
611 for (unsigned int i = 0; i < num_rules; i++)
613 if ((this+rule[i]).apply (context, lookup_context))
620 inline bool sanitize (hb_sanitize_context_t *context) {
622 return SANITIZE_WITH_BASE (this, rule);
626 OffsetArrayOf<ChainRule>
627 rule; /* Array of ChainRule tables
628 * ordered by preference */
630 ASSERT_SIZE (ChainRuleSet, 2);
632 struct ChainContextFormat1
634 friend struct ChainContext;
637 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
640 unsigned int index = (this+coverage) (IN_CURGLYPH ());
641 if (likely (index == NOT_COVERED))
644 const ChainRuleSet &rule_set = this+ruleSet[index];
645 struct ChainContextLookupContext lookup_context = {
646 {match_glyph, apply_func},
649 return rule_set.apply (context, lookup_context);
652 inline bool sanitize (hb_sanitize_context_t *context) {
654 return SANITIZE_WITH_BASE (this, coverage)
655 && SANITIZE_WITH_BASE (this, ruleSet);
659 USHORT format; /* Format identifier--format = 1 */
661 coverage; /* Offset to Coverage table--from
662 * beginning of table */
663 OffsetArrayOf<ChainRuleSet>
664 ruleSet; /* Array of ChainRuleSet tables
665 * ordered by Coverage Index */
667 ASSERT_SIZE (ChainContextFormat1, 6);
669 struct ChainContextFormat2
671 friend struct ChainContext;
674 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
677 unsigned int index = (this+coverage) (IN_CURGLYPH ());
678 if (likely (index == NOT_COVERED))
681 const ClassDef &backtrack_class_def = this+backtrackClassDef;
682 const ClassDef &input_class_def = this+inputClassDef;
683 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
685 index = input_class_def (IN_CURGLYPH ());
686 const ChainRuleSet &rule_set = this+ruleSet[index];
687 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
688 * them across subrule lookups. Not sure it's worth it.
690 struct ChainContextLookupContext lookup_context = {
691 {match_class, apply_func},
692 {CharP(&backtrack_class_def),
693 CharP(&input_class_def),
694 CharP(&lookahead_class_def)}
696 return rule_set.apply (context, lookup_context);
699 inline bool sanitize (hb_sanitize_context_t *context) {
701 return SANITIZE_WITH_BASE (this, coverage)
702 && SANITIZE_WITH_BASE (this, backtrackClassDef)
703 && SANITIZE_WITH_BASE (this, inputClassDef)
704 && SANITIZE_WITH_BASE (this, lookaheadClassDef)
705 && SANITIZE_WITH_BASE (this, ruleSet);
709 USHORT format; /* Format identifier--format = 2 */
711 coverage; /* Offset to Coverage table--from
712 * beginning of table */
714 backtrackClassDef; /* Offset to glyph ClassDef table
715 * containing backtrack sequence
716 * data--from beginning of table */
718 inputClassDef; /* Offset to glyph ClassDef
719 * table containing input sequence
720 * data--from beginning of table */
722 lookaheadClassDef; /* Offset to glyph ClassDef table
723 * containing lookahead sequence
724 * data--from beginning of table */
725 OffsetArrayOf<ChainRuleSet>
726 ruleSet; /* Array of ChainRuleSet tables
727 * ordered by class */
729 ASSERT_SIZE (ChainContextFormat2, 12);
731 struct ChainContextFormat3
733 friend struct ChainContext;
737 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
740 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
742 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
743 if (likely (index == NOT_COVERED))
746 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
747 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
748 struct ChainContextLookupContext lookup_context = {
749 {match_coverage, apply_func},
750 {CharP(this), CharP(this), CharP(this)}
752 return chain_context_lookup (context,
753 backtrack.len, (const USHORT *) backtrack.array(),
754 input.len, (const USHORT *) input.array() + 1,
755 lookahead.len, (const USHORT *) lookahead.array(),
756 lookup.len, lookup.array(),
761 inline bool sanitize (hb_sanitize_context_t *context) {
763 if (!SANITIZE_WITH_BASE (this, backtrack)) return false;
764 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
765 if (!SANITIZE_WITH_BASE (this, input)) return false;
766 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
767 if (!SANITIZE_WITH_BASE (this, lookahead)) return false;
768 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
769 return SANITIZE (lookup);
773 USHORT format; /* Format identifier--format = 3 */
774 OffsetArrayOf<Coverage>
775 backtrack; /* Array of coverage tables
776 * in backtracking sequence, in glyph
778 OffsetArrayOf<Coverage>
779 inputX ; /* Array of coverage
780 * tables in input sequence, in glyph
782 OffsetArrayOf<Coverage>
783 lookaheadX; /* Array of coverage tables
784 * in lookahead sequence, in glyph
786 ArrayOf<LookupRecord>
787 lookupX; /* Array of LookupRecords--in
790 ASSERT_SIZE (ChainContextFormat3, 10);
795 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
799 case 1: return u.format1->apply (context, apply_func);
800 case 2: return u.format2->apply (context, apply_func);
801 case 3: return u.format3->apply (context, apply_func);
802 default:return false;
806 inline bool sanitize (hb_sanitize_context_t *context) {
808 if (!SANITIZE (u.format)) return false;
810 case 1: return u.format1->sanitize (context);
811 case 2: return u.format2->sanitize (context);
812 case 3: return u.format3->sanitize (context);
819 USHORT format; /* Format identifier */
820 ChainContextFormat1 format1[VAR];
821 ChainContextFormat2 format2[VAR];
822 ChainContextFormat3 format3[VAR];
827 struct ExtensionFormat1
829 friend struct Extension;
832 inline unsigned int get_type (void) const { return extensionLookupType; }
833 inline unsigned int get_offset (void) const { return extensionOffset; }
835 inline bool sanitize (hb_sanitize_context_t *context) {
837 return SANITIZE_SELF ();
841 USHORT format; /* Format identifier. Set to 1. */
842 USHORT extensionLookupType; /* Lookup type of subtable referenced
843 * by ExtensionOffset (i.e. the
844 * extension subtable). */
845 ULONG extensionOffset; /* Offset to the extension subtable,
846 * of lookup type subtable. */
848 ASSERT_SIZE (ExtensionFormat1, 8);
852 inline unsigned int get_type (void) const
855 case 1: return u.format1->get_type ();
859 inline unsigned int get_offset (void) const
862 case 1: return u.format1->get_offset ();
867 inline bool sanitize (hb_sanitize_context_t *context) {
869 if (!SANITIZE (u.format)) return false;
871 case 1: return u.format1->sanitize (context);
878 USHORT format; /* Format identifier */
879 ExtensionFormat1 format1[VAR];
890 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
891 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
893 inline unsigned int get_script_count (void) const
894 { return (this+scriptList).len; }
895 inline const Tag& get_script_tag (unsigned int i) const
896 { return (this+scriptList).get_tag (i); }
897 inline unsigned int get_script_tags (unsigned int start_offset,
898 unsigned int *script_count /* IN/OUT */,
899 hb_tag_t *script_tags /* OUT */) const
900 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
901 inline const Script& get_script (unsigned int i) const
902 { return (this+scriptList)[i]; }
903 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
904 { return (this+scriptList).find_index (tag, index); }
906 inline unsigned int get_feature_count (void) const
907 { return (this+featureList).len; }
908 inline const Tag& get_feature_tag (unsigned int i) const
909 { return (this+featureList).get_tag (i); }
910 inline unsigned int get_feature_tags (unsigned int start_offset,
911 unsigned int *feature_count /* IN/OUT */,
912 hb_tag_t *feature_tags /* OUT */) const
913 { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); }
914 inline const Feature& get_feature (unsigned int i) const
915 { return (this+featureList)[i]; }
916 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
917 { return (this+featureList).find_index (tag, index); }
919 inline unsigned int get_lookup_count (void) const
920 { return (this+lookupList).len; }
921 inline const Lookup& get_lookup (unsigned int i) const
922 { return (this+lookupList)[i]; }
924 inline bool sanitize (hb_sanitize_context_t *context) {
926 return SANITIZE (version) && likely (version.major == 1)
927 && SANITIZE_WITH_BASE (this, scriptList)
928 && SANITIZE_WITH_BASE (this, featureList)
929 && SANITIZE_WITH_BASE (this, lookupList);
933 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
936 scriptList; /* ScriptList table */
937 OffsetTo<FeatureList>
938 featureList; /* FeatureList table */
940 lookupList; /* LookupList table */
942 ASSERT_SIZE (GSUBGPOS, 10);
945 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */