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() \
41 _hb_trace ("APPLY", HB_FUNC, this, apply_depth, HB_DEBUG_APPLY); \
45 #define APPLY_ARG_DEF \
46 hb_apply_context_t *context, \
47 hb_ot_layout_context_t *layout_context, \
48 hb_buffer_t *buffer, \
49 unsigned int context_length HB_UNUSED, \
50 unsigned int apply_depth HB_UNUSED
56 (HB_DEBUG_APPLY ? apply_depth + 1 : 0)
58 struct hb_apply_context_t
60 unsigned int nesting_level_left;
61 unsigned int lookup_flag;
62 unsigned int property; /* propety of first glyph (TODO remove) */
66 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
67 typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
72 apply_lookup_func_t apply;
76 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
78 return glyph_id == value;
81 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
83 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
84 return class_def.get_class (glyph_id) == value;
87 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
89 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
90 return (data+coverage) (glyph_id) != NOT_COVERED;
94 static inline bool match_input (APPLY_ARG_DEF,
95 unsigned int count, /* Including the first glyph (not matched) */
96 const USHORT input[], /* Array of input values--start with second glyph */
97 match_func_t match_func,
98 const char *match_data,
99 unsigned int *context_length_out)
102 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
103 if (unlikely (buffer->in_pos + count > end))
106 for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
108 while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
110 if (unlikely (j + count - i == end))
115 if (likely (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
119 *context_length_out = j - buffer->in_pos;
124 static inline bool match_backtrack (APPLY_ARG_DEF,
126 const USHORT backtrack[],
127 match_func_t match_func,
128 const char *match_data)
130 if (unlikely (buffer->out_pos < count))
133 for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
135 while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
137 if (unlikely (j + 1 == count - i))
142 if (likely (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
149 static inline bool match_lookahead (APPLY_ARG_DEF,
151 const USHORT lookahead[],
152 match_func_t match_func,
153 const char *match_data,
157 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
158 if (unlikely (buffer->in_pos + offset + count > end))
161 for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
163 while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
165 if (unlikely (j + count - i == end))
170 if (likely (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
180 static inline unsigned int get_size () { return sizeof (LookupRecord); }
182 inline bool sanitize (SANITIZE_ARG_DEF) {
184 return SANITIZE_SELF ();
187 USHORT sequenceIndex; /* Index into current glyph
188 * sequence--first glyph = 0 */
189 USHORT lookupListIndex; /* Lookup to apply to that
190 * position--zero--based */
192 ASSERT_SIZE (LookupRecord, 4);
194 static inline bool apply_lookup (APPLY_ARG_DEF,
195 unsigned int count, /* Including the first glyph */
196 unsigned int lookupCount,
197 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
198 apply_lookup_func_t apply_func)
200 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
201 if (unlikely (buffer->in_pos + count > end))
204 /* TODO We don't support lookupRecord arrays that are not increasing:
205 * Should be easy for in_place ones at least. */
207 /* Note: If sublookup is reverse, i will underflow after the first loop
208 * and we jump out of it. Not entirely disastrous. So we don't check
209 * for reverse lookup here.
211 for (unsigned int i = 0; i < count; /* NOP */)
213 while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), context->lookup_flag, NULL))
215 if (unlikely (buffer->in_pos == end))
217 /* No lookup applied for this index */
218 _hb_buffer_next_glyph (buffer);
221 if (lookupCount && i == lookupRecord->sequenceIndex)
223 unsigned int old_pos = buffer->in_pos;
226 bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex);
230 /* Err, this is wrong if the lookup jumped over some glyphs */
231 i += buffer->in_pos - old_pos;
232 if (unlikely (buffer->in_pos == end))
241 /* No lookup applied for this index */
242 _hb_buffer_next_glyph (buffer);
251 /* Contextual lookups */
253 struct ContextLookupContext
256 const char *match_data;
259 static inline bool context_lookup (APPLY_ARG_DEF,
260 unsigned int inputCount, /* Including the first glyph (not matched) */
261 const USHORT input[], /* Array of input values--start with second glyph */
262 unsigned int lookupCount,
263 const LookupRecord lookupRecord[],
264 ContextLookupContext &lookup_context)
266 return match_input (APPLY_ARG,
268 lookup_context.funcs.match, lookup_context.match_data,
270 apply_lookup (APPLY_ARG,
272 lookupCount, lookupRecord,
273 lookup_context.funcs.apply);
278 friend struct RuleSet;
281 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
284 const LookupRecord &lookupRecord = StructAtOffset<LookupRecord> (input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
285 return context_lookup (APPLY_ARG,
287 lookupCount, &lookupRecord,
292 inline bool sanitize (SANITIZE_ARG_DEF) {
294 if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
295 return SANITIZE_MEM (input,
296 input[0].get_size () * inputCount +
297 lookupRecordX[0].get_size () * lookupCount);
301 USHORT inputCount; /* Total number of glyphs in input
302 * glyph sequence--includes the first
304 USHORT lookupCount; /* Number of LookupRecords */
305 USHORT input[VAR]; /* Array of match inputs--start with
307 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
310 ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
314 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
317 unsigned int num_rules = rule.len;
318 for (unsigned int i = 0; i < num_rules; i++)
320 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
327 inline bool sanitize (SANITIZE_ARG_DEF) {
329 return SANITIZE_THIS (rule);
334 rule; /* Array of Rule tables
335 * ordered by preference */
339 struct ContextFormat1
341 friend struct Context;
344 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
347 unsigned int index = (this+coverage) (IN_CURGLYPH ());
348 if (likely (index == NOT_COVERED))
351 const RuleSet &rule_set = this+ruleSet[index];
352 struct ContextLookupContext lookup_context = {
353 {match_glyph, apply_func},
356 return rule_set.apply (APPLY_ARG, lookup_context);
359 inline bool sanitize (SANITIZE_ARG_DEF) {
361 return SANITIZE_THIS2 (coverage, ruleSet);
365 USHORT format; /* Format identifier--format = 1 */
367 coverage; /* Offset to Coverage table--from
368 * beginning of table */
369 OffsetArrayOf<RuleSet>
370 ruleSet; /* Array of RuleSet tables
371 * ordered by Coverage Index */
373 ASSERT_SIZE (ContextFormat1, 6);
376 struct ContextFormat2
378 friend struct Context;
381 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
384 unsigned int index = (this+coverage) (IN_CURGLYPH ());
385 if (likely (index == NOT_COVERED))
388 const ClassDef &class_def = this+classDef;
389 index = class_def (IN_CURGLYPH ());
390 const RuleSet &rule_set = this+ruleSet[index];
391 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
392 * them across subrule lookups. Not sure it's worth it.
394 struct ContextLookupContext lookup_context = {
395 {match_class, apply_func},
398 return rule_set.apply (APPLY_ARG, lookup_context);
401 inline bool sanitize (SANITIZE_ARG_DEF) {
403 return SANITIZE_THIS (coverage)
404 && SANITIZE_THIS (classDef)
405 && SANITIZE_THIS (ruleSet);
409 USHORT format; /* Format identifier--format = 2 */
411 coverage; /* Offset to Coverage table--from
412 * beginning of table */
414 classDef; /* Offset to glyph ClassDef table--from
415 * beginning of table */
416 OffsetArrayOf<RuleSet>
417 ruleSet; /* Array of RuleSet tables
418 * ordered by class */
420 ASSERT_SIZE (ContextFormat2, 8);
423 struct ContextFormat3
425 friend struct Context;
428 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
431 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
432 if (likely (index == NOT_COVERED))
435 const LookupRecord &lookupRecord = StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount);
436 struct ContextLookupContext lookup_context = {
437 {match_coverage, apply_func},
440 return context_lookup (APPLY_ARG,
441 glyphCount, (const USHORT *) (coverage + 1),
442 lookupCount, &lookupRecord,
446 inline bool sanitize (SANITIZE_ARG_DEF) {
448 if (!SANITIZE_SELF ()) return false;
449 unsigned int count = glyphCount;
450 if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), glyphCount)) return false;
451 for (unsigned int i = 0; i < count; i++)
452 if (!SANITIZE_THIS (coverage[i])) return false;
453 LookupRecord &lookupRecord = StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * glyphCount);
454 return SANITIZE_ARRAY (&lookupRecord, LookupRecord::get_size (), lookupCount);
458 USHORT format; /* Format identifier--format = 3 */
459 USHORT glyphCount; /* Number of glyphs in the input glyph
461 USHORT lookupCount; /* Number of LookupRecords */
463 coverage[VAR]; /* Array of offsets to Coverage
464 * table in glyph sequence order */
465 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
468 ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
473 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
477 case 1: return u.format1->apply (APPLY_ARG, apply_func);
478 case 2: return u.format2->apply (APPLY_ARG, apply_func);
479 case 3: return u.format3->apply (APPLY_ARG, apply_func);
480 default:return false;
484 inline bool sanitize (SANITIZE_ARG_DEF) {
486 if (!SANITIZE (u.format)) return false;
488 case 1: return u.format1->sanitize (SANITIZE_ARG);
489 case 2: return u.format2->sanitize (SANITIZE_ARG);
490 case 3: return u.format3->sanitize (SANITIZE_ARG);
497 USHORT format; /* Format identifier */
498 ContextFormat1 format1[VAR];
499 ContextFormat2 format2[VAR];
500 ContextFormat3 format3[VAR];
505 /* Chaining Contextual lookups */
507 struct ChainContextLookupContext
510 const char *match_data[3];
513 static inline bool chain_context_lookup (APPLY_ARG_DEF,
514 unsigned int backtrackCount,
515 const USHORT backtrack[],
516 unsigned int inputCount, /* Including the first glyph (not matched) */
517 const USHORT input[], /* Array of input values--start with second glyph */
518 unsigned int lookaheadCount,
519 const USHORT lookahead[],
520 unsigned int lookupCount,
521 const LookupRecord lookupRecord[],
522 ChainContextLookupContext &lookup_context)
525 if (unlikely (buffer->out_pos < backtrackCount ||
526 buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
527 inputCount + lookaheadCount > context_length))
531 return match_backtrack (APPLY_ARG,
532 backtrackCount, backtrack,
533 lookup_context.funcs.match, lookup_context.match_data[0]) &&
534 match_input (APPLY_ARG,
536 lookup_context.funcs.match, lookup_context.match_data[1],
538 match_lookahead (APPLY_ARG,
539 lookaheadCount, lookahead,
540 lookup_context.funcs.match, lookup_context.match_data[2],
542 (context_length = offset, true) &&
543 apply_lookup (APPLY_ARG,
545 lookupCount, lookupRecord,
546 lookup_context.funcs.apply);
551 friend struct ChainRuleSet;
554 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
557 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
558 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
559 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
560 return chain_context_lookup (APPLY_ARG,
561 backtrack.len, backtrack.array(),
562 input.len, input.array(),
563 lookahead.len, lookahead.array(),
564 lookup.len, lookup.array(),
570 inline bool sanitize (SANITIZE_ARG_DEF) {
572 if (!SANITIZE (backtrack)) return false;
573 HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
574 if (!SANITIZE (input)) return false;
575 ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
576 if (!SANITIZE (lookahead)) return false;
577 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
578 return SANITIZE (lookup);
583 backtrack; /* Array of backtracking values
584 * (to be matched before the input
586 HeadlessArrayOf<USHORT>
587 inputX; /* Array of input values (start with
590 lookaheadX; /* Array of lookahead values's (to be
591 * matched after the input sequence) */
592 ArrayOf<LookupRecord>
593 lookupX; /* Array of LookupRecords--in
596 ASSERT_SIZE (ChainRule, 8);
600 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
603 unsigned int num_rules = rule.len;
604 for (unsigned int i = 0; i < num_rules; i++)
606 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
613 inline bool sanitize (SANITIZE_ARG_DEF) {
615 return SANITIZE_THIS (rule);
619 OffsetArrayOf<ChainRule>
620 rule; /* Array of ChainRule tables
621 * ordered by preference */
623 ASSERT_SIZE (ChainRuleSet, 2);
625 struct ChainContextFormat1
627 friend struct ChainContext;
630 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
633 unsigned int index = (this+coverage) (IN_CURGLYPH ());
634 if (likely (index == NOT_COVERED))
637 const ChainRuleSet &rule_set = this+ruleSet[index];
638 struct ChainContextLookupContext lookup_context = {
639 {match_glyph, apply_func},
642 return rule_set.apply (APPLY_ARG, lookup_context);
645 inline bool sanitize (SANITIZE_ARG_DEF) {
647 return SANITIZE_THIS2 (coverage, ruleSet);
651 USHORT format; /* Format identifier--format = 1 */
653 coverage; /* Offset to Coverage table--from
654 * beginning of table */
655 OffsetArrayOf<ChainRuleSet>
656 ruleSet; /* Array of ChainRuleSet tables
657 * ordered by Coverage Index */
659 ASSERT_SIZE (ChainContextFormat1, 6);
661 struct ChainContextFormat2
663 friend struct ChainContext;
666 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
669 unsigned int index = (this+coverage) (IN_CURGLYPH ());
670 if (likely (index == NOT_COVERED))
673 const ClassDef &backtrack_class_def = this+backtrackClassDef;
674 const ClassDef &input_class_def = this+inputClassDef;
675 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
677 index = input_class_def (IN_CURGLYPH ());
678 const ChainRuleSet &rule_set = this+ruleSet[index];
679 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
680 * them across subrule lookups. Not sure it's worth it.
682 struct ChainContextLookupContext lookup_context = {
683 {match_class, apply_func},
684 {CharP(&backtrack_class_def),
685 CharP(&input_class_def),
686 CharP(&lookahead_class_def)}
688 return rule_set.apply (APPLY_ARG, lookup_context);
691 inline bool sanitize (SANITIZE_ARG_DEF) {
693 return SANITIZE_THIS2 (coverage, backtrackClassDef) &&
694 SANITIZE_THIS2 (inputClassDef, lookaheadClassDef) &&
695 SANITIZE_THIS (ruleSet);
699 USHORT format; /* Format identifier--format = 2 */
701 coverage; /* Offset to Coverage table--from
702 * beginning of table */
704 backtrackClassDef; /* Offset to glyph ClassDef table
705 * containing backtrack sequence
706 * data--from beginning of table */
708 inputClassDef; /* Offset to glyph ClassDef
709 * table containing input sequence
710 * data--from beginning of table */
712 lookaheadClassDef; /* Offset to glyph ClassDef table
713 * containing lookahead sequence
714 * data--from beginning of table */
715 OffsetArrayOf<ChainRuleSet>
716 ruleSet; /* Array of ChainRuleSet tables
717 * ordered by class */
719 ASSERT_SIZE (ChainContextFormat2, 12);
721 struct ChainContextFormat3
723 friend struct ChainContext;
727 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
730 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
732 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
733 if (likely (index == NOT_COVERED))
736 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
737 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
738 struct ChainContextLookupContext lookup_context = {
739 {match_coverage, apply_func},
740 {CharP(this), CharP(this), CharP(this)}
742 return chain_context_lookup (APPLY_ARG,
743 backtrack.len, (const USHORT *) backtrack.array(),
744 input.len, (const USHORT *) input.array() + 1,
745 lookahead.len, (const USHORT *) lookahead.array(),
746 lookup.len, lookup.array(),
751 inline bool sanitize (SANITIZE_ARG_DEF) {
753 if (!SANITIZE_THIS (backtrack)) return false;
754 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
755 if (!SANITIZE_THIS (input)) return false;
756 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
757 if (!SANITIZE_THIS (lookahead)) return false;
758 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
759 return SANITIZE (lookup);
763 USHORT format; /* Format identifier--format = 3 */
764 OffsetArrayOf<Coverage>
765 backtrack; /* Array of coverage tables
766 * in backtracking sequence, in glyph
768 OffsetArrayOf<Coverage>
769 inputX ; /* Array of coverage
770 * tables in input sequence, in glyph
772 OffsetArrayOf<Coverage>
773 lookaheadX; /* Array of coverage tables
774 * in lookahead sequence, in glyph
776 ArrayOf<LookupRecord>
777 lookupX; /* Array of LookupRecords--in
780 ASSERT_SIZE (ChainContextFormat3, 10);
785 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
789 case 1: return u.format1->apply (APPLY_ARG, apply_func);
790 case 2: return u.format2->apply (APPLY_ARG, apply_func);
791 case 3: return u.format3->apply (APPLY_ARG, apply_func);
792 default:return false;
796 inline bool sanitize (SANITIZE_ARG_DEF) {
798 if (!SANITIZE (u.format)) return false;
800 case 1: return u.format1->sanitize (SANITIZE_ARG);
801 case 2: return u.format2->sanitize (SANITIZE_ARG);
802 case 3: return u.format3->sanitize (SANITIZE_ARG);
809 USHORT format; /* Format identifier */
810 ChainContextFormat1 format1[VAR];
811 ChainContextFormat2 format2[VAR];
812 ChainContextFormat3 format3[VAR];
817 struct ExtensionFormat1
819 friend struct Extension;
822 inline unsigned int get_type (void) const { return extensionLookupType; }
823 inline unsigned int get_offset (void) const { return extensionOffset; }
825 inline bool sanitize (SANITIZE_ARG_DEF) {
827 return SANITIZE_SELF ();
831 USHORT format; /* Format identifier. Set to 1. */
832 USHORT extensionLookupType; /* Lookup type of subtable referenced
833 * by ExtensionOffset (i.e. the
834 * extension subtable). */
835 ULONG extensionOffset; /* Offset to the extension subtable,
836 * of lookup type subtable. */
838 ASSERT_SIZE (ExtensionFormat1, 8);
842 inline unsigned int get_type (void) const
845 case 1: return u.format1->get_type ();
849 inline unsigned int get_offset (void) const
852 case 1: return u.format1->get_offset ();
857 inline bool sanitize (SANITIZE_ARG_DEF) {
859 if (!SANITIZE (u.format)) return false;
861 case 1: return u.format1->sanitize (SANITIZE_ARG);
868 USHORT format; /* Format identifier */
869 ExtensionFormat1 format1[VAR];
880 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
881 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
883 inline unsigned int get_script_count (void) const
884 { return (this+scriptList).len; }
885 inline const Tag& get_script_tag (unsigned int i) const
886 { return (this+scriptList).get_tag (i); }
887 inline unsigned int get_script_tags (unsigned int start_offset,
888 unsigned int *script_count /* IN/OUT */,
889 hb_tag_t *script_tags /* OUT */) const
890 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
891 inline const Script& get_script (unsigned int i) const
892 { return (this+scriptList)[i]; }
893 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
894 { return (this+scriptList).find_index (tag, index); }
896 inline unsigned int get_feature_count (void) const
897 { return (this+featureList).len; }
898 inline const Tag& get_feature_tag (unsigned int i) const
899 { return (this+featureList).get_tag (i); }
900 inline unsigned int get_feature_tags (unsigned int start_offset,
901 unsigned int *feature_count /* IN/OUT */,
902 hb_tag_t *feature_tags /* OUT */) const
903 { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); }
904 inline const Feature& get_feature (unsigned int i) const
905 { return (this+featureList)[i]; }
906 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
907 { return (this+featureList).find_index (tag, index); }
909 inline unsigned int get_lookup_count (void) const
910 { return (this+lookupList).len; }
911 inline const Lookup& get_lookup (unsigned int i) const
912 { return (this+lookupList)[i]; }
914 inline bool sanitize (SANITIZE_ARG_DEF) {
916 if (!SANITIZE (version)) return false;
917 if (unlikely (version.major != 1)) return false;
918 return SANITIZE_THIS (scriptList)
919 && SANITIZE_THIS (featureList)
920 && SANITIZE_THIS (lookupList);
924 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
927 scriptList; /* ScriptList table */
928 OffsetTo<FeatureList>
929 featureList; /* FeatureList table */
931 lookupList; /* LookupList table */
933 ASSERT_SIZE (GSUBGPOS, 10);
936 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */