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() \
39 hb_trace_t<HB_DEBUG_APPLY> trace (&context->debug_depth); \
40 trace.log ("APPLY", HB_FUNC, this);
43 struct hb_apply_context_t
45 unsigned int debug_depth;
46 hb_ot_layout_context_t *layout;
48 unsigned int context_length;
49 unsigned int nesting_level_left;
50 unsigned int lookup_flag;
51 unsigned int property; /* propety of first glyph (TODO remove) */
58 #define BUFFER context->buffer
61 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
62 typedef bool (*apply_lookup_func_t) (hb_apply_context_t *context, unsigned int lookup_index);
67 apply_lookup_func_t apply;
71 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
73 return glyph_id == value;
76 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
78 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
79 return class_def.get_class (glyph_id) == value;
82 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
84 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
85 return (data+coverage) (glyph_id) != NOT_COVERED;
89 static inline bool match_input (hb_apply_context_t *context,
90 unsigned int count, /* Including the first glyph (not matched) */
91 const USHORT input[], /* Array of input values--start with second glyph */
92 match_func_t match_func,
93 const char *match_data,
94 unsigned int *context_length_out)
97 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
98 if (unlikely (context->buffer->in_pos + count > end))
101 for (i = 1, j = context->buffer->in_pos + 1; i < count; i++, j++)
103 while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
105 if (unlikely (j + count - i == end))
110 if (likely (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
114 *context_length_out = j - context->buffer->in_pos;
119 static inline bool match_backtrack (hb_apply_context_t *context,
121 const USHORT backtrack[],
122 match_func_t match_func,
123 const char *match_data)
125 if (unlikely (context->buffer->out_pos < count))
128 for (unsigned int i = 0, j = context->buffer->out_pos - 1; i < count; i++, j--)
130 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
132 if (unlikely (j + 1 == count - i))
137 if (likely (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
144 static inline bool match_lookahead (hb_apply_context_t *context,
146 const USHORT lookahead[],
147 match_func_t match_func,
148 const char *match_data,
152 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
153 if (unlikely (context->buffer->in_pos + offset + count > end))
156 for (i = 0, j = context->buffer->in_pos + offset; i < count; i++, j++)
158 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
160 if (unlikely (j + count - i == end))
165 if (likely (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
175 static inline unsigned int get_size () { return sizeof (LookupRecord); }
177 inline bool sanitize (hb_sanitize_context_t *context) {
179 return SANITIZE_SELF ();
182 USHORT sequenceIndex; /* Index into current glyph
183 * sequence--first glyph = 0 */
184 USHORT lookupListIndex; /* Lookup to apply to that
185 * position--zero--based */
187 ASSERT_SIZE (LookupRecord, 4);
189 static inline bool apply_lookup (hb_apply_context_t *context,
190 unsigned int count, /* Including the first glyph */
191 unsigned int lookupCount,
192 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
193 apply_lookup_func_t apply_func)
195 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
196 if (unlikely (context->buffer->in_pos + count > end))
199 /* TODO We don't support lookupRecord arrays that are not increasing:
200 * Should be easy for in_place ones at least. */
202 /* Note: If sublookup is reverse, i will underflow after the first loop
203 * and we jump out of it. Not entirely disastrous. So we don't check
204 * for reverse lookup here.
206 for (unsigned int i = 0; i < count; /* NOP */)
208 while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
210 if (unlikely (context->buffer->in_pos == end))
212 /* No lookup applied for this index */
213 _hb_buffer_next_glyph (context->buffer);
216 if (lookupCount && i == lookupRecord->sequenceIndex)
218 unsigned int old_pos = context->buffer->in_pos;
221 bool done = apply_func (context, lookupRecord->lookupListIndex);
225 /* Err, this is wrong if the lookup jumped over some glyphs */
226 i += context->buffer->in_pos - old_pos;
227 if (unlikely (context->buffer->in_pos == end))
236 /* No lookup applied for this index */
237 _hb_buffer_next_glyph (context->buffer);
246 /* Contextual lookups */
248 struct ContextLookupContext
251 const char *match_data;
254 static inline bool context_lookup (hb_apply_context_t *context,
255 unsigned int inputCount, /* Including the first glyph (not matched) */
256 const USHORT input[], /* Array of input values--start with second glyph */
257 unsigned int lookupCount,
258 const LookupRecord lookupRecord[],
259 ContextLookupContext &lookup_context)
261 hb_apply_context_t new_context = *context;
262 return match_input (context,
264 lookup_context.funcs.match, lookup_context.match_data,
265 &new_context.context_length)
266 && apply_lookup (&new_context,
268 lookupCount, lookupRecord,
269 lookup_context.funcs.apply);
274 friend struct RuleSet;
277 inline bool apply (hb_apply_context_t *context, ContextLookupContext &lookup_context) const
280 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
281 return context_lookup (context,
283 lookupCount, lookupRecord,
288 inline bool sanitize (hb_sanitize_context_t *context) {
290 if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
291 return SANITIZE_MEM (input,
292 input[0].get_size () * inputCount +
293 lookupRecordX[0].get_size () * lookupCount);
297 USHORT inputCount; /* Total number of glyphs in input
298 * glyph sequence--includes the first
300 USHORT lookupCount; /* Number of LookupRecords */
301 USHORT input[VAR]; /* Array of match inputs--start with
303 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
306 ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
310 inline bool apply (hb_apply_context_t *context, ContextLookupContext &lookup_context) const
313 unsigned int num_rules = rule.len;
314 for (unsigned int i = 0; i < num_rules; i++)
316 if ((this+rule[i]).apply (context, lookup_context))
323 inline bool sanitize (hb_sanitize_context_t *context) {
325 return SANITIZE_WITH_BASE (this, rule);
330 rule; /* Array of Rule tables
331 * ordered by preference */
335 struct ContextFormat1
337 friend struct Context;
340 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
343 unsigned int index = (this+coverage) (IN_CURGLYPH ());
344 if (likely (index == NOT_COVERED))
347 const RuleSet &rule_set = this+ruleSet[index];
348 struct ContextLookupContext lookup_context = {
349 {match_glyph, apply_func},
352 return rule_set.apply (context, lookup_context);
355 inline bool sanitize (hb_sanitize_context_t *context) {
357 return SANITIZE_WITH_BASE (this, coverage)
358 && SANITIZE_WITH_BASE (this, ruleSet);
362 USHORT format; /* Format identifier--format = 1 */
364 coverage; /* Offset to Coverage table--from
365 * beginning of table */
366 OffsetArrayOf<RuleSet>
367 ruleSet; /* Array of RuleSet tables
368 * ordered by Coverage Index */
370 ASSERT_SIZE (ContextFormat1, 6);
373 struct ContextFormat2
375 friend struct Context;
378 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
381 unsigned int index = (this+coverage) (IN_CURGLYPH ());
382 if (likely (index == NOT_COVERED))
385 const ClassDef &class_def = this+classDef;
386 index = class_def (IN_CURGLYPH ());
387 const RuleSet &rule_set = this+ruleSet[index];
388 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
389 * them across subrule lookups. Not sure it's worth it.
391 struct ContextLookupContext lookup_context = {
392 {match_class, apply_func},
395 return rule_set.apply (context, lookup_context);
398 inline bool sanitize (hb_sanitize_context_t *context) {
400 return SANITIZE_WITH_BASE (this, coverage)
401 && SANITIZE_WITH_BASE (this, classDef)
402 && SANITIZE_WITH_BASE (this, ruleSet);
406 USHORT format; /* Format identifier--format = 2 */
408 coverage; /* Offset to Coverage table--from
409 * beginning of table */
411 classDef; /* Offset to glyph ClassDef table--from
412 * beginning of table */
413 OffsetArrayOf<RuleSet>
414 ruleSet; /* Array of RuleSet tables
415 * ordered by class */
417 ASSERT_SIZE (ContextFormat2, 8);
420 struct ContextFormat3
422 friend struct Context;
425 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
428 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
429 if (likely (index == NOT_COVERED))
432 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount);
433 struct ContextLookupContext lookup_context = {
434 {match_coverage, apply_func},
437 return context_lookup (context,
438 glyphCount, (const USHORT *) (coverage + 1),
439 lookupCount, lookupRecord,
443 inline bool sanitize (hb_sanitize_context_t *context) {
445 if (!SANITIZE_SELF ()) return false;
446 unsigned int count = glyphCount;
447 if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), glyphCount)) return false;
448 for (unsigned int i = 0; i < count; i++)
449 if (!SANITIZE_WITH_BASE (this, coverage[i])) return false;
450 LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * glyphCount);
451 return SANITIZE_ARRAY (lookupRecord, LookupRecord::get_size (), lookupCount);
455 USHORT format; /* Format identifier--format = 3 */
456 USHORT glyphCount; /* Number of glyphs in the input glyph
458 USHORT lookupCount; /* Number of LookupRecords */
460 coverage[VAR]; /* Array of offsets to Coverage
461 * table in glyph sequence order */
462 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
465 ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
470 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
474 case 1: return u.format1->apply (context, apply_func);
475 case 2: return u.format2->apply (context, apply_func);
476 case 3: return u.format3->apply (context, apply_func);
477 default:return false;
481 inline bool sanitize (hb_sanitize_context_t *context) {
483 if (!SANITIZE (u.format)) return false;
485 case 1: return u.format1->sanitize (context);
486 case 2: return u.format2->sanitize (context);
487 case 3: return u.format3->sanitize (context);
494 USHORT format; /* Format identifier */
495 ContextFormat1 format1[VAR];
496 ContextFormat2 format2[VAR];
497 ContextFormat3 format3[VAR];
502 /* Chaining Contextual lookups */
504 struct ChainContextLookupContext
507 const char *match_data[3];
510 static inline bool chain_context_lookup (hb_apply_context_t *context,
511 unsigned int backtrackCount,
512 const USHORT backtrack[],
513 unsigned int inputCount, /* Including the first glyph (not matched) */
514 const USHORT input[], /* Array of input values--start with second glyph */
515 unsigned int lookaheadCount,
516 const USHORT lookahead[],
517 unsigned int lookupCount,
518 const LookupRecord lookupRecord[],
519 ChainContextLookupContext &lookup_context)
522 if (unlikely (context->buffer->out_pos < backtrackCount ||
523 context->buffer->in_pos + inputCount + lookaheadCount > context->buffer->in_length ||
524 inputCount + lookaheadCount > context->context_length))
527 hb_apply_context_t new_context = *context;
528 return match_backtrack (context,
529 backtrackCount, backtrack,
530 lookup_context.funcs.match, lookup_context.match_data[0])
531 && match_input (context,
533 lookup_context.funcs.match, lookup_context.match_data[1],
534 &new_context.context_length)
535 && match_lookahead (context,
536 lookaheadCount, lookahead,
537 lookup_context.funcs.match, lookup_context.match_data[2],
538 new_context.context_length)
539 && apply_lookup (&new_context,
541 lookupCount, lookupRecord,
542 lookup_context.funcs.apply);
547 friend struct ChainRuleSet;
550 inline bool apply (hb_apply_context_t *context, ChainContextLookupContext &lookup_context) const
553 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
554 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
555 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
556 return chain_context_lookup (context,
557 backtrack.len, backtrack.array(),
558 input.len, input.array(),
559 lookahead.len, lookahead.array(),
560 lookup.len, lookup.array(),
566 inline bool sanitize (hb_sanitize_context_t *context) {
568 if (!SANITIZE (backtrack)) return false;
569 HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
570 if (!SANITIZE (input)) return false;
571 ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
572 if (!SANITIZE (lookahead)) return false;
573 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
574 return SANITIZE (lookup);
579 backtrack; /* Array of backtracking values
580 * (to be matched before the input
582 HeadlessArrayOf<USHORT>
583 inputX; /* Array of input values (start with
586 lookaheadX; /* Array of lookahead values's (to be
587 * matched after the input sequence) */
588 ArrayOf<LookupRecord>
589 lookupX; /* Array of LookupRecords--in
592 ASSERT_SIZE (ChainRule, 8);
596 inline bool apply (hb_apply_context_t *context, ChainContextLookupContext &lookup_context) const
599 unsigned int num_rules = rule.len;
600 for (unsigned int i = 0; i < num_rules; i++)
602 if ((this+rule[i]).apply (context, lookup_context))
609 inline bool sanitize (hb_sanitize_context_t *context) {
611 return SANITIZE_WITH_BASE (this, rule);
615 OffsetArrayOf<ChainRule>
616 rule; /* Array of ChainRule tables
617 * ordered by preference */
619 ASSERT_SIZE (ChainRuleSet, 2);
621 struct ChainContextFormat1
623 friend struct ChainContext;
626 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
629 unsigned int index = (this+coverage) (IN_CURGLYPH ());
630 if (likely (index == NOT_COVERED))
633 const ChainRuleSet &rule_set = this+ruleSet[index];
634 struct ChainContextLookupContext lookup_context = {
635 {match_glyph, apply_func},
638 return rule_set.apply (context, lookup_context);
641 inline bool sanitize (hb_sanitize_context_t *context) {
643 return SANITIZE_WITH_BASE (this, coverage)
644 && SANITIZE_WITH_BASE (this, ruleSet);
648 USHORT format; /* Format identifier--format = 1 */
650 coverage; /* Offset to Coverage table--from
651 * beginning of table */
652 OffsetArrayOf<ChainRuleSet>
653 ruleSet; /* Array of ChainRuleSet tables
654 * ordered by Coverage Index */
656 ASSERT_SIZE (ChainContextFormat1, 6);
658 struct ChainContextFormat2
660 friend struct ChainContext;
663 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
666 unsigned int index = (this+coverage) (IN_CURGLYPH ());
667 if (likely (index == NOT_COVERED))
670 const ClassDef &backtrack_class_def = this+backtrackClassDef;
671 const ClassDef &input_class_def = this+inputClassDef;
672 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
674 index = input_class_def (IN_CURGLYPH ());
675 const ChainRuleSet &rule_set = this+ruleSet[index];
676 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
677 * them across subrule lookups. Not sure it's worth it.
679 struct ChainContextLookupContext lookup_context = {
680 {match_class, apply_func},
681 {CharP(&backtrack_class_def),
682 CharP(&input_class_def),
683 CharP(&lookahead_class_def)}
685 return rule_set.apply (context, lookup_context);
688 inline bool sanitize (hb_sanitize_context_t *context) {
690 return SANITIZE_WITH_BASE (this, coverage)
691 && SANITIZE_WITH_BASE (this, backtrackClassDef)
692 && SANITIZE_WITH_BASE (this, inputClassDef)
693 && SANITIZE_WITH_BASE (this, lookaheadClassDef)
694 && SANITIZE_WITH_BASE (this, ruleSet);
698 USHORT format; /* Format identifier--format = 2 */
700 coverage; /* Offset to Coverage table--from
701 * beginning of table */
703 backtrackClassDef; /* Offset to glyph ClassDef table
704 * containing backtrack sequence
705 * data--from beginning of table */
707 inputClassDef; /* Offset to glyph ClassDef
708 * table containing input sequence
709 * data--from beginning of table */
711 lookaheadClassDef; /* Offset to glyph ClassDef table
712 * containing lookahead sequence
713 * data--from beginning of table */
714 OffsetArrayOf<ChainRuleSet>
715 ruleSet; /* Array of ChainRuleSet tables
716 * ordered by class */
718 ASSERT_SIZE (ChainContextFormat2, 12);
720 struct ChainContextFormat3
722 friend struct ChainContext;
726 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
729 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
731 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
732 if (likely (index == NOT_COVERED))
735 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
736 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
737 struct ChainContextLookupContext lookup_context = {
738 {match_coverage, apply_func},
739 {CharP(this), CharP(this), CharP(this)}
741 return chain_context_lookup (context,
742 backtrack.len, (const USHORT *) backtrack.array(),
743 input.len, (const USHORT *) input.array() + 1,
744 lookahead.len, (const USHORT *) lookahead.array(),
745 lookup.len, lookup.array(),
750 inline bool sanitize (hb_sanitize_context_t *context) {
752 if (!SANITIZE_WITH_BASE (this, backtrack)) return false;
753 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
754 if (!SANITIZE_WITH_BASE (this, input)) return false;
755 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
756 if (!SANITIZE_WITH_BASE (this, lookahead)) return false;
757 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
758 return SANITIZE (lookup);
762 USHORT format; /* Format identifier--format = 3 */
763 OffsetArrayOf<Coverage>
764 backtrack; /* Array of coverage tables
765 * in backtracking sequence, in glyph
767 OffsetArrayOf<Coverage>
768 inputX ; /* Array of coverage
769 * tables in input sequence, in glyph
771 OffsetArrayOf<Coverage>
772 lookaheadX; /* Array of coverage tables
773 * in lookahead sequence, in glyph
775 ArrayOf<LookupRecord>
776 lookupX; /* Array of LookupRecords--in
779 ASSERT_SIZE (ChainContextFormat3, 10);
784 inline bool apply (hb_apply_context_t *context, apply_lookup_func_t apply_func) const
788 case 1: return u.format1->apply (context, apply_func);
789 case 2: return u.format2->apply (context, apply_func);
790 case 3: return u.format3->apply (context, apply_func);
791 default:return false;
795 inline bool sanitize (hb_sanitize_context_t *context) {
797 if (!SANITIZE (u.format)) return false;
799 case 1: return u.format1->sanitize (context);
800 case 2: return u.format2->sanitize (context);
801 case 3: return u.format3->sanitize (context);
808 USHORT format; /* Format identifier */
809 ChainContextFormat1 format1[VAR];
810 ChainContextFormat2 format2[VAR];
811 ChainContextFormat3 format3[VAR];
816 struct ExtensionFormat1
818 friend struct Extension;
821 inline unsigned int get_type (void) const { return extensionLookupType; }
822 inline unsigned int get_offset (void) const { return extensionOffset; }
824 inline bool sanitize (hb_sanitize_context_t *context) {
826 return SANITIZE_SELF ();
830 USHORT format; /* Format identifier. Set to 1. */
831 USHORT extensionLookupType; /* Lookup type of subtable referenced
832 * by ExtensionOffset (i.e. the
833 * extension subtable). */
834 ULONG extensionOffset; /* Offset to the extension subtable,
835 * of lookup type subtable. */
837 ASSERT_SIZE (ExtensionFormat1, 8);
841 inline unsigned int get_type (void) const
844 case 1: return u.format1->get_type ();
848 inline unsigned int get_offset (void) const
851 case 1: return u.format1->get_offset ();
856 inline bool sanitize (hb_sanitize_context_t *context) {
858 if (!SANITIZE (u.format)) return false;
860 case 1: return u.format1->sanitize (context);
867 USHORT format; /* Format identifier */
868 ExtensionFormat1 format1[VAR];
879 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
880 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
882 inline unsigned int get_script_count (void) const
883 { return (this+scriptList).len; }
884 inline const Tag& get_script_tag (unsigned int i) const
885 { return (this+scriptList).get_tag (i); }
886 inline unsigned int get_script_tags (unsigned int start_offset,
887 unsigned int *script_count /* IN/OUT */,
888 hb_tag_t *script_tags /* OUT */) const
889 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
890 inline const Script& get_script (unsigned int i) const
891 { return (this+scriptList)[i]; }
892 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
893 { return (this+scriptList).find_index (tag, index); }
895 inline unsigned int get_feature_count (void) const
896 { return (this+featureList).len; }
897 inline const Tag& get_feature_tag (unsigned int i) const
898 { return (this+featureList).get_tag (i); }
899 inline unsigned int get_feature_tags (unsigned int start_offset,
900 unsigned int *feature_count /* IN/OUT */,
901 hb_tag_t *feature_tags /* OUT */) const
902 { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); }
903 inline const Feature& get_feature (unsigned int i) const
904 { return (this+featureList)[i]; }
905 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
906 { return (this+featureList).find_index (tag, index); }
908 inline unsigned int get_lookup_count (void) const
909 { return (this+lookupList).len; }
910 inline const Lookup& get_lookup (unsigned int i) const
911 { return (this+lookupList)[i]; }
913 inline bool sanitize (hb_sanitize_context_t *context) {
915 return SANITIZE (version) && likely (version.major == 1)
916 && SANITIZE_WITH_BASE (this, scriptList)
917 && SANITIZE_WITH_BASE (this, featureList)
918 && SANITIZE_WITH_BASE (this, lookupList);
922 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
925 scriptList; /* ScriptList table */
926 OffsetTo<FeatureList>
927 featureList; /* FeatureList table */
929 lookupList; /* LookupList table */
931 ASSERT_SIZE (GSUBGPOS, 10);
934 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */