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_buffer_t *buffer, \
48 unsigned int context_length HB_UNUSED, \
49 unsigned int apply_depth HB_UNUSED
54 (HB_DEBUG_APPLY ? apply_depth + 1 : 0)
56 struct hb_apply_context_t
58 hb_ot_layout_context_t *layout;
59 unsigned int nesting_level_left;
60 unsigned int lookup_flag;
61 unsigned int property; /* propety of first glyph (TODO remove) */
65 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
66 typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
71 apply_lookup_func_t apply;
75 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
77 return glyph_id == value;
80 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
82 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
83 return class_def.get_class (glyph_id) == value;
86 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
88 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
89 return (data+coverage) (glyph_id) != NOT_COVERED;
93 static inline bool match_input (APPLY_ARG_DEF,
94 unsigned int count, /* Including the first glyph (not matched) */
95 const USHORT input[], /* Array of input values--start with second glyph */
96 match_func_t match_func,
97 const char *match_data,
98 unsigned int *context_length_out)
101 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
102 if (unlikely (buffer->in_pos + count > end))
105 for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
107 while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
109 if (unlikely (j + count - i == end))
114 if (likely (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
118 *context_length_out = j - buffer->in_pos;
123 static inline bool match_backtrack (APPLY_ARG_DEF,
125 const USHORT backtrack[],
126 match_func_t match_func,
127 const char *match_data)
129 if (unlikely (buffer->out_pos < count))
132 for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
134 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
136 if (unlikely (j + 1 == count - i))
141 if (likely (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
148 static inline bool match_lookahead (APPLY_ARG_DEF,
150 const USHORT lookahead[],
151 match_func_t match_func,
152 const char *match_data,
156 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
157 if (unlikely (buffer->in_pos + offset + count > end))
160 for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
162 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
164 if (unlikely (j + count - i == end))
169 if (likely (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
179 static inline unsigned int get_size () { return sizeof (LookupRecord); }
181 inline bool sanitize (hb_sanitize_context_t *context) {
183 return SANITIZE_SELF ();
186 USHORT sequenceIndex; /* Index into current glyph
187 * sequence--first glyph = 0 */
188 USHORT lookupListIndex; /* Lookup to apply to that
189 * position--zero--based */
191 ASSERT_SIZE (LookupRecord, 4);
193 static inline bool apply_lookup (APPLY_ARG_DEF,
194 unsigned int count, /* Including the first glyph */
195 unsigned int lookupCount,
196 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
197 apply_lookup_func_t apply_func)
199 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
200 if (unlikely (buffer->in_pos + count > end))
203 /* TODO We don't support lookupRecord arrays that are not increasing:
204 * Should be easy for in_place ones at least. */
206 /* Note: If sublookup is reverse, i will underflow after the first loop
207 * and we jump out of it. Not entirely disastrous. So we don't check
208 * for reverse lookup here.
210 for (unsigned int i = 0; i < count; /* NOP */)
212 while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
214 if (unlikely (buffer->in_pos == end))
216 /* No lookup applied for this index */
217 _hb_buffer_next_glyph (buffer);
220 if (lookupCount && i == lookupRecord->sequenceIndex)
222 unsigned int old_pos = buffer->in_pos;
225 bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex);
229 /* Err, this is wrong if the lookup jumped over some glyphs */
230 i += buffer->in_pos - old_pos;
231 if (unlikely (buffer->in_pos == end))
240 /* No lookup applied for this index */
241 _hb_buffer_next_glyph (buffer);
250 /* Contextual lookups */
252 struct ContextLookupContext
255 const char *match_data;
258 static inline bool context_lookup (APPLY_ARG_DEF,
259 unsigned int inputCount, /* Including the first glyph (not matched) */
260 const USHORT input[], /* Array of input values--start with second glyph */
261 unsigned int lookupCount,
262 const LookupRecord lookupRecord[],
263 ContextLookupContext &lookup_context)
265 return match_input (APPLY_ARG,
267 lookup_context.funcs.match, lookup_context.match_data,
269 apply_lookup (APPLY_ARG,
271 lookupCount, lookupRecord,
272 lookup_context.funcs.apply);
277 friend struct RuleSet;
280 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
283 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
284 return context_lookup (APPLY_ARG,
286 lookupCount, lookupRecord,
291 inline bool sanitize (hb_sanitize_context_t *context) {
293 if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
294 return SANITIZE_MEM (input,
295 input[0].get_size () * inputCount +
296 lookupRecordX[0].get_size () * lookupCount);
300 USHORT inputCount; /* Total number of glyphs in input
301 * glyph sequence--includes the first
303 USHORT lookupCount; /* Number of LookupRecords */
304 USHORT input[VAR]; /* Array of match inputs--start with
306 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
309 ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
313 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
316 unsigned int num_rules = rule.len;
317 for (unsigned int i = 0; i < num_rules; i++)
319 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
326 inline bool sanitize (hb_sanitize_context_t *context) {
328 return SANITIZE_WITH_BASE (this, rule);
333 rule; /* Array of Rule tables
334 * ordered by preference */
338 struct ContextFormat1
340 friend struct Context;
343 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
346 unsigned int index = (this+coverage) (IN_CURGLYPH ());
347 if (likely (index == NOT_COVERED))
350 const RuleSet &rule_set = this+ruleSet[index];
351 struct ContextLookupContext lookup_context = {
352 {match_glyph, apply_func},
355 return rule_set.apply (APPLY_ARG, lookup_context);
358 inline bool sanitize (hb_sanitize_context_t *context) {
360 return SANITIZE_WITH_BASE (this, coverage)
361 && SANITIZE_WITH_BASE (this, 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 (hb_sanitize_context_t *context) {
403 return SANITIZE_WITH_BASE (this, coverage)
404 && SANITIZE_WITH_BASE (this, classDef)
405 && SANITIZE_WITH_BASE (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 (hb_sanitize_context_t *context) {
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_WITH_BASE (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 (hb_sanitize_context_t *context) {
486 if (!SANITIZE (u.format)) return false;
488 case 1: return u.format1->sanitize (context);
489 case 2: return u.format2->sanitize (context);
490 case 3: return u.format3->sanitize (context);
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 (hb_sanitize_context_t *context) {
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 (hb_sanitize_context_t *context) {
615 return SANITIZE_WITH_BASE (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 (hb_sanitize_context_t *context) {
647 return SANITIZE_WITH_BASE (this, coverage)
648 && SANITIZE_WITH_BASE (this, ruleSet);
652 USHORT format; /* Format identifier--format = 1 */
654 coverage; /* Offset to Coverage table--from
655 * beginning of table */
656 OffsetArrayOf<ChainRuleSet>
657 ruleSet; /* Array of ChainRuleSet tables
658 * ordered by Coverage Index */
660 ASSERT_SIZE (ChainContextFormat1, 6);
662 struct ChainContextFormat2
664 friend struct ChainContext;
667 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
670 unsigned int index = (this+coverage) (IN_CURGLYPH ());
671 if (likely (index == NOT_COVERED))
674 const ClassDef &backtrack_class_def = this+backtrackClassDef;
675 const ClassDef &input_class_def = this+inputClassDef;
676 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
678 index = input_class_def (IN_CURGLYPH ());
679 const ChainRuleSet &rule_set = this+ruleSet[index];
680 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
681 * them across subrule lookups. Not sure it's worth it.
683 struct ChainContextLookupContext lookup_context = {
684 {match_class, apply_func},
685 {CharP(&backtrack_class_def),
686 CharP(&input_class_def),
687 CharP(&lookahead_class_def)}
689 return rule_set.apply (APPLY_ARG, lookup_context);
692 inline bool sanitize (hb_sanitize_context_t *context) {
694 return SANITIZE_WITH_BASE (this, coverage)
695 && SANITIZE_WITH_BASE (this, backtrackClassDef)
696 && SANITIZE_WITH_BASE (this, inputClassDef)
697 && SANITIZE_WITH_BASE (this, lookaheadClassDef)
698 && SANITIZE_WITH_BASE (this, ruleSet);
702 USHORT format; /* Format identifier--format = 2 */
704 coverage; /* Offset to Coverage table--from
705 * beginning of table */
707 backtrackClassDef; /* Offset to glyph ClassDef table
708 * containing backtrack sequence
709 * data--from beginning of table */
711 inputClassDef; /* Offset to glyph ClassDef
712 * table containing input sequence
713 * data--from beginning of table */
715 lookaheadClassDef; /* Offset to glyph ClassDef table
716 * containing lookahead sequence
717 * data--from beginning of table */
718 OffsetArrayOf<ChainRuleSet>
719 ruleSet; /* Array of ChainRuleSet tables
720 * ordered by class */
722 ASSERT_SIZE (ChainContextFormat2, 12);
724 struct ChainContextFormat3
726 friend struct ChainContext;
730 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
733 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
735 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
736 if (likely (index == NOT_COVERED))
739 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
740 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
741 struct ChainContextLookupContext lookup_context = {
742 {match_coverage, apply_func},
743 {CharP(this), CharP(this), CharP(this)}
745 return chain_context_lookup (APPLY_ARG,
746 backtrack.len, (const USHORT *) backtrack.array(),
747 input.len, (const USHORT *) input.array() + 1,
748 lookahead.len, (const USHORT *) lookahead.array(),
749 lookup.len, lookup.array(),
754 inline bool sanitize (hb_sanitize_context_t *context) {
756 if (!SANITIZE_WITH_BASE (this, backtrack)) return false;
757 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
758 if (!SANITIZE_WITH_BASE (this, input)) return false;
759 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
760 if (!SANITIZE_WITH_BASE (this, lookahead)) return false;
761 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
762 return SANITIZE (lookup);
766 USHORT format; /* Format identifier--format = 3 */
767 OffsetArrayOf<Coverage>
768 backtrack; /* Array of coverage tables
769 * in backtracking sequence, in glyph
771 OffsetArrayOf<Coverage>
772 inputX ; /* Array of coverage
773 * tables in input sequence, in glyph
775 OffsetArrayOf<Coverage>
776 lookaheadX; /* Array of coverage tables
777 * in lookahead sequence, in glyph
779 ArrayOf<LookupRecord>
780 lookupX; /* Array of LookupRecords--in
783 ASSERT_SIZE (ChainContextFormat3, 10);
788 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
792 case 1: return u.format1->apply (APPLY_ARG, apply_func);
793 case 2: return u.format2->apply (APPLY_ARG, apply_func);
794 case 3: return u.format3->apply (APPLY_ARG, apply_func);
795 default:return false;
799 inline bool sanitize (hb_sanitize_context_t *context) {
801 if (!SANITIZE (u.format)) return false;
803 case 1: return u.format1->sanitize (context);
804 case 2: return u.format2->sanitize (context);
805 case 3: return u.format3->sanitize (context);
812 USHORT format; /* Format identifier */
813 ChainContextFormat1 format1[VAR];
814 ChainContextFormat2 format2[VAR];
815 ChainContextFormat3 format3[VAR];
820 struct ExtensionFormat1
822 friend struct Extension;
825 inline unsigned int get_type (void) const { return extensionLookupType; }
826 inline unsigned int get_offset (void) const { return extensionOffset; }
828 inline bool sanitize (hb_sanitize_context_t *context) {
830 return SANITIZE_SELF ();
834 USHORT format; /* Format identifier. Set to 1. */
835 USHORT extensionLookupType; /* Lookup type of subtable referenced
836 * by ExtensionOffset (i.e. the
837 * extension subtable). */
838 ULONG extensionOffset; /* Offset to the extension subtable,
839 * of lookup type subtable. */
841 ASSERT_SIZE (ExtensionFormat1, 8);
845 inline unsigned int get_type (void) const
848 case 1: return u.format1->get_type ();
852 inline unsigned int get_offset (void) const
855 case 1: return u.format1->get_offset ();
860 inline bool sanitize (hb_sanitize_context_t *context) {
862 if (!SANITIZE (u.format)) return false;
864 case 1: return u.format1->sanitize (context);
871 USHORT format; /* Format identifier */
872 ExtensionFormat1 format1[VAR];
883 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
884 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
886 inline unsigned int get_script_count (void) const
887 { return (this+scriptList).len; }
888 inline const Tag& get_script_tag (unsigned int i) const
889 { return (this+scriptList).get_tag (i); }
890 inline unsigned int get_script_tags (unsigned int start_offset,
891 unsigned int *script_count /* IN/OUT */,
892 hb_tag_t *script_tags /* OUT */) const
893 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
894 inline const Script& get_script (unsigned int i) const
895 { return (this+scriptList)[i]; }
896 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
897 { return (this+scriptList).find_index (tag, index); }
899 inline unsigned int get_feature_count (void) const
900 { return (this+featureList).len; }
901 inline const Tag& get_feature_tag (unsigned int i) const
902 { return (this+featureList).get_tag (i); }
903 inline unsigned int get_feature_tags (unsigned int start_offset,
904 unsigned int *feature_count /* IN/OUT */,
905 hb_tag_t *feature_tags /* OUT */) const
906 { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); }
907 inline const Feature& get_feature (unsigned int i) const
908 { return (this+featureList)[i]; }
909 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
910 { return (this+featureList).find_index (tag, index); }
912 inline unsigned int get_lookup_count (void) const
913 { return (this+lookupList).len; }
914 inline const Lookup& get_lookup (unsigned int i) const
915 { return (this+lookupList)[i]; }
917 inline bool sanitize (hb_sanitize_context_t *context) {
919 return SANITIZE (version) && likely (version.major == 1)
920 && SANITIZE_WITH_BASE (this, scriptList)
921 && SANITIZE_WITH_BASE (this, featureList)
922 && SANITIZE_WITH_BASE (this, lookupList);
926 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
929 scriptList; /* ScriptList table */
930 OffsetTo<FeatureList>
931 featureList; /* FeatureList table */
933 lookupList; /* LookupList table */
935 ASSERT_SIZE (GSUBGPOS, 10);
938 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */