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
40 #define TRACE_APPLY_ARG_DEF , unsigned int apply_depth HB_GNUC_UNUSED
41 #define TRACE_APPLY_ARG , apply_depth + 1
42 #define TRACE_APPLY_ARG_INIT , 1
43 #define TRACE_APPLY() \
45 if (apply_depth < HB_DEBUG_APPLY) \
46 fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \
47 (CharP (this) == CharP (&NullPool)) ? 0 : this, \
48 apply_depth, apply_depth, \
49 __PRETTY_FUNCTION__); \
52 #define TRACE_APPLY_ARG_DEF
53 #define TRACE_APPLY_ARG
54 #define TRACE_APPLY_ARG_INIT
55 #define TRACE_APPLY() HB_STMT_START {} HB_STMT_END
58 #define APPLY_ARG_DEF \
59 hb_ot_layout_context_t *context, \
60 hb_buffer_t *buffer, \
61 unsigned int context_length HB_GNUC_UNUSED, \
62 unsigned int nesting_level_left HB_GNUC_UNUSED, \
63 unsigned int lookup_flag HB_GNUC_UNUSED, \
64 unsigned int property HB_GNUC_UNUSED /* propety of first glyph */ \
74 #define APPLY_ARG_INIT \
84 typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
85 typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
90 apply_lookup_func_t apply;
94 static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_GNUC_UNUSED)
96 return glyph_id == value;
99 static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
101 const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
102 return class_def.get_class (glyph_id) == value;
105 static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
107 const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
108 return (data+coverage) (glyph_id) != NOT_COVERED;
112 static inline bool match_input (APPLY_ARG_DEF,
113 unsigned int count, /* Including the first glyph (not matched) */
114 const USHORT input[], /* Array of input values--start with second glyph */
115 match_func_t match_func,
116 const char *match_data,
117 unsigned int *context_length_out)
120 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
121 if (HB_UNLIKELY (buffer->in_pos + count > end))
124 for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
126 while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
128 if (HB_UNLIKELY (j + count - i == end))
133 if (HB_LIKELY (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
137 *context_length_out = j - buffer->in_pos;
142 static inline bool match_backtrack (APPLY_ARG_DEF,
144 const USHORT backtrack[],
145 match_func_t match_func,
146 const char *match_data)
148 if (HB_UNLIKELY (buffer->out_pos < count))
151 for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
153 while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
155 if (HB_UNLIKELY (j + 1 == count - i))
160 if (HB_LIKELY (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
167 static inline bool match_lookahead (APPLY_ARG_DEF,
169 const USHORT lookahead[],
170 match_func_t match_func,
171 const char *match_data,
175 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
176 if (HB_UNLIKELY (buffer->in_pos + offset + count > end))
179 for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
181 while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
183 if (HB_UNLIKELY (j + count - i == end))
188 if (HB_LIKELY (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
198 static inline unsigned int get_size () { return sizeof (LookupRecord); }
200 inline bool sanitize (SANITIZE_ARG_DEF) {
202 return SANITIZE_SELF ();
205 USHORT sequenceIndex; /* Index into current glyph
206 * sequence--first glyph = 0 */
207 USHORT lookupListIndex; /* Lookup to apply to that
208 * position--zero--based */
210 ASSERT_SIZE (LookupRecord, 4);
212 static inline bool apply_lookup (APPLY_ARG_DEF,
213 unsigned int count, /* Including the first glyph */
214 unsigned int lookupCount,
215 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
216 apply_lookup_func_t apply_func)
218 unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
219 if (HB_UNLIKELY (buffer->in_pos + count > end))
222 /* TODO We don't support lookupRecord arrays that are not increasing:
223 * Should be easy for in_place ones at least. */
225 /* Note: If sublookup is reverse, i will underflow after the first loop
226 * and we jump out of it. Not entirely disastrous. So we don't check
227 * for reverse lookup here.
229 for (unsigned int i = 0; i < count; /* NOP */)
231 while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL))
233 if (HB_UNLIKELY (buffer->in_pos == end))
235 /* No lookup applied for this index */
236 _hb_buffer_next_glyph (buffer);
239 if (lookupCount && i == lookupRecord->sequenceIndex)
241 unsigned int old_pos = buffer->in_pos;
244 bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex);
248 /* Err, this is wrong if the lookup jumped over some glyphs */
249 i += buffer->in_pos - old_pos;
250 if (HB_UNLIKELY (buffer->in_pos == end))
259 /* No lookup applied for this index */
260 _hb_buffer_next_glyph (buffer);
269 /* Contextual lookups */
271 struct ContextLookupContext
274 const char *match_data;
277 static inline bool context_lookup (APPLY_ARG_DEF,
278 unsigned int inputCount, /* Including the first glyph (not matched) */
279 const USHORT input[], /* Array of input values--start with second glyph */
280 unsigned int lookupCount,
281 const LookupRecord lookupRecord[],
282 ContextLookupContext &lookup_context)
284 return match_input (APPLY_ARG,
286 lookup_context.funcs.match, lookup_context.match_data,
288 apply_lookup (APPLY_ARG,
290 lookupCount, lookupRecord,
291 lookup_context.funcs.apply);
296 friend struct RuleSet;
299 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
302 const LookupRecord *lookupRecord = &CONST_CAST (LookupRecord, input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
303 return context_lookup (APPLY_ARG,
305 lookupCount, lookupRecord,
310 inline bool sanitize (SANITIZE_ARG_DEF) {
312 if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
313 return SANITIZE_MEM (input,
314 input[0].get_size () * inputCount +
315 lookupRecordX[0].get_size () * lookupCount);
319 USHORT inputCount; /* Total number of glyphs in input
320 * glyph sequence--includes the first
322 USHORT lookupCount; /* Number of LookupRecords */
323 USHORT input[VAR]; /* Array of match inputs--start with
325 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
328 ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
332 inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
335 unsigned int num_rules = rule.len;
336 for (unsigned int i = 0; i < num_rules; i++)
338 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
345 inline bool sanitize (SANITIZE_ARG_DEF) {
347 return SANITIZE_THIS (rule);
352 rule; /* Array of Rule tables
353 * ordered by preference */
357 struct ContextFormat1
359 friend struct Context;
362 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
365 unsigned int index = (this+coverage) (IN_CURGLYPH ());
366 if (HB_LIKELY (index == NOT_COVERED))
369 const RuleSet &rule_set = this+ruleSet[index];
370 struct ContextLookupContext lookup_context = {
371 {match_glyph, apply_func},
374 return rule_set.apply (APPLY_ARG, lookup_context);
377 inline bool sanitize (SANITIZE_ARG_DEF) {
379 return SANITIZE_THIS2 (coverage, ruleSet);
383 USHORT format; /* Format identifier--format = 1 */
385 coverage; /* Offset to Coverage table--from
386 * beginning of table */
387 OffsetArrayOf<RuleSet>
388 ruleSet; /* Array of RuleSet tables
389 * ordered by Coverage Index */
391 ASSERT_SIZE (ContextFormat1, 6);
394 struct ContextFormat2
396 friend struct Context;
399 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
402 unsigned int index = (this+coverage) (IN_CURGLYPH ());
403 if (HB_LIKELY (index == NOT_COVERED))
406 const ClassDef &class_def = this+classDef;
407 index = class_def (IN_CURGLYPH ());
408 const RuleSet &rule_set = this+ruleSet[index];
409 /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
410 * them across subrule lookups. Not sure it's worth it.
412 struct ContextLookupContext lookup_context = {
413 {match_class, apply_func},
416 return rule_set.apply (APPLY_ARG, lookup_context);
419 inline bool sanitize (SANITIZE_ARG_DEF) {
421 return SANITIZE_THIS3 (coverage, classDef, ruleSet);
425 USHORT format; /* Format identifier--format = 2 */
427 coverage; /* Offset to Coverage table--from
428 * beginning of table */
430 classDef; /* Offset to glyph ClassDef table--from
431 * beginning of table */
432 OffsetArrayOf<RuleSet>
433 ruleSet; /* Array of RuleSet tables
434 * ordered by class */
436 ASSERT_SIZE (ContextFormat2, 8);
439 struct ContextFormat3
441 friend struct Context;
444 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
447 unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
448 if (HB_LIKELY (index == NOT_COVERED))
451 const LookupRecord *lookupRecord = &CONST_CAST(LookupRecord, coverage, coverage[0].get_size () * glyphCount);
452 struct ContextLookupContext lookup_context = {
453 {match_coverage, apply_func},
456 return context_lookup (APPLY_ARG,
457 glyphCount, (const USHORT *) (coverage + 1),
458 lookupCount, lookupRecord,
462 inline bool sanitize (SANITIZE_ARG_DEF) {
464 if (!SANITIZE_SELF ()) return false;
465 unsigned int count = glyphCount;
466 if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), glyphCount)) return false;
467 for (unsigned int i = 0; i < count; i++)
468 if (!SANITIZE_THIS (coverage[i])) return false;
469 LookupRecord *lookupRecord = &CAST(LookupRecord, coverage, OffsetTo<Coverage>::get_size () * glyphCount);
470 return SANITIZE_ARRAY (lookupRecord, LookupRecord::get_size (), lookupCount);
474 USHORT format; /* Format identifier--format = 3 */
475 USHORT glyphCount; /* Number of glyphs in the input glyph
477 USHORT lookupCount; /* Number of LookupRecords */
479 coverage[VAR]; /* Array of offsets to Coverage
480 * table in glyph sequence order */
481 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
484 ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
489 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
493 case 1: return u.format1->apply (APPLY_ARG, apply_func);
494 case 2: return u.format2->apply (APPLY_ARG, apply_func);
495 case 3: return u.format3->apply (APPLY_ARG, apply_func);
496 default:return false;
500 inline bool sanitize (SANITIZE_ARG_DEF) {
502 if (!SANITIZE (u.format)) return false;
504 case 1: return u.format1->sanitize (SANITIZE_ARG);
505 case 2: return u.format2->sanitize (SANITIZE_ARG);
506 case 3: return u.format3->sanitize (SANITIZE_ARG);
513 USHORT format; /* Format identifier */
514 ContextFormat1 format1[VAR];
515 ContextFormat2 format2[VAR];
516 ContextFormat3 format3[VAR];
521 /* Chaining Contextual lookups */
523 struct ChainContextLookupContext
526 const char *match_data[3];
529 static inline bool chain_context_lookup (APPLY_ARG_DEF,
530 unsigned int backtrackCount,
531 const USHORT backtrack[],
532 unsigned int inputCount, /* Including the first glyph (not matched) */
533 const USHORT input[], /* Array of input values--start with second glyph */
534 unsigned int lookaheadCount,
535 const USHORT lookahead[],
536 unsigned int lookupCount,
537 const LookupRecord lookupRecord[],
538 ChainContextLookupContext &lookup_context)
541 if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
542 buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
543 inputCount + lookaheadCount > context_length))
547 return match_backtrack (APPLY_ARG,
548 backtrackCount, backtrack,
549 lookup_context.funcs.match, lookup_context.match_data[0]) &&
550 match_input (APPLY_ARG,
552 lookup_context.funcs.match, lookup_context.match_data[1],
554 match_lookahead (APPLY_ARG,
555 lookaheadCount, lookahead,
556 lookup_context.funcs.match, lookup_context.match_data[2],
558 (context_length = offset, true) &&
559 apply_lookup (APPLY_ARG,
561 lookupCount, lookupRecord,
562 lookup_context.funcs.apply);
567 friend struct ChainRuleSet;
570 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
573 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
574 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
575 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
576 return chain_context_lookup (APPLY_ARG,
577 backtrack.len, backtrack.array(),
578 input.len, input.array(),
579 lookahead.len, lookahead.array(),
580 lookup.len, lookup.array(),
586 inline bool sanitize (SANITIZE_ARG_DEF) {
588 if (!SANITIZE (backtrack)) return false;
589 HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
590 if (!SANITIZE (input)) return false;
591 ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
592 if (!SANITIZE (lookahead)) return false;
593 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
594 return SANITIZE (lookup);
599 backtrack; /* Array of backtracking values
600 * (to be matched before the input
602 HeadlessArrayOf<USHORT>
603 inputX; /* Array of input values (start with
606 lookaheadX; /* Array of lookahead values's (to be
607 * matched after the input sequence) */
608 ArrayOf<LookupRecord>
609 lookupX; /* Array of LookupRecords--in
612 ASSERT_SIZE (ChainRule, 8);
616 inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
619 unsigned int num_rules = rule.len;
620 for (unsigned int i = 0; i < num_rules; i++)
622 if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
629 inline bool sanitize (SANITIZE_ARG_DEF) {
631 return SANITIZE_THIS (rule);
635 OffsetArrayOf<ChainRule>
636 rule; /* Array of ChainRule tables
637 * ordered by preference */
639 ASSERT_SIZE (ChainRuleSet, 2);
641 struct ChainContextFormat1
643 friend struct ChainContext;
646 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
649 unsigned int index = (this+coverage) (IN_CURGLYPH ());
650 if (HB_LIKELY (index == NOT_COVERED))
653 const ChainRuleSet &rule_set = this+ruleSet[index];
654 struct ChainContextLookupContext lookup_context = {
655 {match_glyph, apply_func},
658 return rule_set.apply (APPLY_ARG, lookup_context);
661 inline bool sanitize (SANITIZE_ARG_DEF) {
663 return SANITIZE_THIS2 (coverage, 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 (HB_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 (SANITIZE_ARG_DEF) {
709 return SANITIZE_THIS2 (coverage, backtrackClassDef) &&
710 SANITIZE_THIS2 (inputClassDef, lookaheadClassDef) &&
711 SANITIZE_THIS (ruleSet);
715 USHORT format; /* Format identifier--format = 2 */
717 coverage; /* Offset to Coverage table--from
718 * beginning of table */
720 backtrackClassDef; /* Offset to glyph ClassDef table
721 * containing backtrack sequence
722 * data--from beginning of table */
724 inputClassDef; /* Offset to glyph ClassDef
725 * table containing input sequence
726 * data--from beginning of table */
728 lookaheadClassDef; /* Offset to glyph ClassDef table
729 * containing lookahead sequence
730 * data--from beginning of table */
731 OffsetArrayOf<ChainRuleSet>
732 ruleSet; /* Array of ChainRuleSet tables
733 * ordered by class */
735 ASSERT_SIZE (ChainContextFormat2, 12);
737 struct ChainContextFormat3
739 friend struct ChainContext;
743 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
746 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
748 unsigned int index = (this+input[0]) (IN_CURGLYPH ());
749 if (HB_LIKELY (index == NOT_COVERED))
752 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
753 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
754 struct ChainContextLookupContext lookup_context = {
755 {match_coverage, apply_func},
756 {CharP(this), CharP(this), CharP(this)}
758 return chain_context_lookup (APPLY_ARG,
759 backtrack.len, (const USHORT *) backtrack.array(),
760 input.len, (const USHORT *) input.array() + 1,
761 lookahead.len, (const USHORT *) lookahead.array(),
762 lookup.len, lookup.array(),
767 inline bool sanitize (SANITIZE_ARG_DEF) {
769 if (!SANITIZE_THIS (backtrack)) return false;
770 OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
771 if (!SANITIZE_THIS (input)) return false;
772 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
773 if (!SANITIZE_THIS (lookahead)) return false;
774 ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
775 return SANITIZE (lookup);
779 USHORT format; /* Format identifier--format = 3 */
780 OffsetArrayOf<Coverage>
781 backtrack; /* Array of coverage tables
782 * in backtracking sequence, in glyph
784 OffsetArrayOf<Coverage>
785 inputX ; /* Array of coverage
786 * tables in input sequence, in glyph
788 OffsetArrayOf<Coverage>
789 lookaheadX; /* Array of coverage tables
790 * in lookahead sequence, in glyph
792 ArrayOf<LookupRecord>
793 lookupX; /* Array of LookupRecords--in
796 ASSERT_SIZE (ChainContextFormat3, 10);
801 inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
805 case 1: return u.format1->apply (APPLY_ARG, apply_func);
806 case 2: return u.format2->apply (APPLY_ARG, apply_func);
807 case 3: return u.format3->apply (APPLY_ARG, apply_func);
808 default:return false;
812 inline bool sanitize (SANITIZE_ARG_DEF) {
814 if (!SANITIZE (u.format)) return false;
816 case 1: return u.format1->sanitize (SANITIZE_ARG);
817 case 2: return u.format2->sanitize (SANITIZE_ARG);
818 case 3: return u.format3->sanitize (SANITIZE_ARG);
825 USHORT format; /* Format identifier */
826 ChainContextFormat1 format1[VAR];
827 ChainContextFormat2 format2[VAR];
828 ChainContextFormat3 format3[VAR];
833 struct ExtensionFormat1
835 friend struct Extension;
838 inline unsigned int get_type (void) const { return extensionLookupType; }
839 inline const LookupSubTable& get_subtable (void) const
841 unsigned int offset = extensionOffset;
842 if (HB_UNLIKELY (!offset)) return Null(LookupSubTable);
843 return CONST_CAST (LookupSubTable, *this, offset);
846 inline bool sanitize (SANITIZE_ARG_DEF) {
848 return SANITIZE_SELF ();
852 USHORT format; /* Format identifier. Set to 1. */
853 USHORT extensionLookupType; /* Lookup type of subtable referenced
854 * by ExtensionOffset (i.e. the
855 * extension subtable). */
856 ULONG extensionOffset; /* Offset to the extension subtable,
857 * of lookup type subtable. */
859 ASSERT_SIZE (ExtensionFormat1, 8);
863 inline unsigned int get_type (void) const
866 case 1: return u.format1->get_type ();
870 inline const LookupSubTable& get_subtable (void) const
873 case 1: return u.format1->get_subtable ();
874 default:return Null(LookupSubTable);
878 inline bool sanitize (SANITIZE_ARG_DEF) {
880 if (!SANITIZE (u.format)) return false;
882 case 1: return u.format1->sanitize (SANITIZE_ARG);
889 USHORT format; /* Format identifier */
890 ExtensionFormat1 format1[VAR];
901 static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
902 static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
904 STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1, 1);
906 inline unsigned int get_script_count (void) const
907 { return (this+scriptList).len; }
908 inline const Tag& get_script_tag (unsigned int i) const
909 { return (this+scriptList).get_tag (i); }
910 inline unsigned int get_script_tags (unsigned int start_offset,
911 unsigned int *script_count /* IN/OUT */,
912 hb_tag_t *script_tags /* OUT */) const
913 { return (this+scriptList).get_tags (start_offset, script_count, script_tags); }
914 inline const Script& get_script (unsigned int i) const
915 { return (this+scriptList)[i]; }
916 inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
917 { return (this+scriptList).find_index (tag, index); }
919 inline unsigned int get_feature_count (void) const
920 { return (this+featureList).len; }
921 inline const Tag& get_feature_tag (unsigned int i) const
922 { return (this+featureList).get_tag (i); }
923 inline unsigned int get_feature_tags (unsigned int start_offset,
924 unsigned int *feature_count /* IN/OUT */,
925 hb_tag_t *feature_tags /* OUT */) const
926 { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); }
927 inline const Feature& get_feature (unsigned int i) const
928 { return (this+featureList)[i]; }
929 inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
930 { return (this+featureList).find_index (tag, index); }
932 inline unsigned int get_lookup_count (void) const
933 { return (this+lookupList).len; }
934 inline const Lookup& get_lookup (unsigned int i) const
935 { return (this+lookupList)[i]; }
937 inline bool sanitize (SANITIZE_ARG_DEF) {
939 if (!SANITIZE (version)) return false;
940 if (version.major != 1) return true;
941 return SANITIZE_THIS3 (scriptList, featureList, lookupList);
945 FixedVersion version; /* Version of the GSUB/GPOS table--initially set
948 scriptList; /* ScriptList table */
949 OffsetTo<FeatureList>
950 featureList; /* FeatureList table */
952 lookupList; /* LookupList table */
954 ASSERT_SIZE (GSUBGPOS, 10);
957 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */