| 1 | /* | 
|---|
| 2 | * Copyright © 2007,2008,2009,2010  Red Hat, Inc. | 
|---|
| 3 | * Copyright © 2010,2012,2013  Google, Inc. | 
|---|
| 4 | * | 
|---|
| 5 | *  This is part of HarfBuzz, a text shaping library. | 
|---|
| 6 | * | 
|---|
| 7 | * Permission is hereby granted, without written agreement and without | 
|---|
| 8 | * license or royalty fees, to use, copy, modify, and distribute this | 
|---|
| 9 | * software and its documentation for any purpose, provided that the | 
|---|
| 10 | * above copyright notice and the following two paragraphs appear in | 
|---|
| 11 | * all copies of this software. | 
|---|
| 12 | * | 
|---|
| 13 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 
|---|
| 14 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES | 
|---|
| 15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN | 
|---|
| 16 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | 
|---|
| 17 | * DAMAGE. | 
|---|
| 18 | * | 
|---|
| 19 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, | 
|---|
| 20 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | 
|---|
| 21 | * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS | 
|---|
| 22 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO | 
|---|
| 23 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 
|---|
| 24 | * | 
|---|
| 25 | * Red Hat Author(s): Behdad Esfahbod | 
|---|
| 26 | * Google Author(s): Behdad Esfahbod | 
|---|
| 27 | */ | 
|---|
| 28 |  | 
|---|
| 29 | #ifndef HB_OT_LAYOUT_GSUB_TABLE_HH | 
|---|
| 30 | #define HB_OT_LAYOUT_GSUB_TABLE_HH | 
|---|
| 31 |  | 
|---|
| 32 | #include "OT/Layout/GSUB/GSUB.hh" | 
|---|
| 33 |  | 
|---|
| 34 | namespace OT { | 
|---|
| 35 | namespace Layout { | 
|---|
| 36 | namespace GSUB_impl { | 
|---|
| 37 |  | 
|---|
| 38 | // TODO(garretrieger): Move into the new layout directory. | 
|---|
| 39 | /* Out-of-class implementation for methods recursing */ | 
|---|
| 40 |  | 
|---|
| 41 | #ifndef HB_NO_OT_LAYOUT | 
|---|
| 42 | /*static*/ inline bool ExtensionSubst::is_reverse () const | 
|---|
| 43 | { | 
|---|
| 44 | return SubstLookup::lookup_type_is_reverse (get_type ()); | 
|---|
| 45 | } | 
|---|
| 46 | template <typename context_t> | 
|---|
| 47 | /*static*/ typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) | 
|---|
| 48 | { | 
|---|
| 49 | const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index); | 
|---|
| 50 | return l.dispatch (c); | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | /*static*/ typename hb_closure_context_t::return_t SubstLookup::closure_glyphs_recurse_func (hb_closure_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indices, unsigned seq_index, unsigned end_index) | 
|---|
| 54 | { | 
|---|
| 55 | const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index); | 
|---|
| 56 | if (l.may_have_non_1to1 ()) | 
|---|
| 57 | hb_set_add_range (covered_seq_indices, seq_index, end_index); | 
|---|
| 58 | return l.dispatch (c); | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | template <> | 
|---|
| 62 | inline hb_closure_lookups_context_t::return_t | 
|---|
| 63 | SubstLookup::dispatch_recurse_func<hb_closure_lookups_context_t> (hb_closure_lookups_context_t *c, unsigned this_index) | 
|---|
| 64 | { | 
|---|
| 65 | const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (this_index); | 
|---|
| 66 | return l.closure_lookups (c, this_index); | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | template <> | 
|---|
| 70 | inline bool SubstLookup::dispatch_recurse_func<hb_ot_apply_context_t> (hb_ot_apply_context_t *c, unsigned int lookup_index) | 
|---|
| 71 | { | 
|---|
| 72 | auto *gsub = c->face->table.GSUB.get_relaxed (); | 
|---|
| 73 | const SubstLookup &l = gsub->table->get_lookup (lookup_index); | 
|---|
| 74 | unsigned int saved_lookup_props = c->lookup_props; | 
|---|
| 75 | unsigned int saved_lookup_index = c->lookup_index; | 
|---|
| 76 | c->set_lookup_index (lookup_index); | 
|---|
| 77 | c->set_lookup_props (l.get_props ()); | 
|---|
| 78 |  | 
|---|
| 79 | bool ret = false; | 
|---|
| 80 | auto *accel = gsub->get_accel (lookup_index); | 
|---|
| 81 | ret = accel && accel->apply (c, l.get_subtable_count (), false); | 
|---|
| 82 |  | 
|---|
| 83 | c->set_lookup_index (saved_lookup_index); | 
|---|
| 84 | c->set_lookup_props (saved_lookup_props); | 
|---|
| 85 | return ret; | 
|---|
| 86 | } | 
|---|
| 87 | #endif | 
|---|
| 88 |  | 
|---|
| 89 | } /* namespace GSUB_impl */ | 
|---|
| 90 | } /* namespace Layout */ | 
|---|
| 91 | } /* namespace OT */ | 
|---|
| 92 |  | 
|---|
| 93 |  | 
|---|
| 94 | #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ | 
|---|
| 95 |  | 
|---|