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 APPLY_DEBUG_ARG_DEF , unsigned int apply_depth
40 #define APPLY_DEBUG_ARG , apply_depth + 1
41 #define APPLY_DEBUG_ARG_INIT , 1
42 #define APPLY_DEBUG() \
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 APPLY_DEBUG_ARG_DEF
52 #define APPLY_DEBUG_ARG
53 #define APPLY_DEBUG_ARG_INIT
54 #define APPLY_DEBUG() 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; i++)
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 i += buffer->in_pos - old_pos;
242 if (HB_UNLIKELY (buffer->in_pos == end))
251 /* No lookup applied for this index */
252 _hb_buffer_next_glyph (buffer);
261 /* Contextual lookups */
263 struct ContextLookupContext
269 static inline bool context_lookup (APPLY_ARG_DEF,
270 unsigned int inputCount, /* Including the first glyph (not matched) */
271 const USHORT input[], /* Array of input values--start with second glyph */
272 unsigned int lookupCount,
273 const LookupRecord lookupRecord[],
274 ContextLookupContext &lookup_context)
276 return match_input (APPLY_ARG,
278 lookup_context.funcs.match, lookup_context.match_data,
280 apply_lookup (APPLY_ARG,
282 lookupCount, lookupRecord,
283 lookup_context.funcs.apply);
288 friend struct RuleSet;
291 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
294 const LookupRecord *lookupRecord = &CONST_CAST (LookupRecord, input, sizeof (input[0]) * (inputCount ? inputCount - 1 : 0));
295 return context_lookup (APPLY_ARG,
297 lookupCount, lookupRecord,
302 inline bool sanitize (SANITIZE_ARG_DEF) {
304 if (!SANITIZE_SELF ()) return false;
305 return SANITIZE_MEM (input,
306 sizeof (input[0]) * inputCount +
307 sizeof (lookupRecordX[0]) * lookupCount);
311 USHORT inputCount; /* Total number of glyphs in input
312 * glyph sequence--includes the first
314 USHORT lookupCount; /* Number of LookupRecords */
315 USHORT input[]; /* Array of match inputs--start with
317 LookupRecord lookupRecordX[]; /* Array of LookupRecords--in
320 ASSERT_SIZE (Rule, 4);
324 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
327 unsigned int num_rules = rule.len;
328 for (unsigned int i = 0; i < num_rules; i++)
330 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
337 inline bool sanitize (SANITIZE_ARG_DEF) {
339 return SANITIZE_THIS (rule);
344 rule; /* Array of Rule tables
345 * ordered by preference */
349 struct ContextFormat1
351 friend struct Context;
354 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
357 unsigned int index = (this+coverage) (IN_CURGLYPH ());
358 if (HB_LIKELY (index == NOT_COVERED))
361 const RuleSet &rule_set = this+ruleSet[index];
362 struct ContextLookupContext lookup_context = {
363 {match_glyph, apply_func},
366 return rule_set.apply (APPLY_ARG, lookup_context);
369 inline bool sanitize (SANITIZE_ARG_DEF) {
371 return SANITIZE_THIS2 (coverage, ruleSet);
375 USHORT format; /* Format identifier--format = 1 */
377 coverage; /* Offset to Coverage table--from
378 * beginning of table */
379 OffsetArrayOf<RuleSet>
380 ruleSet; /* Array of RuleSet tables
381 * ordered by Coverage Index */
383 ASSERT_SIZE (ContextFormat1, 6);
386 struct ContextFormat2
388 friend struct Context;
391 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
394 unsigned int index = (this+coverage) (IN_CURGLYPH ());
395 if (HB_LIKELY (index == NOT_COVERED))
398 const ClassDef &class_def = this+classDef;
399 index = class_def (IN_CURGLYPH ());
400 const RuleSet &rule_set = this+ruleSet[index];
401 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
402 * them across subrule lookups. Not sure it's worth it.
404 struct ContextLookupContext lookup_context = {
405 {match_class, apply_func},
406 DECONST_CHARP(&class_def)
408 return rule_set.apply (APPLY_ARG, lookup_context);
411 inline bool sanitize (SANITIZE_ARG_DEF) {
413 return SANITIZE_THIS3 (coverage, classDef, ruleSet);
417 USHORT format; /* Format identifier--format = 2 */
419 coverage; /* Offset to Coverage table--from
420 * beginning of table */
422 classDef; /* Offset to glyph ClassDef table--from
423 * beginning of table */
424 OffsetArrayOf<RuleSet>
425 ruleSet; /* Array of RuleSet tables
426 * ordered by class */
428 ASSERT_SIZE (ContextFormat2, 8);
431 struct ContextFormat3
433 friend struct Context;
436 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
439 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
440 if (HB_LIKELY (index == NOT_COVERED))
443 const LookupRecord *lookupRecord = &CONST_CAST(LookupRecord, coverage, sizeof (coverage[0]) * glyphCount);
444 struct ContextLookupContext lookup_context = {
445 {match_coverage, apply_func},
448 return context_lookup (APPLY_ARG,
449 glyphCount, (const USHORT *) (coverage + 1),
450 lookupCount, lookupRecord,
454 inline bool sanitize (SANITIZE_ARG_DEF) {
456 if (!SANITIZE_SELF ()) return false;
457 unsigned int count = glyphCount;
458 for (unsigned int i = 0; i < count; i++)
459 if (!SANITIZE_THIS (coverage[i])) return false;
460 LookupRecord *lookupRecord = &CAST(LookupRecord, coverage, sizeof (coverage[0]) * glyphCount);
461 return SANITIZE_MEM (lookupRecord, sizeof (lookupRecord[0]) * lookupCount);
465 USHORT format; /* Format identifier--format = 3 */
466 USHORT glyphCount; /* Number of glyphs in the input glyph
468 USHORT lookupCount; /* Number of LookupRecords */
470 coverage[]; /* Array of offsets to Coverage
471 * table in glyph sequence order */
472 LookupRecord lookupRecordX[]; /* Array of LookupRecords--in
475 ASSERT_SIZE (ContextFormat3, 6);
480 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
484 case 1: return u.format1->apply (APPLY_ARG, apply_func);
485 case 2: return u.format2->apply (APPLY_ARG, apply_func);
486 case 3: return u.format3->apply (APPLY_ARG, apply_func);
487 default:return false;
491 inline bool sanitize (SANITIZE_ARG_DEF) {
493 if (!SANITIZE (u.format)) return false;
495 case 1: return u.format1->sanitize (SANITIZE_ARG);
496 case 2: return u.format2->sanitize (SANITIZE_ARG);
497 case 3: return u.format3->sanitize (SANITIZE_ARG);
504 USHORT format; /* Format identifier */
505 ContextFormat1 format1[];
506 ContextFormat2 format2[];
507 ContextFormat3 format3[];
510 ASSERT_SIZE (Context, 2);
513 /* Chaining Contextual lookups */
515 struct ChainContextLookupContext
521 static inline bool chain_context_lookup (APPLY_ARG_DEF,
522 unsigned int backtrackCount,
523 const USHORT backtrack[],
524 unsigned int inputCount, /* Including the first glyph (not matched) */
525 const USHORT input[], /* Array of input values--start with second glyph */
526 unsigned int lookaheadCount,
527 const USHORT lookahead[],
528 unsigned int lookupCount,
529 const LookupRecord lookupRecord[],
530 ChainContextLookupContext &lookup_context)
533 if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
534 buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
535 inputCount + lookaheadCount > context_length))
539 return match_backtrack (APPLY_ARG,
540 backtrackCount, backtrack,
541 lookup_context.funcs.match, lookup_context.match_data[0]) &&
542 match_input (APPLY_ARG,
544 lookup_context.funcs.match, lookup_context.match_data[1],
546 match_lookahead (APPLY_ARG,
547 lookaheadCount, lookahead,
548 lookup_context.funcs.match, lookup_context.match_data[2],
550 (context_length = offset, true) &&
551 apply_lookup (APPLY_ARG,
553 lookupCount, lookupRecord,
554 lookup_context.funcs.apply);
559 friend struct ChainRuleSet;
562 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
565 const HeadlessArrayOf<USHORT> &input = CONST_NEXT (HeadlessArrayOf<USHORT>, backtrack);
566 const ArrayOf<USHORT> &lookahead = CONST_NEXT (ArrayOf<USHORT>, input);
567 const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
568 return chain_context_lookup (APPLY_ARG,
569 backtrack.len, backtrack.array,
570 input.len, input.array + 1,
571 lookahead.len, lookahead.array,
572 lookup.len, lookup.array,
578 inline bool sanitize (SANITIZE_ARG_DEF) {
580 if (!SANITIZE (backtrack)) return false;
581 HeadlessArrayOf<USHORT> &input = NEXT (HeadlessArrayOf<USHORT>, backtrack);
582 if (!SANITIZE (input)) return false;
583 ArrayOf<USHORT> &lookahead = NEXT (ArrayOf<USHORT>, input);
584 if (!SANITIZE (lookahead)) return false;
585 ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
586 return SANITIZE (lookup);
591 backtrack; /* Array of backtracking values
592 * (to be matched before the input
594 HeadlessArrayOf<USHORT>
595 inputX; /* Array of input values (start with
598 lookaheadX; /* Array of lookahead values's (to be
599 * matched after the input sequence) */
600 ArrayOf<LookupRecord>
601 lookupX; /* Array of LookupRecords--in
604 ASSERT_SIZE (ChainRule, 8);
608 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
611 unsigned int num_rules = rule.len;
612 for (unsigned int i = 0; i < num_rules; i++)
614 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
621 inline bool sanitize (SANITIZE_ARG_DEF) {
623 return SANITIZE_THIS (rule);
627 OffsetArrayOf<ChainRule>
628 rule; /* Array of ChainRule tables
629 * ordered by preference */
631 ASSERT_SIZE (ChainRuleSet, 2);
633 struct ChainContextFormat1
635 friend struct ChainContext;
638 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
641 unsigned int index = (this+coverage) (IN_CURGLYPH ());
642 if (HB_LIKELY (index == NOT_COVERED))
645 const ChainRuleSet &rule_set = this+ruleSet[index];
646 struct ChainContextLookupContext lookup_context = {
647 {match_glyph, apply_func},
650 return rule_set.apply (APPLY_ARG, lookup_context);
653 inline bool sanitize (SANITIZE_ARG_DEF) {
655 return SANITIZE_THIS2 (coverage, 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 (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
677 unsigned int index = (this+coverage) (IN_CURGLYPH ());
678 if (HB_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 {DECONST_CHARP(&backtrack_class_def),
693 DECONST_CHARP(&input_class_def),
694 DECONST_CHARP(&lookahead_class_def)}
696 return rule_set.apply (APPLY_ARG, lookup_context);
699 inline bool sanitize (SANITIZE_ARG_DEF) {
701 return SANITIZE_THIS2 (coverage, backtrackClassDef) &&
702 SANITIZE_THIS2 (inputClassDef, lookaheadClassDef) &&
703 SANITIZE_THIS (ruleSet);
707 USHORT format; /* Format identifier--format = 2 */
709 coverage; /* Offset to Coverage table--from
710 * beginning of table */
712 backtrackClassDef; /* Offset to glyph ClassDef table
713 * containing backtrack sequence
714 * data--from beginning of table */
716 inputClassDef; /* Offset to glyph ClassDef
717 * table containing input sequence
718 * data--from beginning of table */
720 lookaheadClassDef; /* Offset to glyph ClassDef table
721 * containing lookahead sequence
722 * data--from beginning of table */
723 OffsetArrayOf<ChainRuleSet>
724 ruleSet; /* Array of ChainRuleSet tables
725 * ordered by class */
727 ASSERT_SIZE (ChainContextFormat2, 12);
729 struct ChainContextFormat3
731 friend struct ChainContext;
735 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
738 const OffsetArrayOf<Coverage> &input = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
740 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
741 if (HB_LIKELY (index == NOT_COVERED))
744 const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, input);
745 const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
746 struct ChainContextLookupContext lookup_context = {
747 {match_coverage, apply_func},
748 {DECONST_CHARP(this), DECONST_CHARP(this), DECONST_CHARP(this)}
750 return chain_context_lookup (APPLY_ARG,
751 backtrack.len, (USHORT *) backtrack.array,
752 input.len, (USHORT *) input.array,
753 lookahead.len, (USHORT *) lookahead.array,
754 lookup.len, lookup.array,
759 inline bool sanitize (SANITIZE_ARG_DEF) {
761 if (!SANITIZE_THIS (backtrack)) return false;
762 OffsetArrayOf<Coverage> &input = NEXT (OffsetArrayOf<Coverage>, backtrack);
763 if (!SANITIZE_THIS (input)) return false;
764 OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, input);
765 if (!SANITIZE_THIS (lookahead)) return false;
766 ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
767 return SANITIZE (lookup);
771 USHORT format; /* Format identifier--format = 3 */
772 OffsetArrayOf<Coverage>
773 backtrack; /* Array of coverage tables
774 * in backtracking sequence, in glyph
776 OffsetArrayOf<Coverage>
777 inputX ; /* Array of coverage
778 * tables in input sequence, in glyph
780 OffsetArrayOf<Coverage>
781 lookaheadX; /* Array of coverage tables
782 * in lookahead sequence, in glyph
784 ArrayOf<LookupRecord>
785 lookupX; /* Array of LookupRecords--in
788 ASSERT_SIZE (ChainContextFormat3, 10);
793 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
797 case 1: return u.format1->apply (APPLY_ARG, apply_func);
798 case 2: return u.format2->apply (APPLY_ARG, apply_func);
799 case 3: return u.format3->apply (APPLY_ARG, apply_func);
800 default:return false;
804 inline bool sanitize (SANITIZE_ARG_DEF) {
806 if (!SANITIZE (u.format)) return false;
808 case 1: return u.format1->sanitize (SANITIZE_ARG);
809 case 2: return u.format2->sanitize (SANITIZE_ARG);
810 case 3: return u.format3->sanitize (SANITIZE_ARG);
817 USHORT format; /* Format identifier */
818 ChainContextFormat1 format1[];
819 ChainContextFormat2 format2[];
820 ChainContextFormat3 format3[];
823 ASSERT_SIZE (ChainContext, 2);
826 struct ExtensionFormat1
828 friend struct Extension;
831 inline unsigned int get_type (void) const { return extensionLookupType; }
832 inline unsigned int get_offset (void) const { return (extensionOffset[0] << 16) + extensionOffset[1]; }
833 inline const LookupSubTable& get_subtable (void) const
835 unsigned int offset = get_offset ();
836 if (HB_UNLIKELY (!offset)) return Null(LookupSubTable);
837 return CONST_CAST (LookupSubTable, *this, offset);
840 inline bool sanitize (SANITIZE_ARG_DEF) {
842 return SANITIZE_SELF ();
846 USHORT format; /* Format identifier. Set to 1. */
847 USHORT extensionLookupType; /* Lookup type of subtable referenced
848 * by ExtensionOffset (i.e. the
849 * extension subtable). */
850 USHORT extensionOffset[2]; /* Offset to the extension subtable,
851 * of lookup type subtable.
852 * Defined as two shorts to avoid
853 * alignment requirements. */
855 ASSERT_SIZE (ExtensionFormat1, 8);
859 inline unsigned int get_type (void) const
862 case 1: return u.format1->get_type ();
866 inline const LookupSubTable& get_subtable (void) const
869 case 1: return u.format1->get_subtable ();
870 default:return Null(LookupSubTable);
874 inline bool sanitize (SANITIZE_ARG_DEF) {
876 if (!SANITIZE (u.format)) return false;
878 case 1: return u.format1->sanitize (SANITIZE_ARG);
885 USHORT format; /* Format identifier */
886 ExtensionFormat1 format1[];
889 ASSERT_SIZE (Extension, 2);
898 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
899 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
901 STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1, 1);
903 inline unsigned int get_script_count (void) const
904 { return (this+scriptList).len; }
905 inline const Tag& get_script_tag (unsigned int i) const
906 { return (this+scriptList).get_tag (i); }
907 inline bool get_script_tags (unsigned int *script_count /* IN/OUT */,
908 hb_tag_t *script_tags /* OUT */) const
909 { return (this+scriptList).get_tags (script_count, script_tags); }
910 inline const Script& get_script (unsigned int i) const
911 { return (this+scriptList)[i]; }
912 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
913 { return (this+scriptList).find_index (tag, index); }
915 inline unsigned int get_feature_count (void) const
916 { return (this+featureList).len; }
917 inline const Tag& get_feature_tag (unsigned int i) const
918 { return (this+featureList).get_tag (i); }
919 inline bool get_feature_tags (unsigned int *feature_count /* IN/OUT */,
920 hb_tag_t *feature_tags /* OUT */) const
921 { return (this+featureList).get_tags (feature_count, feature_tags); }
922 inline const Feature& get_feature (unsigned int i) const
923 { return (this+featureList)[i]; }
924 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
925 { return (this+featureList).find_index (tag, index); }
927 inline unsigned int get_lookup_count (void) const
928 { return (this+lookupList).len; }
929 inline const Lookup& get_lookup (unsigned int i) const
930 { return (this+lookupList)[i]; }
932 inline bool sanitize (SANITIZE_ARG_DEF) {
934 if (!SANITIZE (version)) return false;
935 if (version.major != 1) return true;
936 return SANITIZE_THIS3 (scriptList, featureList, lookupList);
940 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
943 scriptList; /* ScriptList table */
944 OffsetTo<FeatureList>
945 featureList; /* FeatureList table */
947 lookupList; /* LookupList table */
949 ASSERT_SIZE (GSUBGPOS, 10);
952 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */