2 * Copyright (C) 2007,2008,2009 Red Hat, Inc.
4 * This is part of HarfBuzz, an OpenType Layout engine 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
39 #define TRACE_APPLY_ARG_DEF , unsigned int apply_depth
40 #define TRACE_APPLY_ARG , apply_depth + 1
41 #define TRACE_APPLY_ARG_INIT , 1
42 #define TRACE_APPLY() \
44 if (apply_depth < HB_DEBUG_APPLY) \
45 fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \
46 (CONST_CHARP (this) == NullPool) ? 0 : this, \
47 apply_depth, apply_depth, \
48 __PRETTY_FUNCTION__); \
51 #define TRACE_APPLY_ARG_DEF
52 #define TRACE_APPLY_ARG
53 #define TRACE_APPLY_ARG_INIT
54 #define TRACE_APPLY() HB_STMT_START {} HB_STMT_END
57 #define APPLY_ARG_DEF \
58 hb_ot_layout_context_t *context, \
59 hb_buffer_t *buffer, \
60 unsigned int context_length HB_GNUC_UNUSED, \
61 unsigned int nesting_level_left HB_GNUC_UNUSED, \
62 unsigned int lookup_flag, \
63 unsigned int property HB_GNUC_UNUSED /* propety of first glyph */ \
73 #define APPLY_ARG_INIT \
83 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, char *data);
84 typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
89 apply_lookup_func_t apply;
93 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, char *data)
95 return glyph_id == value;
98 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, char *data)
100 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
101 return class_def.get_class (glyph_id) == value;
104 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, char *data)
106 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
107 return (data+coverage) (glyph_id) != NOT_COVERED;
111 static inline bool match_input (APPLY_ARG_DEF,
112 unsigned int count, /* Including the first glyph (not matched) */
113 const USHORT input[], /* Array of input values--start with second glyph */
114 match_func_t match_func,
116 unsigned int *context_length_out)
119 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
120 if (HB_UNLIKELY (buffer->in_pos + count > end))
123 for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
125 while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
127 if (HB_UNLIKELY (j + count - i == end))
132 if (HB_LIKELY (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
136 *context_length_out = j - buffer->in_pos;
141 static inline bool match_backtrack (APPLY_ARG_DEF,
143 const USHORT backtrack[],
144 match_func_t match_func,
147 if (HB_UNLIKELY (buffer->out_pos < count))
150 for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
152 while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
154 if (HB_UNLIKELY (j + 1 == count - i))
159 if (HB_LIKELY (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
166 static inline bool match_lookahead (APPLY_ARG_DEF,
168 const USHORT lookahead[],
169 match_func_t match_func,
174 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
175 if (HB_UNLIKELY (buffer->in_pos + offset + count > end))
178 for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
180 while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
182 if (HB_UNLIKELY (j + count - i == end))
187 if (HB_LIKELY (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
198 inline bool sanitize (SANITIZE_ARG_DEF) {
200 return SANITIZE_SELF ();
203 USHORT sequenceIndex; /* Index into current glyph
204 * sequence--first glyph = 0 */
205 USHORT lookupListIndex; /* Lookup to apply to that
206 * position--zero--based */
208 ASSERT_SIZE (LookupRecord, 4);
210 static inline bool apply_lookup (APPLY_ARG_DEF,
211 unsigned int count, /* Including the first glyph */
212 unsigned int lookupCount,
213 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
214 apply_lookup_func_t apply_func)
216 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
217 if (HB_UNLIKELY (buffer->in_pos + count > end))
220 /* TODO We don't support lookupRecord arrays that are not increasing:
221 * Should be easy for in_place ones at least. */
222 for (unsigned int i = 0; i < count; /* NOP */)
224 while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL))
226 if (HB_UNLIKELY (buffer->in_pos == end))
228 /* No lookup applied for this index */
229 _hb_buffer_next_glyph (buffer);
232 if (lookupCount && i == lookupRecord->sequenceIndex)
234 unsigned int old_pos = buffer->in_pos;
237 bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex);
241 /* Err, this is wrong if the lookup jumped over some glyphs */
242 i += buffer->in_pos - old_pos;
243 if (HB_UNLIKELY (buffer->in_pos == end))
252 /* No lookup applied for this index */
253 _hb_buffer_next_glyph (buffer);
262 /* Contextual lookups */
264 struct ContextLookupContext
270 static inline bool context_lookup (APPLY_ARG_DEF,
271 unsigned int inputCount, /* Including the first glyph (not matched) */
272 const USHORT input[], /* Array of input values--start with second glyph */
273 unsigned int lookupCount,
274 const LookupRecord lookupRecord[],
275 ContextLookupContext &lookup_context)
277 return match_input (APPLY_ARG,
279 lookup_context.funcs.match, lookup_context.match_data,
281 apply_lookup (APPLY_ARG,
283 lookupCount, lookupRecord,
284 lookup_context.funcs.apply);
289 friend struct RuleSet;
292 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
295 const LookupRecord *lookupRecord = &CONST_CAST (LookupRecord, input, sizeof (input[0]) * (inputCount ? inputCount - 1 : 0));
296 return context_lookup (APPLY_ARG,
298 lookupCount, lookupRecord,
303 inline bool sanitize (SANITIZE_ARG_DEF) {
305 if (!SANITIZE_SELF ()) return false;
306 return SANITIZE_MEM (input,
307 sizeof (input[0]) * inputCount +
308 sizeof (lookupRecordX[0]) * lookupCount);
312 USHORT inputCount; /* Total number of glyphs in input
313 * glyph sequence--includes the first
315 USHORT lookupCount; /* Number of LookupRecords */
316 USHORT input[]; /* Array of match inputs--start with
318 LookupRecord lookupRecordX[]; /* Array of LookupRecords--in
321 ASSERT_SIZE (Rule, 4);
325 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
328 unsigned int num_rules = rule.len;
329 for (unsigned int i = 0; i < num_rules; i++)
331 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
338 inline bool sanitize (SANITIZE_ARG_DEF) {
340 return SANITIZE_THIS (rule);
345 rule; /* Array of Rule tables
346 * ordered by preference */
350 struct ContextFormat1
352 friend struct Context;
355 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
358 unsigned int index = (this+coverage) (IN_CURGLYPH ());
359 if (HB_LIKELY (index == NOT_COVERED))
362 const RuleSet &rule_set = this+ruleSet[index];
363 struct ContextLookupContext lookup_context = {
364 {match_glyph, apply_func},
367 return rule_set.apply (APPLY_ARG, lookup_context);
370 inline bool sanitize (SANITIZE_ARG_DEF) {
372 return SANITIZE_THIS2 (coverage, ruleSet);
376 USHORT format; /* Format identifier--format = 1 */
378 coverage; /* Offset to Coverage table--from
379 * beginning of table */
380 OffsetArrayOf<RuleSet>
381 ruleSet; /* Array of RuleSet tables
382 * ordered by Coverage Index */
384 ASSERT_SIZE (ContextFormat1, 6);
387 struct ContextFormat2
389 friend struct Context;
392 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
395 unsigned int index = (this+coverage) (IN_CURGLYPH ());
396 if (HB_LIKELY (index == NOT_COVERED))
399 const ClassDef &class_def = this+classDef;
400 index = class_def (IN_CURGLYPH ());
401 const RuleSet &rule_set = this+ruleSet[index];
402 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
403 * them across subrule lookups. Not sure it's worth it.
405 struct ContextLookupContext lookup_context = {
406 {match_class, apply_func},
407 DECONST_CHARP(&class_def)
409 return rule_set.apply (APPLY_ARG, lookup_context);
412 inline bool sanitize (SANITIZE_ARG_DEF) {
414 return SANITIZE_THIS3 (coverage, classDef, ruleSet);
418 USHORT format; /* Format identifier--format = 2 */
420 coverage; /* Offset to Coverage table--from
421 * beginning of table */
423 classDef; /* Offset to glyph ClassDef table--from
424 * beginning of table */
425 OffsetArrayOf<RuleSet>
426 ruleSet; /* Array of RuleSet tables
427 * ordered by class */
429 ASSERT_SIZE (ContextFormat2, 8);
432 struct ContextFormat3
434 friend struct Context;
437 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
440 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
441 if (HB_LIKELY (index == NOT_COVERED))
444 const LookupRecord *lookupRecord = &CONST_CAST(LookupRecord, coverage, sizeof (coverage[0]) * glyphCount);
445 struct ContextLookupContext lookup_context = {
446 {match_coverage, apply_func},
449 return context_lookup (APPLY_ARG,
450 glyphCount, (const USHORT *) (coverage + 1),
451 lookupCount, lookupRecord,
455 inline bool sanitize (SANITIZE_ARG_DEF) {
457 if (!SANITIZE_SELF ()) return false;
458 unsigned int count = glyphCount;
459 for (unsigned int i = 0; i < count; i++)
460 if (!SANITIZE_THIS (coverage[i])) return false;
461 LookupRecord *lookupRecord = &CAST(LookupRecord, coverage, sizeof (coverage[0]) * glyphCount);
462 return SANITIZE_MEM (lookupRecord, sizeof (lookupRecord[0]) * lookupCount);
466 USHORT format; /* Format identifier--format = 3 */
467 USHORT glyphCount; /* Number of glyphs in the input glyph
469 USHORT lookupCount; /* Number of LookupRecords */
471 coverage[]; /* Array of offsets to Coverage
472 * table in glyph sequence order */
473 LookupRecord lookupRecordX[]; /* Array of LookupRecords--in
476 ASSERT_SIZE (ContextFormat3, 6);
481 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
485 case 1: return u.format1->apply (APPLY_ARG, apply_func);
486 case 2: return u.format2->apply (APPLY_ARG, apply_func);
487 case 3: return u.format3->apply (APPLY_ARG, apply_func);
488 default:return false;
492 inline bool sanitize (SANITIZE_ARG_DEF) {
494 if (!SANITIZE (u.format)) return false;
496 case 1: return u.format1->sanitize (SANITIZE_ARG);
497 case 2: return u.format2->sanitize (SANITIZE_ARG);
498 case 3: return u.format3->sanitize (SANITIZE_ARG);
505 USHORT format; /* Format identifier */
506 ContextFormat1 format1[];
507 ContextFormat2 format2[];
508 ContextFormat3 format3[];
511 ASSERT_SIZE (Context, 2);
514 /* Chaining Contextual lookups */
516 struct ChainContextLookupContext
522 static inline bool chain_context_lookup (APPLY_ARG_DEF,
523 unsigned int backtrackCount,
524 const USHORT backtrack[],
525 unsigned int inputCount, /* Including the first glyph (not matched) */
526 const USHORT input[], /* Array of input values--start with second glyph */
527 unsigned int lookaheadCount,
528 const USHORT lookahead[],
529 unsigned int lookupCount,
530 const LookupRecord lookupRecord[],
531 ChainContextLookupContext &lookup_context)
534 if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
535 buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
536 inputCount + lookaheadCount > context_length))
540 return match_backtrack (APPLY_ARG,
541 backtrackCount, backtrack,
542 lookup_context.funcs.match, lookup_context.match_data[0]) &&
543 match_input (APPLY_ARG,
545 lookup_context.funcs.match, lookup_context.match_data[1],
547 match_lookahead (APPLY_ARG,
548 lookaheadCount, lookahead,
549 lookup_context.funcs.match, lookup_context.match_data[2],
551 (context_length = offset, true) &&
552 apply_lookup (APPLY_ARG,
554 lookupCount, lookupRecord,
555 lookup_context.funcs.apply);
560 friend struct ChainRuleSet;
563 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
566 const HeadlessArrayOf<USHORT> &input = CONST_NEXT (HeadlessArrayOf<USHORT>, backtrack);
567 const ArrayOf<USHORT> &lookahead = CONST_NEXT (ArrayOf<USHORT>, input);
568 const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
569 return chain_context_lookup (APPLY_ARG,
570 backtrack.len, backtrack.array,
571 input.len, input.array,
572 lookahead.len, lookahead.array,
573 lookup.len, lookup.array,
579 inline bool sanitize (SANITIZE_ARG_DEF) {
581 if (!SANITIZE (backtrack)) return false;
582 HeadlessArrayOf<USHORT> &input = NEXT (HeadlessArrayOf<USHORT>, backtrack);
583 if (!SANITIZE (input)) return false;
584 ArrayOf<USHORT> &lookahead = NEXT (ArrayOf<USHORT>, input);
585 if (!SANITIZE (lookahead)) return false;
586 ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
587 return SANITIZE (lookup);
592 backtrack; /* Array of backtracking values
593 * (to be matched before the input
595 HeadlessArrayOf<USHORT>
596 inputX; /* Array of input values (start with
599 lookaheadX; /* Array of lookahead values's (to be
600 * matched after the input sequence) */
601 ArrayOf<LookupRecord>
602 lookupX; /* Array of LookupRecords--in
605 ASSERT_SIZE (ChainRule, 8);
609 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
612 unsigned int num_rules = rule.len;
613 for (unsigned int i = 0; i < num_rules; i++)
615 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
622 inline bool sanitize (SANITIZE_ARG_DEF) {
624 return SANITIZE_THIS (rule);
628 OffsetArrayOf<ChainRule>
629 rule; /* Array of ChainRule tables
630 * ordered by preference */
632 ASSERT_SIZE (ChainRuleSet, 2);
634 struct ChainContextFormat1
636 friend struct ChainContext;
639 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
642 unsigned int index = (this+coverage) (IN_CURGLYPH ());
643 if (HB_LIKELY (index == NOT_COVERED))
646 const ChainRuleSet &rule_set = this+ruleSet[index];
647 struct ChainContextLookupContext lookup_context = {
648 {match_glyph, apply_func},
651 return rule_set.apply (APPLY_ARG, lookup_context);
654 inline bool sanitize (SANITIZE_ARG_DEF) {
656 return SANITIZE_THIS2 (coverage, ruleSet);
660 USHORT format; /* Format identifier--format = 1 */
662 coverage; /* Offset to Coverage table--from
663 * beginning of table */
664 OffsetArrayOf<ChainRuleSet>
665 ruleSet; /* Array of ChainRuleSet tables
666 * ordered by Coverage Index */
668 ASSERT_SIZE (ChainContextFormat1, 6);
670 struct ChainContextFormat2
672 friend struct ChainContext;
675 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
678 unsigned int index = (this+coverage) (IN_CURGLYPH ());
679 if (HB_LIKELY (index == NOT_COVERED))
682 const ClassDef &backtrack_class_def = this+backtrackClassDef;
683 const ClassDef &input_class_def = this+inputClassDef;
684 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
686 index = input_class_def (IN_CURGLYPH ());
687 const ChainRuleSet &rule_set = this+ruleSet[index];
688 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
689 * them across subrule lookups. Not sure it's worth it.
691 struct ChainContextLookupContext lookup_context = {
692 {match_class, apply_func},
693 {DECONST_CHARP(&backtrack_class_def),
694 DECONST_CHARP(&input_class_def),
695 DECONST_CHARP(&lookahead_class_def)}
697 return rule_set.apply (APPLY_ARG, lookup_context);
700 inline bool sanitize (SANITIZE_ARG_DEF) {
702 return SANITIZE_THIS2 (coverage, backtrackClassDef) &&
703 SANITIZE_THIS2 (inputClassDef, lookaheadClassDef) &&
704 SANITIZE_THIS (ruleSet);
708 USHORT format; /* Format identifier--format = 2 */
710 coverage; /* Offset to Coverage table--from
711 * beginning of table */
713 backtrackClassDef; /* Offset to glyph ClassDef table
714 * containing backtrack sequence
715 * data--from beginning of table */
717 inputClassDef; /* Offset to glyph ClassDef
718 * table containing input sequence
719 * data--from beginning of table */
721 lookaheadClassDef; /* Offset to glyph ClassDef table
722 * containing lookahead sequence
723 * data--from beginning of table */
724 OffsetArrayOf<ChainRuleSet>
725 ruleSet; /* Array of ChainRuleSet tables
726 * ordered by class */
728 ASSERT_SIZE (ChainContextFormat2, 12);
730 struct ChainContextFormat3
732 friend struct ChainContext;
736 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
739 const OffsetArrayOf<Coverage> &input = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
741 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
742 if (HB_LIKELY (index == NOT_COVERED))
745 const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, input);
746 const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
747 struct ChainContextLookupContext lookup_context = {
748 {match_coverage, apply_func},
749 {DECONST_CHARP(this), DECONST_CHARP(this), DECONST_CHARP(this)}
751 return chain_context_lookup (APPLY_ARG,
752 backtrack.len, (USHORT *) backtrack.array,
753 input.len, (USHORT *) input.array + 1,
754 lookahead.len, (USHORT *) lookahead.array,
755 lookup.len, lookup.array,
760 inline bool sanitize (SANITIZE_ARG_DEF) {
762 if (!SANITIZE_THIS (backtrack)) return false;
763 OffsetArrayOf<Coverage> &input = NEXT (OffsetArrayOf<Coverage>, backtrack);
764 if (!SANITIZE_THIS (input)) return false;
765 OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, input);
766 if (!SANITIZE_THIS (lookahead)) return false;
767 ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
768 return SANITIZE (lookup);
772 USHORT format; /* Format identifier--format = 3 */
773 OffsetArrayOf<Coverage>
774 backtrack; /* Array of coverage tables
775 * in backtracking sequence, in glyph
777 OffsetArrayOf<Coverage>
778 inputX ; /* Array of coverage
779 * tables in input sequence, in glyph
781 OffsetArrayOf<Coverage>
782 lookaheadX; /* Array of coverage tables
783 * in lookahead sequence, in glyph
785 ArrayOf<LookupRecord>
786 lookupX; /* Array of LookupRecords--in
789 ASSERT_SIZE (ChainContextFormat3, 10);
794 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
798 case 1: return u.format1->apply (APPLY_ARG, apply_func);
799 case 2: return u.format2->apply (APPLY_ARG, apply_func);
800 case 3: return u.format3->apply (APPLY_ARG, apply_func);
801 default:return false;
805 inline bool sanitize (SANITIZE_ARG_DEF) {
807 if (!SANITIZE (u.format)) return false;
809 case 1: return u.format1->sanitize (SANITIZE_ARG);
810 case 2: return u.format2->sanitize (SANITIZE_ARG);
811 case 3: return u.format3->sanitize (SANITIZE_ARG);
818 USHORT format; /* Format identifier */
819 ChainContextFormat1 format1[];
820 ChainContextFormat2 format2[];
821 ChainContextFormat3 format3[];
824 ASSERT_SIZE (ChainContext, 2);
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[0] << 16) + extensionOffset[1]; }
834 inline const LookupSubTable& get_subtable (void) const
836 unsigned int offset = get_offset ();
837 if (HB_UNLIKELY (!offset)) return Null(LookupSubTable);
838 return CONST_CAST (LookupSubTable, *this, offset);
841 inline bool sanitize (SANITIZE_ARG_DEF) {
843 return SANITIZE_SELF ();
847 USHORT format; /* Format identifier. Set to 1. */
848 USHORT extensionLookupType; /* Lookup type of subtable referenced
849 * by ExtensionOffset (i.e. the
850 * extension subtable). */
851 USHORT extensionOffset[2]; /* Offset to the extension subtable,
852 * of lookup type subtable.
853 * Defined as two shorts to avoid
854 * alignment requirements. */
856 ASSERT_SIZE (ExtensionFormat1, 8);
860 inline unsigned int get_type (void) const
863 case 1: return u.format1->get_type ();
867 inline const LookupSubTable& get_subtable (void) const
870 case 1: return u.format1->get_subtable ();
871 default:return Null(LookupSubTable);
875 inline bool sanitize (SANITIZE_ARG_DEF) {
877 if (!SANITIZE (u.format)) return false;
879 case 1: return u.format1->sanitize (SANITIZE_ARG);
886 USHORT format; /* Format identifier */
887 ExtensionFormat1 format1[];
890 ASSERT_SIZE (Extension, 2);
899 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
900 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
902 STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1, 1);
904 inline unsigned int get_script_count (void) const
905 { return (this+scriptList).len; }
906 inline const Tag& get_script_tag (unsigned int i) const
907 { return (this+scriptList).get_tag (i); }
908 inline bool get_script_tags (unsigned int *script_count /* IN/OUT */,
909 hb_tag_t *script_tags /* OUT */) const
910 { return (this+scriptList).get_tags (script_count, script_tags); }
911 inline const Script& get_script (unsigned int i) const
912 { return (this+scriptList)[i]; }
913 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
914 { return (this+scriptList).find_index (tag, index); }
916 inline unsigned int get_feature_count (void) const
917 { return (this+featureList).len; }
918 inline const Tag& get_feature_tag (unsigned int i) const
919 { return (this+featureList).get_tag (i); }
920 inline bool get_feature_tags (unsigned int *feature_count /* IN/OUT */,
921 hb_tag_t *feature_tags /* OUT */) const
922 { return (this+featureList).get_tags (feature_count, feature_tags); }
923 inline const Feature& get_feature (unsigned int i) const
924 { return (this+featureList)[i]; }
925 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
926 { return (this+featureList).find_index (tag, index); }
928 inline unsigned int get_lookup_count (void) const
929 { return (this+lookupList).len; }
930 inline const Lookup& get_lookup (unsigned int i) const
931 { return (this+lookupList)[i]; }
933 inline bool sanitize (SANITIZE_ARG_DEF) {
935 if (!SANITIZE (version)) return false;
936 if (version.major != 1) return true;
937 return SANITIZE_THIS3 (scriptList, featureList, lookupList);
941 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
944 scriptList; /* ScriptList table */
945 OffsetTo<FeatureList>
946 featureList; /* FeatureList table */
948 lookupList; /* LookupList table */
950 ASSERT_SIZE (GSUBGPOS, 10);
953 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */