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 apply_depth HB_UNUSED
50 (HB_DEBUG_APPLY ? apply_depth + 1 : 0)
52 struct hb_apply_context_t
54 hb_ot_layout_context_t *layout;
56 unsigned int context_length;
57 unsigned int nesting_level_left;
58 unsigned int lookup_flag;
59 unsigned int property; /* propety of first glyph (TODO remove) */
66 #define BUFFER context->buffer
69 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
70 typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
75 apply_lookup_func_t apply;
79 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
81 return glyph_id == value;
84 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
86 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
87 return class_def.get_class (glyph_id) == value;
90 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
92 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
93 return (data+coverage) (glyph_id) != NOT_COVERED;
97 static inline bool match_input (APPLY_ARG_DEF,
98 unsigned int count, /* Including the first glyph (not matched) */
99 const USHORT input[], /* Array of input values--start with second glyph */
100 match_func_t match_func,
101 const char *match_data,
102 unsigned int *context_length_out)
105 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
106 if (unlikely (context->buffer->in_pos + count > end))
109 for (i = 1, j = context->buffer->in_pos + 1; i < count; i++, j++)
111 while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
113 if (unlikely (j + count - i == end))
118 if (likely (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
122 *context_length_out = j - context->buffer->in_pos;
127 static inline bool match_backtrack (APPLY_ARG_DEF,
129 const USHORT backtrack[],
130 match_func_t match_func,
131 const char *match_data)
133 if (unlikely (context->buffer->out_pos < count))
136 for (unsigned int i = 0, j = context->buffer->out_pos - 1; i < count; i++, j--)
138 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
140 if (unlikely (j + 1 == count - i))
145 if (likely (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
152 static inline bool match_lookahead (APPLY_ARG_DEF,
154 const USHORT lookahead[],
155 match_func_t match_func,
156 const char *match_data,
160 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
161 if (unlikely (context->buffer->in_pos + offset + count > end))
164 for (i = 0, j = context->buffer->in_pos + offset; i < count; i++, j++)
166 while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
168 if (unlikely (j + count - i == end))
173 if (likely (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
183 static inline unsigned int get_size () { return sizeof (LookupRecord); }
185 inline bool sanitize (hb_sanitize_context_t *context) {
187 return SANITIZE_SELF ();
190 USHORT sequenceIndex; /* Index into current glyph
191 * sequence--first glyph = 0 */
192 USHORT lookupListIndex; /* Lookup to apply to that
193 * position--zero--based */
195 ASSERT_SIZE (LookupRecord, 4);
197 static inline bool apply_lookup (APPLY_ARG_DEF,
198 unsigned int count, /* Including the first glyph */
199 unsigned int lookupCount,
200 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
201 apply_lookup_func_t apply_func)
203 unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
204 if (unlikely (context->buffer->in_pos + count > end))
207 /* TODO We don't support lookupRecord arrays that are not increasing:
208 * Should be easy for in_place ones at least. */
210 /* Note: If sublookup is reverse, i will underflow after the first loop
211 * and we jump out of it. Not entirely disastrous. So we don't check
212 * for reverse lookup here.
214 for (unsigned int i = 0; i < count; /* NOP */)
216 while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
218 if (unlikely (context->buffer->in_pos == end))
220 /* No lookup applied for this index */
221 _hb_buffer_next_glyph (context->buffer);
224 if (lookupCount && i == lookupRecord->sequenceIndex)
226 unsigned int old_pos = context->buffer->in_pos;
229 bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex);
233 /* Err, this is wrong if the lookup jumped over some glyphs */
234 i += context->buffer->in_pos - old_pos;
235 if (unlikely (context->buffer->in_pos == end))
244 /* No lookup applied for this index */
245 _hb_buffer_next_glyph (context->buffer);
254 /* Contextual lookups */
256 struct ContextLookupContext
259 const char *match_data;
262 static inline bool context_lookup (APPLY_ARG_DEF,
263 unsigned int inputCount, /* Including the first glyph (not matched) */
264 const USHORT input[], /* Array of input values--start with second glyph */
265 unsigned int lookupCount,
266 const LookupRecord lookupRecord[],
267 ContextLookupContext &lookup_context)
269 unsigned int new_context_length;
270 if (!match_input (APPLY_ARG,
272 lookup_context.funcs.match, lookup_context.match_data,
273 &new_context_length)) return false;
274 unsigned int old_context_length;
275 old_context_length = context->context_length;
276 context->context_length = new_context_length;
277 bool ret = apply_lookup (APPLY_ARG,
279 lookupCount, lookupRecord,
280 lookup_context.funcs.apply);
281 context->context_length = old_context_length;
287 friend struct RuleSet;
290 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
293 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
294 return context_lookup (APPLY_ARG,
296 lookupCount, lookupRecord,
301 inline bool sanitize (hb_sanitize_context_t *context) {
303 if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
304 return SANITIZE_MEM (input,
305 input[0].get_size () * inputCount +
306 lookupRecordX[0].get_size () * lookupCount);
310 USHORT inputCount; /* Total number of glyphs in input
311 * glyph sequence--includes the first
313 USHORT lookupCount; /* Number of LookupRecords */
314 USHORT input[VAR]; /* Array of match inputs--start with
316 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
319 ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
323 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
326 unsigned int num_rules = rule.len;
327 for (unsigned int i = 0; i < num_rules; i++)
329 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
336 inline bool sanitize (hb_sanitize_context_t *context) {
338 return SANITIZE_WITH_BASE (this, rule);
343 rule; /* Array of Rule tables
344 * ordered by preference */
348 struct ContextFormat1
350 friend struct Context;
353 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
356 unsigned int index = (this+coverage) (IN_CURGLYPH ());
357 if (likely (index == NOT_COVERED))
360 const RuleSet &rule_set = this+ruleSet[index];
361 struct ContextLookupContext lookup_context = {
362 {match_glyph, apply_func},
365 return rule_set.apply (APPLY_ARG, lookup_context);
368 inline bool sanitize (hb_sanitize_context_t *context) {
370 return SANITIZE_WITH_BASE (this, coverage)
371 && SANITIZE_WITH_BASE (this, 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 (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},
408 return rule_set.apply (APPLY_ARG, lookup_context);
411 inline bool sanitize (hb_sanitize_context_t *context) {
413 return SANITIZE_WITH_BASE (this, coverage)
414 && SANITIZE_WITH_BASE (this, classDef)
415 && SANITIZE_WITH_BASE (this, ruleSet);
419 USHORT format; /* Format identifier--format = 2 */
421 coverage; /* Offset to Coverage table--from
422 * beginning of table */
424 classDef; /* Offset to glyph ClassDef table--from
425 * beginning of table */
426 OffsetArrayOf<RuleSet>
427 ruleSet; /* Array of RuleSet tables
428 * ordered by class */
430 ASSERT_SIZE (ContextFormat2, 8);
433 struct ContextFormat3
435 friend struct Context;
438 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
441 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
442 if (likely (index == NOT_COVERED))
445 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount);
446 struct ContextLookupContext lookup_context = {
447 {match_coverage, apply_func},
450 return context_lookup (APPLY_ARG,
451 glyphCount, (const USHORT *) (coverage + 1),
452 lookupCount, lookupRecord,
456 inline bool sanitize (hb_sanitize_context_t *context) {
458 if (!SANITIZE_SELF ()) return false;
459 unsigned int count = glyphCount;
460 if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), glyphCount)) return false;
461 for (unsigned int i = 0; i < count; i++)
462 if (!SANITIZE_WITH_BASE (this, coverage[i])) return false;
463 LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * glyphCount);
464 return SANITIZE_ARRAY (lookupRecord, LookupRecord::get_size (), lookupCount);
468 USHORT format; /* Format identifier--format = 3 */
469 USHORT glyphCount; /* Number of glyphs in the input glyph
471 USHORT lookupCount; /* Number of LookupRecords */
473 coverage[VAR]; /* Array of offsets to Coverage
474 * table in glyph sequence order */
475 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
478 ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
483 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
487 case 1: return u.format1->apply (APPLY_ARG, apply_func);
488 case 2: return u.format2->apply (APPLY_ARG, apply_func);
489 case 3: return u.format3->apply (APPLY_ARG, apply_func);
490 default:return false;
494 inline bool sanitize (hb_sanitize_context_t *context) {
496 if (!SANITIZE (u.format)) return false;
498 case 1: return u.format1->sanitize (context);
499 case 2: return u.format2->sanitize (context);
500 case 3: return u.format3->sanitize (context);
507 USHORT format; /* Format identifier */
508 ContextFormat1 format1[VAR];
509 ContextFormat2 format2[VAR];
510 ContextFormat3 format3[VAR];
515 /* Chaining Contextual lookups */
517 struct ChainContextLookupContext
520 const char *match_data[3];
523 static inline bool chain_context_lookup (APPLY_ARG_DEF,
524 unsigned int backtrackCount,
525 const USHORT backtrack[],
526 unsigned int inputCount, /* Including the first glyph (not matched) */
527 const USHORT input[], /* Array of input values--start with second glyph */
528 unsigned int lookaheadCount,
529 const USHORT lookahead[],
530 unsigned int lookupCount,
531 const LookupRecord lookupRecord[],
532 ChainContextLookupContext &lookup_context)
535 if (unlikely (context->buffer->out_pos < backtrackCount ||
536 context->buffer->in_pos + inputCount + lookaheadCount > context->buffer->in_length ||
537 inputCount + lookaheadCount > context->context_length))
541 if (!(match_backtrack (APPLY_ARG,
542 backtrackCount, backtrack,
543 lookup_context.funcs.match, lookup_context.match_data[0]) &&
544 match_input (APPLY_ARG,
546 lookup_context.funcs.match, lookup_context.match_data[1],
548 match_lookahead (APPLY_ARG,
549 lookaheadCount, lookahead,
550 lookup_context.funcs.match, lookup_context.match_data[2],
551 offset))) return false;
553 unsigned int old_context_length;
554 old_context_length = context->context_length;
555 context->context_length = offset;
556 bool ret = apply_lookup (APPLY_ARG,
558 lookupCount, lookupRecord,
559 lookup_context.funcs.apply);
560 context->context_length = old_context_length;
566 friend struct ChainRuleSet;
569 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
572 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
573 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
574 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
575 return chain_context_lookup (APPLY_ARG,
576 backtrack.len, backtrack.array(),
577 input.len, input.array(),
578 lookahead.len, lookahead.array(),
579 lookup.len, lookup.array(),
585 inline bool sanitize (hb_sanitize_context_t *context) {
587 if (!SANITIZE (backtrack)) return false;
588 HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
589 if (!SANITIZE (input)) return false;
590 ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
591 if (!SANITIZE (lookahead)) return false;
592 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
593 return SANITIZE (lookup);
598 backtrack; /* Array of backtracking values
599 * (to be matched before the input
601 HeadlessArrayOf<USHORT>
602 inputX; /* Array of input values (start with
605 lookaheadX; /* Array of lookahead values's (to be
606 * matched after the input sequence) */
607 ArrayOf<LookupRecord>
608 lookupX; /* Array of LookupRecords--in
611 ASSERT_SIZE (ChainRule, 8);
615 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
618 unsigned int num_rules = rule.len;
619 for (unsigned int i = 0; i < num_rules; i++)
621 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
628 inline bool sanitize (hb_sanitize_context_t *context) {
630 return SANITIZE_WITH_BASE (this, rule);
634 OffsetArrayOf<ChainRule>
635 rule; /* Array of ChainRule tables
636 * ordered by preference */
638 ASSERT_SIZE (ChainRuleSet, 2);
640 struct ChainContextFormat1
642 friend struct ChainContext;
645 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
648 unsigned int index = (this+coverage) (IN_CURGLYPH ());
649 if (likely (index == NOT_COVERED))
652 const ChainRuleSet &rule_set = this+ruleSet[index];
653 struct ChainContextLookupContext lookup_context = {
654 {match_glyph, apply_func},
657 return rule_set.apply (APPLY_ARG, lookup_context);
660 inline bool sanitize (hb_sanitize_context_t *context) {
662 return SANITIZE_WITH_BASE (this, coverage)
663 && SANITIZE_WITH_BASE (this, ruleSet);
667 USHORT format; /* Format identifier--format = 1 */
669 coverage; /* Offset to Coverage table--from
670 * beginning of table */
671 OffsetArrayOf<ChainRuleSet>
672 ruleSet; /* Array of ChainRuleSet tables
673 * ordered by Coverage Index */
675 ASSERT_SIZE (ChainContextFormat1, 6);
677 struct ChainContextFormat2
679 friend struct ChainContext;
682 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
685 unsigned int index = (this+coverage) (IN_CURGLYPH ());
686 if (likely (index == NOT_COVERED))
689 const ClassDef &backtrack_class_def = this+backtrackClassDef;
690 const ClassDef &input_class_def = this+inputClassDef;
691 const ClassDef &lookahead_class_def = this+lookaheadClassDef;
693 index = input_class_def (IN_CURGLYPH ());
694 const ChainRuleSet &rule_set = this+ruleSet[index];
695 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
696 * them across subrule lookups. Not sure it's worth it.
698 struct ChainContextLookupContext lookup_context = {
699 {match_class, apply_func},
700 {CharP(&backtrack_class_def),
701 CharP(&input_class_def),
702 CharP(&lookahead_class_def)}
704 return rule_set.apply (APPLY_ARG, lookup_context);
707 inline bool sanitize (hb_sanitize_context_t *context) {
709 return SANITIZE_WITH_BASE (this, coverage)
710 && SANITIZE_WITH_BASE (this, backtrackClassDef)
711 && SANITIZE_WITH_BASE (this, inputClassDef)
712 && SANITIZE_WITH_BASE (this, lookaheadClassDef)
713 && SANITIZE_WITH_BASE (this, ruleSet);
717 USHORT format; /* Format identifier--format = 2 */
719 coverage; /* Offset to Coverage table--from
720 * beginning of table */
722 backtrackClassDef; /* Offset to glyph ClassDef table
723 * containing backtrack sequence
724 * data--from beginning of table */
726 inputClassDef; /* Offset to glyph ClassDef
727 * table containing input sequence
728 * data--from beginning of table */
730 lookaheadClassDef; /* Offset to glyph ClassDef table
731 * containing lookahead sequence
732 * data--from beginning of table */
733 OffsetArrayOf<ChainRuleSet>
734 ruleSet; /* Array of ChainRuleSet tables
735 * ordered by class */
737 ASSERT_SIZE (ChainContextFormat2, 12);
739 struct ChainContextFormat3
741 friend struct ChainContext;
745 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
748 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
750 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
751 if (likely (index == NOT_COVERED))
754 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
755 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
756 struct ChainContextLookupContext lookup_context = {
757 {match_coverage, apply_func},
758 {CharP(this), CharP(this), CharP(this)}
760 return chain_context_lookup (APPLY_ARG,
761 backtrack.len, (const USHORT *) backtrack.array(),
762 input.len, (const USHORT *) input.array() + 1,
763 lookahead.len, (const USHORT *) lookahead.array(),
764 lookup.len, lookup.array(),
769 inline bool sanitize (hb_sanitize_context_t *context) {
771 if (!SANITIZE_WITH_BASE (this, backtrack)) return false;
772 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
773 if (!SANITIZE_WITH_BASE (this, input)) return false;
774 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
775 if (!SANITIZE_WITH_BASE (this, lookahead)) return false;
776 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
777 return SANITIZE (lookup);
781 USHORT format; /* Format identifier--format = 3 */
782 OffsetArrayOf<Coverage>
783 backtrack; /* Array of coverage tables
784 * in backtracking sequence, in glyph
786 OffsetArrayOf<Coverage>
787 inputX ; /* Array of coverage
788 * tables in input sequence, in glyph
790 OffsetArrayOf<Coverage>
791 lookaheadX; /* Array of coverage tables
792 * in lookahead sequence, in glyph
794 ArrayOf<LookupRecord>
795 lookupX; /* Array of LookupRecords--in
798 ASSERT_SIZE (ChainContextFormat3, 10);
803 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
807 case 1: return u.format1->apply (APPLY_ARG, apply_func);
808 case 2: return u.format2->apply (APPLY_ARG, apply_func);
809 case 3: return u.format3->apply (APPLY_ARG, apply_func);
810 default:return false;
814 inline bool sanitize (hb_sanitize_context_t *context) {
816 if (!SANITIZE (u.format)) return false;
818 case 1: return u.format1->sanitize (context);
819 case 2: return u.format2->sanitize (context);
820 case 3: return u.format3->sanitize (context);
827 USHORT format; /* Format identifier */
828 ChainContextFormat1 format1[VAR];
829 ChainContextFormat2 format2[VAR];
830 ChainContextFormat3 format3[VAR];
835 struct ExtensionFormat1
837 friend struct Extension;
840 inline unsigned int get_type (void) const { return extensionLookupType; }
841 inline unsigned int get_offset (void) const { return extensionOffset; }
843 inline bool sanitize (hb_sanitize_context_t *context) {
845 return SANITIZE_SELF ();
849 USHORT format; /* Format identifier. Set to 1. */
850 USHORT extensionLookupType; /* Lookup type of subtable referenced
851 * by ExtensionOffset (i.e. the
852 * extension subtable). */
853 ULONG extensionOffset; /* Offset to the extension subtable,
854 * of lookup type subtable. */
856 ASSERT_SIZE (ExtensionFormat1, 8);
860 inline unsigned int get_type (void) const
863 case 1: return u.format1->get_type ();
867 inline unsigned int get_offset (void) const
870 case 1: return u.format1->get_offset ();
875 inline bool sanitize (hb_sanitize_context_t *context) {
877 if (!SANITIZE (u.format)) return false;
879 case 1: return u.format1->sanitize (context);
886 USHORT format; /* Format identifier */
887 ExtensionFormat1 format1[VAR];
898 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
899 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
901 inline unsigned int get_script_count (void) const
902 { return (this+scriptList).len; }
903 inline const Tag& get_script_tag (unsigned int i) const
904 { return (this+scriptList).get_tag (i); }
905 inline unsigned int get_script_tags (unsigned int start_offset,
906 unsigned int *script_count /* IN/OUT */,
907 hb_tag_t *script_tags /* OUT */) const
908 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
909 inline const Script& get_script (unsigned int i) const
910 { return (this+scriptList)[i]; }
911 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
912 { return (this+scriptList).find_index (tag, index); }
914 inline unsigned int get_feature_count (void) const
915 { return (this+featureList).len; }
916 inline const Tag& get_feature_tag (unsigned int i) const
917 { return (this+featureList).get_tag (i); }
918 inline unsigned int get_feature_tags (unsigned int start_offset,
919 unsigned int *feature_count /* IN/OUT */,
920 hb_tag_t *feature_tags /* OUT */) const
921 { return (this+featureList).get_tags (start_offset, 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 (hb_sanitize_context_t *context) {
934 return SANITIZE (version) && likely (version.major == 1)
935 && SANITIZE_WITH_BASE (this, scriptList)
936 && SANITIZE_WITH_BASE (this, featureList)
937 && SANITIZE_WITH_BASE (this, lookupList);
941 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
944 scriptList; /* ScriptList table */
945 OffsetTo<FeatureList>
946 featureList; /* FeatureList table */
948 lookupList; /* LookupList table */
950 ASSERT_SIZE (GSUBGPOS, 10);
953 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */