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 unsigned int context_length HB_UNUSED, \
48 unsigned int apply_depth HB_UNUSED
52 (HB_DEBUG_APPLY ? apply_depth + 1 : 0)
54 struct hb_apply_context_t
56 hb_ot_layout_context_t *layout;
58 unsigned int nesting_level_left;
59 unsigned int lookup_flag;
60 unsigned int property; /* propety of first glyph (TODO remove) */
67 #define BUFFER context->buffer
70 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
71 typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
76 apply_lookup_func_t apply;
80 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
82 return glyph_id == value;
85 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
87 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
88 return class_def.get_class (glyph_id) == value;
91 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
93 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
94 return (data+coverage) (glyph_id) != NOT_COVERED;
98 static inline bool match_input (APPLY_ARG_DEF,
99 unsigned int count, /* Including the first glyph (not matched) */
100 const USHORT input[], /* Array of input values--start with second glyph */
101 match_func_t match_func,
102 const char *match_data,
103 unsigned int *context_length_out)
106 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
107 if (unlikely (context->buffer->in_pos + count > end))
110 for (i = 1, j = context->buffer->in_pos + 1; i < count; i++, j++)
112 while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
114 if (unlikely (j + count - i == end))
119 if (likely (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
123 *context_length_out = j - context->buffer->in_pos;
128 static inline bool match_backtrack (APPLY_ARG_DEF,
130 const USHORT backtrack[],
131 match_func_t match_func,
132 const char *match_data)
134 if (unlikely (context->buffer->out_pos < count))
137 for (unsigned int i = 0, j = context->buffer->out_pos - 1; i < count; i++, j--)
139 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
141 if (unlikely (j + 1 == count - i))
146 if (likely (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
153 static inline bool match_lookahead (APPLY_ARG_DEF,
155 const USHORT lookahead[],
156 match_func_t match_func,
157 const char *match_data,
161 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
162 if (unlikely (context->buffer->in_pos + offset + count > end))
165 for (i = 0, j = context->buffer->in_pos + offset; i < count; i++, j++)
167 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
169 if (unlikely (j + count - i == end))
174 if (likely (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
184 static inline unsigned int get_size () { return sizeof (LookupRecord); }
186 inline bool sanitize (hb_sanitize_context_t *context) {
188 return SANITIZE_SELF ();
191 USHORT sequenceIndex; /* Index into current glyph
192 * sequence--first glyph = 0 */
193 USHORT lookupListIndex; /* Lookup to apply to that
194 * position--zero--based */
196 ASSERT_SIZE (LookupRecord, 4);
198 static inline bool apply_lookup (APPLY_ARG_DEF,
199 unsigned int count, /* Including the first glyph */
200 unsigned int lookupCount,
201 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
202 apply_lookup_func_t apply_func)
204 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context_length);
205 if (unlikely (context->buffer->in_pos + count > end))
208 /* TODO We don't support lookupRecord arrays that are not increasing:
209 * Should be easy for in_place ones at least. */
211 /* Note: If sublookup is reverse, i will underflow after the first loop
212 * and we jump out of it. Not entirely disastrous. So we don't check
213 * for reverse lookup here.
215 for (unsigned int i = 0; i < count; /* NOP */)
217 while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
219 if (unlikely (context->buffer->in_pos == end))
221 /* No lookup applied for this index */
222 _hb_buffer_next_glyph (context->buffer);
225 if (lookupCount && i == lookupRecord->sequenceIndex)
227 unsigned int old_pos = context->buffer->in_pos;
230 bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex);
234 /* Err, this is wrong if the lookup jumped over some glyphs */
235 i += context->buffer->in_pos - old_pos;
236 if (unlikely (context->buffer->in_pos == end))
245 /* No lookup applied for this index */
246 _hb_buffer_next_glyph (context->buffer);
255 /* Contextual lookups */
257 struct ContextLookupContext
260 const char *match_data;
263 static inline bool context_lookup (APPLY_ARG_DEF,
264 unsigned int inputCount, /* Including the first glyph (not matched) */
265 const USHORT input[], /* Array of input values--start with second glyph */
266 unsigned int lookupCount,
267 const LookupRecord lookupRecord[],
268 ContextLookupContext &lookup_context)
270 return match_input (APPLY_ARG,
272 lookup_context.funcs.match, lookup_context.match_data,
274 apply_lookup (APPLY_ARG,
276 lookupCount, lookupRecord,
277 lookup_context.funcs.apply);
282 friend struct RuleSet;
285 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
288 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
289 return context_lookup (APPLY_ARG,
291 lookupCount, lookupRecord,
296 inline bool sanitize (hb_sanitize_context_t *context) {
298 if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
299 return SANITIZE_MEM (input,
300 input[0].get_size () * inputCount +
301 lookupRecordX[0].get_size () * lookupCount);
305 USHORT inputCount; /* Total number of glyphs in input
306 * glyph sequence--includes the first
308 USHORT lookupCount; /* Number of LookupRecords */
309 USHORT input[VAR]; /* Array of match inputs--start with
311 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
314 ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
318 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
321 unsigned int num_rules = rule.len;
322 for (unsigned int i = 0; i < num_rules; i++)
324 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
331 inline bool sanitize (hb_sanitize_context_t *context) {
333 return SANITIZE_WITH_BASE (this, rule);
338 rule; /* Array of Rule tables
339 * ordered by preference */
343 struct ContextFormat1
345 friend struct Context;
348 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
351 unsigned int index = (this+coverage) (IN_CURGLYPH ());
352 if (likely (index == NOT_COVERED))
355 const RuleSet &rule_set = this+ruleSet[index];
356 struct ContextLookupContext lookup_context = {
357 {match_glyph, apply_func},
360 return rule_set.apply (APPLY_ARG, lookup_context);
363 inline bool sanitize (hb_sanitize_context_t *context) {
365 return SANITIZE_WITH_BASE (this, coverage)
366 && SANITIZE_WITH_BASE (this, ruleSet);
370 USHORT format; /* Format identifier--format = 1 */
372 coverage; /* Offset to Coverage table--from
373 * beginning of table */
374 OffsetArrayOf<RuleSet>
375 ruleSet; /* Array of RuleSet tables
376 * ordered by Coverage Index */
378 ASSERT_SIZE (ContextFormat1, 6);
381 struct ContextFormat2
383 friend struct Context;
386 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
389 unsigned int index = (this+coverage) (IN_CURGLYPH ());
390 if (likely (index == NOT_COVERED))
393 const ClassDef &class_def = this+classDef;
394 index = class_def (IN_CURGLYPH ());
395 const RuleSet &rule_set = this+ruleSet[index];
396 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
397 * them across subrule lookups. Not sure it's worth it.
399 struct ContextLookupContext lookup_context = {
400 {match_class, apply_func},
403 return rule_set.apply (APPLY_ARG, lookup_context);
406 inline bool sanitize (hb_sanitize_context_t *context) {
408 return SANITIZE_WITH_BASE (this, coverage)
409 && SANITIZE_WITH_BASE (this, classDef)
410 && SANITIZE_WITH_BASE (this, ruleSet);
414 USHORT format; /* Format identifier--format = 2 */
416 coverage; /* Offset to Coverage table--from
417 * beginning of table */
419 classDef; /* Offset to glyph ClassDef table--from
420 * beginning of table */
421 OffsetArrayOf<RuleSet>
422 ruleSet; /* Array of RuleSet tables
423 * ordered by class */
425 ASSERT_SIZE (ContextFormat2, 8);
428 struct ContextFormat3
430 friend struct Context;
433 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
436 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
437 if (likely (index == NOT_COVERED))
440 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount);
441 struct ContextLookupContext lookup_context = {
442 {match_coverage, apply_func},
445 return context_lookup (APPLY_ARG,
446 glyphCount, (const USHORT *) (coverage + 1),
447 lookupCount, lookupRecord,
451 inline bool sanitize (hb_sanitize_context_t *context) {
453 if (!SANITIZE_SELF ()) return false;
454 unsigned int count = glyphCount;
455 if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), glyphCount)) return false;
456 for (unsigned int i = 0; i < count; i++)
457 if (!SANITIZE_WITH_BASE (this, coverage[i])) return false;
458 LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * glyphCount);
459 return SANITIZE_ARRAY (lookupRecord, LookupRecord::get_size (), lookupCount);
463 USHORT format; /* Format identifier--format = 3 */
464 USHORT glyphCount; /* Number of glyphs in the input glyph
466 USHORT lookupCount; /* Number of LookupRecords */
468 coverage[VAR]; /* Array of offsets to Coverage
469 * table in glyph sequence order */
470 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
473 ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
478 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
482 case 1: return u.format1->apply (APPLY_ARG, apply_func);
483 case 2: return u.format2->apply (APPLY_ARG, apply_func);
484 case 3: return u.format3->apply (APPLY_ARG, apply_func);
485 default:return false;
489 inline bool sanitize (hb_sanitize_context_t *context) {
491 if (!SANITIZE (u.format)) return false;
493 case 1: return u.format1->sanitize (context);
494 case 2: return u.format2->sanitize (context);
495 case 3: return u.format3->sanitize (context);
502 USHORT format; /* Format identifier */
503 ContextFormat1 format1[VAR];
504 ContextFormat2 format2[VAR];
505 ContextFormat3 format3[VAR];
510 /* Chaining Contextual lookups */
512 struct ChainContextLookupContext
515 const char *match_data[3];
518 static inline bool chain_context_lookup (APPLY_ARG_DEF,
519 unsigned int backtrackCount,
520 const USHORT backtrack[],
521 unsigned int inputCount, /* Including the first glyph (not matched) */
522 const USHORT input[], /* Array of input values--start with second glyph */
523 unsigned int lookaheadCount,
524 const USHORT lookahead[],
525 unsigned int lookupCount,
526 const LookupRecord lookupRecord[],
527 ChainContextLookupContext &lookup_context)
530 if (unlikely (context->buffer->out_pos < backtrackCount ||
531 context->buffer->in_pos + inputCount + lookaheadCount > context->buffer->in_length ||
532 inputCount + lookaheadCount > context_length))
536 return match_backtrack (APPLY_ARG,
537 backtrackCount, backtrack,
538 lookup_context.funcs.match, lookup_context.match_data[0]) &&
539 match_input (APPLY_ARG,
541 lookup_context.funcs.match, lookup_context.match_data[1],
543 match_lookahead (APPLY_ARG,
544 lookaheadCount, lookahead,
545 lookup_context.funcs.match, lookup_context.match_data[2],
547 (context_length = offset, true) &&
548 apply_lookup (APPLY_ARG,
550 lookupCount, lookupRecord,
551 lookup_context.funcs.apply);
556 friend struct ChainRuleSet;
559 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
562 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
563 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
564 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
565 return chain_context_lookup (APPLY_ARG,
566 backtrack.len, backtrack.array(),
567 input.len, input.array(),
568 lookahead.len, lookahead.array(),
569 lookup.len, lookup.array(),
575 inline bool sanitize (hb_sanitize_context_t *context) {
577 if (!SANITIZE (backtrack)) return false;
578 HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
579 if (!SANITIZE (input)) return false;
580 ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
581 if (!SANITIZE (lookahead)) return false;
582 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
583 return SANITIZE (lookup);
588 backtrack; /* Array of backtracking values
589 * (to be matched before the input
591 HeadlessArrayOf<USHORT>
592 inputX; /* Array of input values (start with
595 lookaheadX; /* Array of lookahead values's (to be
596 * matched after the input sequence) */
597 ArrayOf<LookupRecord>
598 lookupX; /* Array of LookupRecords--in
601 ASSERT_SIZE (ChainRule, 8);
605 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
608 unsigned int num_rules = rule.len;
609 for (unsigned int i = 0; i < num_rules; i++)
611 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
618 inline bool sanitize (hb_sanitize_context_t *context) {
620 return SANITIZE_WITH_BASE (this, rule);
624 OffsetArrayOf<ChainRule>
625 rule; /* Array of ChainRule tables
626 * ordered by preference */
628 ASSERT_SIZE (ChainRuleSet, 2);
630 struct ChainContextFormat1
632 friend struct ChainContext;
635 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
638 unsigned int index = (this+coverage) (IN_CURGLYPH ());
639 if (likely (index == NOT_COVERED))
642 const ChainRuleSet &rule_set = this+ruleSet[index];
643 struct ChainContextLookupContext lookup_context = {
644 {match_glyph, apply_func},
647 return rule_set.apply (APPLY_ARG, lookup_context);
650 inline bool sanitize (hb_sanitize_context_t *context) {
652 return SANITIZE_WITH_BASE (this, coverage)
653 && SANITIZE_WITH_BASE (this, ruleSet);
657 USHORT format; /* Format identifier--format = 1 */
659 coverage; /* Offset to Coverage table--from
660 * beginning of table */
661 OffsetArrayOf<ChainRuleSet>
662 ruleSet; /* Array of ChainRuleSet tables
663 * ordered by Coverage Index */
665 ASSERT_SIZE (ChainContextFormat1, 6);
667 struct ChainContextFormat2
669 friend struct ChainContext;
672 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
675 unsigned int index = (this+coverage) (IN_CURGLYPH ());
676 if (likely (index == NOT_COVERED))
679 const ClassDef &backtrack_class_def = this+backtrackClassDef;
680 const ClassDef &input_class_def = this+inputClassDef;
681 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
683 index = input_class_def (IN_CURGLYPH ());
684 const ChainRuleSet &rule_set = this+ruleSet[index];
685 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
686 * them across subrule lookups. Not sure it's worth it.
688 struct ChainContextLookupContext lookup_context = {
689 {match_class, apply_func},
690 {CharP(&backtrack_class_def),
691 CharP(&input_class_def),
692 CharP(&lookahead_class_def)}
694 return rule_set.apply (APPLY_ARG, lookup_context);
697 inline bool sanitize (hb_sanitize_context_t *context) {
699 return SANITIZE_WITH_BASE (this, coverage)
700 && SANITIZE_WITH_BASE (this, backtrackClassDef)
701 && SANITIZE_WITH_BASE (this, inputClassDef)
702 && SANITIZE_WITH_BASE (this, lookaheadClassDef)
703 && SANITIZE_WITH_BASE (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 = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
740 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
741 if (likely (index == NOT_COVERED))
744 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
745 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
746 struct ChainContextLookupContext lookup_context = {
747 {match_coverage, apply_func},
748 {CharP(this), CharP(this), CharP(this)}
750 return chain_context_lookup (APPLY_ARG,
751 backtrack.len, (const USHORT *) backtrack.array(),
752 input.len, (const USHORT *) input.array() + 1,
753 lookahead.len, (const USHORT *) lookahead.array(),
754 lookup.len, lookup.array(),
759 inline bool sanitize (hb_sanitize_context_t *context) {
761 if (!SANITIZE_WITH_BASE (this, backtrack)) return false;
762 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
763 if (!SANITIZE_WITH_BASE (this, input)) return false;
764 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
765 if (!SANITIZE_WITH_BASE (this, lookahead)) return false;
766 ArrayOf<LookupRecord> &lookup = StructAfter<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 (hb_sanitize_context_t *context) {
806 if (!SANITIZE (u.format)) return false;
808 case 1: return u.format1->sanitize (context);
809 case 2: return u.format2->sanitize (context);
810 case 3: return u.format3->sanitize (context);
817 USHORT format; /* Format identifier */
818 ChainContextFormat1 format1[VAR];
819 ChainContextFormat2 format2[VAR];
820 ChainContextFormat3 format3[VAR];
825 struct ExtensionFormat1
827 friend struct Extension;
830 inline unsigned int get_type (void) const { return extensionLookupType; }
831 inline unsigned int get_offset (void) const { return extensionOffset; }
833 inline bool sanitize (hb_sanitize_context_t *context) {
835 return SANITIZE_SELF ();
839 USHORT format; /* Format identifier. Set to 1. */
840 USHORT extensionLookupType; /* Lookup type of subtable referenced
841 * by ExtensionOffset (i.e. the
842 * extension subtable). */
843 ULONG extensionOffset; /* Offset to the extension subtable,
844 * of lookup type subtable. */
846 ASSERT_SIZE (ExtensionFormat1, 8);
850 inline unsigned int get_type (void) const
853 case 1: return u.format1->get_type ();
857 inline unsigned int get_offset (void) const
860 case 1: return u.format1->get_offset ();
865 inline bool sanitize (hb_sanitize_context_t *context) {
867 if (!SANITIZE (u.format)) return false;
869 case 1: return u.format1->sanitize (context);
876 USHORT format; /* Format identifier */
877 ExtensionFormat1 format1[VAR];
888 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
889 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
891 inline unsigned int get_script_count (void) const
892 { return (this+scriptList).len; }
893 inline const Tag& get_script_tag (unsigned int i) const
894 { return (this+scriptList).get_tag (i); }
895 inline unsigned int get_script_tags (unsigned int start_offset,
896 unsigned int *script_count /* IN/OUT */,
897 hb_tag_t *script_tags /* OUT */) const
898 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
899 inline const Script& get_script (unsigned int i) const
900 { return (this+scriptList)[i]; }
901 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
902 { return (this+scriptList).find_index (tag, index); }
904 inline unsigned int get_feature_count (void) const
905 { return (this+featureList).len; }
906 inline const Tag& get_feature_tag (unsigned int i) const
907 { return (this+featureList).get_tag (i); }
908 inline unsigned int get_feature_tags (unsigned int start_offset,
909 unsigned int *feature_count /* IN/OUT */,
910 hb_tag_t *feature_tags /* OUT */) const
911 { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); }
912 inline const Feature& get_feature (unsigned int i) const
913 { return (this+featureList)[i]; }
914 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
915 { return (this+featureList).find_index (tag, index); }
917 inline unsigned int get_lookup_count (void) const
918 { return (this+lookupList).len; }
919 inline const Lookup& get_lookup (unsigned int i) const
920 { return (this+lookupList)[i]; }
922 inline bool sanitize (hb_sanitize_context_t *context) {
924 return SANITIZE (version) && likely (version.major == 1)
925 && SANITIZE_WITH_BASE (this, scriptList)
926 && SANITIZE_WITH_BASE (this, featureList)
927 && SANITIZE_WITH_BASE (this, lookupList);
931 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
934 scriptList; /* ScriptList table */
935 OffsetTo<FeatureList>
936 featureList; /* FeatureList table */
938 lookupList; /* LookupList table */
940 ASSERT_SIZE (GSUBGPOS, 10);
943 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */