Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
Behdad Esfahbod | 5b93e8d | 2012-04-23 22:26:13 -0400 | [diff] [blame] | 3 | * Copyright © 2010,2012 Google, Inc. |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 4 | * |
Behdad Esfahbod | c755cb3 | 2010-04-22 00:11:43 -0400 | [diff] [blame] | 5 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 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 |
Behdad Esfahbod | 98370e8 | 2010-10-27 17:39:01 -0400 | [diff] [blame] | 26 | * Google Author(s): Behdad Esfahbod |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 27 | */ |
| 28 | |
Behdad Esfahbod | 5f5b24f | 2009-08-02 20:03:12 -0400 | [diff] [blame] | 29 | #ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH |
| 30 | #define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 31 | |
Behdad Esfahbod | 22da7fd | 2010-05-12 18:23:21 -0400 | [diff] [blame] | 32 | #include "hb-buffer-private.hh" |
Behdad Esfahbod | 7a750ac | 2011-08-17 14:19:59 +0200 | [diff] [blame] | 33 | #include "hb-ot-layout-gdef-table.hh" |
Behdad Esfahbod | 1336ecd | 2012-08-01 21:46:36 -0400 | [diff] [blame] | 34 | #include "hb-set-private.hh" |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 35 | |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 36 | |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 37 | namespace OT { |
| 38 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 39 | |
Behdad Esfahbod | 902cc8a | 2012-11-23 15:06:59 -0500 | [diff] [blame] | 40 | |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 41 | #define TRACE_PROCESS(this) \ |
| 42 | hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \ |
| 43 | (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 44 | ""); |
| 45 | |
| 46 | |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 47 | #ifndef HB_DEBUG_CLOSURE |
| 48 | #define HB_DEBUG_CLOSURE (HB_DEBUG+0) |
| 49 | #endif |
| 50 | |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 51 | #define TRACE_CLOSURE(this) \ |
Behdad Esfahbod | 902cc8a | 2012-11-23 15:06:59 -0500 | [diff] [blame] | 52 | hb_auto_trace_t<HB_DEBUG_CLOSURE, void_t> trace \ |
| 53 | (&c->debug_depth, "CLOSURE", this, HB_FUNC, \ |
| 54 | ""); |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 55 | |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 56 | struct hb_closure_context_t |
| 57 | { |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 58 | inline const char *get_name (void) { return "CLOSURE"; } |
| 59 | static const unsigned int max_debug_depth = HB_DEBUG_CLOSURE; |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 60 | typedef void_t return_t; |
| 61 | typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index); |
| 62 | template <typename T> |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 63 | inline return_t process (const T &obj) { obj.closure (this); return VOID; } |
| 64 | static return_t default_return_value (void) { return VOID; } |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 65 | bool stop_sublookup_iteration (const return_t r) const { return false; } |
| 66 | return_t recurse (unsigned int lookup_index) |
| 67 | { |
| 68 | if (unlikely (nesting_level_left == 0)) |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 69 | return default_return_value (); |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 70 | |
| 71 | nesting_level_left--; |
| 72 | recurse_func (this, lookup_index); |
| 73 | nesting_level_left++; |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 74 | return default_return_value (); |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 75 | } |
| 76 | |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 77 | hb_face_t *face; |
Behdad Esfahbod | 6a9be5b | 2012-04-23 22:23:17 -0400 | [diff] [blame] | 78 | hb_set_t *glyphs; |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 79 | recurse_func_t recurse_func; |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 80 | unsigned int nesting_level_left; |
| 81 | unsigned int debug_depth; |
| 82 | |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 83 | hb_closure_context_t (hb_face_t *face_, |
Behdad Esfahbod | 6a9be5b | 2012-04-23 22:23:17 -0400 | [diff] [blame] | 84 | hb_set_t *glyphs_, |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 85 | recurse_func_t recurse_func_, |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 86 | unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) : |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 87 | face (face_), |
| 88 | glyphs (glyphs_), |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 89 | recurse_func (recurse_func_), |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 90 | nesting_level_left (nesting_level_left_), |
| 91 | debug_depth (0) {} |
| 92 | }; |
| 93 | |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 94 | |
| 95 | |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 96 | #ifndef HB_DEBUG_WOULD_APPLY |
| 97 | #define HB_DEBUG_WOULD_APPLY (HB_DEBUG+0) |
| 98 | #endif |
| 99 | |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 100 | #define TRACE_WOULD_APPLY(this) \ |
Behdad Esfahbod | 902cc8a | 2012-11-23 15:06:59 -0500 | [diff] [blame] | 101 | hb_auto_trace_t<HB_DEBUG_WOULD_APPLY, bool> trace \ |
| 102 | (&c->debug_depth, "WOULD_APPLY", this, HB_FUNC, \ |
| 103 | "%d glyphs", c->len); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 104 | |
| 105 | struct hb_would_apply_context_t |
| 106 | { |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 107 | inline const char *get_name (void) { return "WOULD_APPLY"; } |
| 108 | static const unsigned int max_debug_depth = HB_DEBUG_WOULD_APPLY; |
Behdad Esfahbod | 1d67ef9 | 2012-11-22 16:47:53 -0500 | [diff] [blame] | 109 | typedef bool return_t; |
| 110 | template <typename T> |
| 111 | inline return_t process (const T &obj) { return obj.would_apply (this); } |
| 112 | static return_t default_return_value (void) { return false; } |
| 113 | bool stop_sublookup_iteration (const return_t r) const { return r; } |
| 114 | return_t recurse (unsigned int lookup_index) { return true; } |
| 115 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 116 | hb_face_t *face; |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 117 | const hb_codepoint_t *glyphs; |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 118 | unsigned int len; |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 119 | bool zero_context; |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 120 | unsigned int debug_depth; |
| 121 | |
| 122 | hb_would_apply_context_t (hb_face_t *face_, |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 123 | const hb_codepoint_t *glyphs_, |
| 124 | unsigned int len_, |
Behdad Esfahbod | 2bd9fe3 | 2012-09-04 15:15:19 -0400 | [diff] [blame] | 125 | bool zero_context_) : |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 126 | face (face_), |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 127 | glyphs (glyphs_), |
| 128 | len (len_), |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 129 | zero_context (zero_context_), |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 130 | debug_depth (0) {} |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 134 | |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 135 | #ifndef HB_DEBUG_COLLECT_GLYPHS |
| 136 | #define HB_DEBUG_COLLECT_GLYPHS (HB_DEBUG+0) |
| 137 | #endif |
| 138 | |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 139 | #define TRACE_COLLECT_GLYPHS(this) \ |
Behdad Esfahbod | 902cc8a | 2012-11-23 15:06:59 -0500 | [diff] [blame] | 140 | hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS, void_t> trace \ |
| 141 | (&c->debug_depth, "COLLECT_GLYPHS", this, HB_FUNC, \ |
| 142 | ""); |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 143 | |
| 144 | struct hb_collect_glyphs_context_t |
| 145 | { |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 146 | inline const char *get_name (void) { return "COLLECT_GLYPHS"; } |
| 147 | static const unsigned int max_debug_depth = HB_DEBUG_COLLECT_GLYPHS; |
Behdad Esfahbod | 1d67ef9 | 2012-11-22 16:47:53 -0500 | [diff] [blame] | 148 | typedef void_t return_t; |
| 149 | template <typename T> |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 150 | inline return_t process (const T &obj) { obj.collect_glyphs (this); return VOID; } |
| 151 | static return_t default_return_value (void) { return VOID; } |
Behdad Esfahbod | 1d67ef9 | 2012-11-22 16:47:53 -0500 | [diff] [blame] | 152 | bool stop_iteration (const return_t r) const { return false; } |
| 153 | return_t recurse (unsigned int lookup_index) |
| 154 | { |
| 155 | #if 0 |
| 156 | /* XXX */ |
| 157 | #endif |
| 158 | return default_return_value (); |
| 159 | } |
| 160 | |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 161 | hb_face_t *face; |
| 162 | hb_set_t &before; |
| 163 | hb_set_t &input; |
| 164 | hb_set_t &after; |
| 165 | hb_set_t &output; |
| 166 | unsigned int debug_depth; |
| 167 | |
| 168 | hb_collect_glyphs_context_t (hb_face_t *face_, |
| 169 | hb_set_t *glyphs_before, /* OUT. May be NULL */ |
| 170 | hb_set_t *glyphs_input, /* OUT. May be NULL */ |
| 171 | hb_set_t *glyphs_after, /* OUT. May be NULL */ |
| 172 | hb_set_t *glyphs_output /* OUT. May be NULL */) : |
| 173 | face (face_), |
| 174 | before (glyphs_before ? *glyphs_before : *hb_set_get_empty ()), |
| 175 | input (glyphs_input ? *glyphs_input : *hb_set_get_empty ()), |
| 176 | after (glyphs_after ? *glyphs_after : *hb_set_get_empty ()), |
| 177 | output (glyphs_output ? *glyphs_output : *hb_set_get_empty ()), |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 178 | debug_depth (0) {} |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | |
| 182 | |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 183 | struct hb_get_coverage_context_t |
| 184 | { |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 185 | inline const char *get_name (void) { return "GET_COVERAGE"; } |
| 186 | static const unsigned int max_debug_depth = 0; |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 187 | typedef const Coverage &return_t; |
| 188 | template <typename T> |
| 189 | inline return_t process (const T &obj) { return obj.get_coverage (); } |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 190 | static return_t default_return_value (void) { return Null(Coverage); } |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 191 | bool stop_sublookup_iteration (const return_t r) const { return true; /* Unused */ } |
| 192 | return_t recurse (unsigned int lookup_index) |
| 193 | { return default_return_value (); } |
Behdad Esfahbod | 1d67ef9 | 2012-11-22 16:47:53 -0500 | [diff] [blame] | 194 | |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 195 | hb_get_coverage_context_t (void) : |
| 196 | debug_depth (0) {} |
| 197 | |
| 198 | unsigned int debug_depth; |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 199 | }; |
| 200 | |
| 201 | |
| 202 | |
Behdad Esfahbod | 0535b50 | 2009-08-28 17:14:33 -0400 | [diff] [blame] | 203 | #ifndef HB_DEBUG_APPLY |
Behdad Esfahbod | 11e3ec4 | 2010-11-03 15:11:04 -0400 | [diff] [blame] | 204 | #define HB_DEBUG_APPLY (HB_DEBUG+0) |
Behdad Esfahbod | 0535b50 | 2009-08-28 17:14:33 -0400 | [diff] [blame] | 205 | #endif |
| 206 | |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 207 | #define TRACE_APPLY(this) \ |
Behdad Esfahbod | 902cc8a | 2012-11-23 15:06:59 -0500 | [diff] [blame] | 208 | hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \ |
| 209 | (&c->debug_depth, "APPLY", this, HB_FUNC, \ |
| 210 | "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint); |
Behdad Esfahbod | 0535b50 | 2009-08-28 17:14:33 -0400 | [diff] [blame] | 211 | |
Behdad Esfahbod | 1376fb7 | 2010-04-29 02:19:21 -0400 | [diff] [blame] | 212 | struct hb_apply_context_t |
| 213 | { |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 214 | inline const char *get_name (void) { return "APPLY"; } |
| 215 | static const unsigned int max_debug_depth = HB_DEBUG_APPLY; |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 216 | typedef bool return_t; |
| 217 | typedef return_t (*recurse_func_t) (hb_apply_context_t *c, unsigned int lookup_index); |
| 218 | template <typename T> |
| 219 | inline return_t process (const T &obj) { return obj.apply (this); } |
Behdad Esfahbod | dabe698 | 2012-11-23 14:21:35 -0500 | [diff] [blame] | 220 | static return_t default_return_value (void) { return false; } |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 221 | bool stop_sublookup_iteration (const return_t r) const { return r; } |
| 222 | return_t recurse (unsigned int lookup_index) |
| 223 | { |
| 224 | if (unlikely (nesting_level_left == 0 || !recurse_func)) |
| 225 | return default_return_value (); |
| 226 | |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 227 | /* TODO Reuse context. */ |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 228 | hb_apply_context_t new_c (*this); |
| 229 | new_c.nesting_level_left--; |
| 230 | return recurse_func (&new_c, lookup_index); |
| 231 | } |
| 232 | |
Behdad Esfahbod | abcfe9b | 2011-05-11 00:02:02 -0400 | [diff] [blame] | 233 | hb_font_t *font; |
| 234 | hb_face_t *face; |
Behdad Esfahbod | 94a23aa | 2010-05-05 01:13:09 -0400 | [diff] [blame] | 235 | hb_buffer_t *buffer; |
Behdad Esfahbod | 744970a | 2011-05-16 18:15:37 -0400 | [diff] [blame] | 236 | hb_direction_t direction; |
Behdad Esfahbod | f7acd8d | 2010-05-20 17:26:35 +0100 | [diff] [blame] | 237 | hb_mask_t lookup_mask; |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 238 | recurse_func_t recurse_func; |
Behdad Esfahbod | 1376fb7 | 2010-04-29 02:19:21 -0400 | [diff] [blame] | 239 | unsigned int nesting_level_left; |
Behdad Esfahbod | 8c69e65 | 2010-10-27 22:07:49 -0400 | [diff] [blame] | 240 | unsigned int lookup_props; |
Behdad Esfahbod | 98370e8 | 2010-10-27 17:39:01 -0400 | [diff] [blame] | 241 | unsigned int property; /* propety of first glyph */ |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 242 | const GDEF &gdef; |
Behdad Esfahbod | 300c730 | 2012-07-30 19:37:44 -0400 | [diff] [blame] | 243 | bool has_glyph_classes; |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 244 | unsigned int debug_depth; |
Behdad Esfahbod | 98370e8 | 2010-10-27 17:39:01 -0400 | [diff] [blame] | 245 | |
Behdad Esfahbod | 41ae674 | 2012-04-11 17:11:05 -0400 | [diff] [blame] | 246 | |
| 247 | hb_apply_context_t (hb_font_t *font_, |
Behdad Esfahbod | 41ae674 | 2012-04-11 17:11:05 -0400 | [diff] [blame] | 248 | hb_buffer_t *buffer_, |
Behdad Esfahbod | 2bd9fe3 | 2012-09-04 15:15:19 -0400 | [diff] [blame] | 249 | hb_mask_t lookup_mask_) : |
Behdad Esfahbod | afbcc24 | 2012-08-02 08:36:40 -0400 | [diff] [blame] | 250 | font (font_), face (font->face), buffer (buffer_), |
Behdad Esfahbod | 41ae674 | 2012-04-11 17:11:05 -0400 | [diff] [blame] | 251 | direction (buffer_->props.direction), |
| 252 | lookup_mask (lookup_mask_), |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 253 | recurse_func (NULL), |
Behdad Esfahbod | 6736f3c | 2012-05-13 15:21:06 +0200 | [diff] [blame] | 254 | nesting_level_left (MAX_NESTING_LEVEL), |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 255 | lookup_props (0), property (0), |
Behdad Esfahbod | afbcc24 | 2012-08-02 08:36:40 -0400 | [diff] [blame] | 256 | gdef (*hb_ot_layout_from_face (face)->gdef), |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 257 | has_glyph_classes (gdef.has_glyph_classes ()), |
| 258 | debug_depth (0) {} |
Behdad Esfahbod | 41ae674 | 2012-04-11 17:11:05 -0400 | [diff] [blame] | 259 | |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 260 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
| 261 | void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; } |
| 262 | void set_lookup (const Lookup &l) { lookup_props = l.get_props (); } |
Behdad Esfahbod | 41ae674 | 2012-04-11 17:11:05 -0400 | [diff] [blame] | 263 | |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 264 | struct mark_skipping_forward_iterator_t |
| 265 | { |
| 266 | inline mark_skipping_forward_iterator_t (hb_apply_context_t *c_, |
| 267 | unsigned int start_index_, |
Behdad Esfahbod | 203d710 | 2012-05-11 16:01:44 +0200 | [diff] [blame] | 268 | unsigned int num_items_, |
Behdad Esfahbod | 28b9d50 | 2012-05-13 15:04:00 +0200 | [diff] [blame] | 269 | bool context_match = false) |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 270 | { |
| 271 | c = c_; |
| 272 | idx = start_index_; |
| 273 | num_items = num_items_; |
Behdad Esfahbod | 28b9d50 | 2012-05-13 15:04:00 +0200 | [diff] [blame] | 274 | mask = context_match ? -1 : c->lookup_mask; |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 275 | syllable = context_match ? 0 : c->buffer->cur().syllable (); |
Behdad Esfahbod | 5df809b | 2012-05-13 15:17:51 +0200 | [diff] [blame] | 276 | end = c->buffer->len; |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 277 | } |
| 278 | inline bool has_no_chance (void) const |
| 279 | { |
| 280 | return unlikely (num_items && idx + num_items >= end); |
| 281 | } |
Behdad Esfahbod | b12e254 | 2012-06-09 03:05:20 -0400 | [diff] [blame] | 282 | inline void reject (void) |
Behdad Esfahbod | 7b84c53 | 2012-06-08 22:04:23 -0400 | [diff] [blame] | 283 | { |
| 284 | num_items++; |
| 285 | } |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 286 | inline bool next (unsigned int *property_out, |
Behdad Esfahbod | 8932858 | 2012-07-19 21:02:38 -0400 | [diff] [blame] | 287 | unsigned int lookup_props) |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 288 | { |
Behdad Esfahbod | 506ffeb | 2012-01-18 16:07:53 -0500 | [diff] [blame] | 289 | assert (num_items > 0); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 290 | do |
| 291 | { |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 292 | if (has_no_chance ()) |
| 293 | return false; |
Behdad Esfahbod | a4a48fe | 2012-01-17 18:08:41 -0500 | [diff] [blame] | 294 | idx++; |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 295 | } while (c->should_skip_mark (&c->buffer->info[idx], lookup_props, property_out)); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 296 | num_items--; |
Behdad Esfahbod | 5f131d3 | 2012-05-11 17:29:40 +0200 | [diff] [blame] | 297 | return (c->buffer->info[idx].mask & mask) && (!syllable || syllable == c->buffer->info[idx].syllable ()); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 298 | } |
| 299 | inline bool next (unsigned int *property_out = NULL) |
| 300 | { |
| 301 | return next (property_out, c->lookup_props); |
| 302 | } |
| 303 | |
| 304 | unsigned int idx; |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 305 | protected: |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 306 | hb_apply_context_t *c; |
| 307 | unsigned int num_items; |
Behdad Esfahbod | 203d710 | 2012-05-11 16:01:44 +0200 | [diff] [blame] | 308 | hb_mask_t mask; |
Behdad Esfahbod | 5f131d3 | 2012-05-11 17:29:40 +0200 | [diff] [blame] | 309 | uint8_t syllable; |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 310 | unsigned int end; |
| 311 | }; |
| 312 | |
| 313 | struct mark_skipping_backward_iterator_t |
| 314 | { |
| 315 | inline mark_skipping_backward_iterator_t (hb_apply_context_t *c_, |
| 316 | unsigned int start_index_, |
Behdad Esfahbod | 203d710 | 2012-05-11 16:01:44 +0200 | [diff] [blame] | 317 | unsigned int num_items_, |
Behdad Esfahbod | 5f131d3 | 2012-05-11 17:29:40 +0200 | [diff] [blame] | 318 | hb_mask_t mask_ = 0, |
Behdad Esfahbod | 6736f3c | 2012-05-13 15:21:06 +0200 | [diff] [blame] | 319 | bool match_syllable_ = true) |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 320 | { |
| 321 | c = c_; |
| 322 | idx = start_index_; |
| 323 | num_items = num_items_; |
Behdad Esfahbod | 203d710 | 2012-05-11 16:01:44 +0200 | [diff] [blame] | 324 | mask = mask_ ? mask_ : c->lookup_mask; |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 325 | syllable = match_syllable_ ? c->buffer->cur().syllable () : 0; |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 326 | } |
| 327 | inline bool has_no_chance (void) const |
| 328 | { |
Behdad Esfahbod | 506ffeb | 2012-01-18 16:07:53 -0500 | [diff] [blame] | 329 | return unlikely (idx < num_items); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 330 | } |
Behdad Esfahbod | b12e254 | 2012-06-09 03:05:20 -0400 | [diff] [blame] | 331 | inline void reject (void) |
Behdad Esfahbod | 7b84c53 | 2012-06-08 22:04:23 -0400 | [diff] [blame] | 332 | { |
| 333 | num_items++; |
| 334 | } |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 335 | inline bool prev (unsigned int *property_out, |
Behdad Esfahbod | 8932858 | 2012-07-19 21:02:38 -0400 | [diff] [blame] | 336 | unsigned int lookup_props) |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 337 | { |
Behdad Esfahbod | 506ffeb | 2012-01-18 16:07:53 -0500 | [diff] [blame] | 338 | assert (num_items > 0); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 339 | do |
| 340 | { |
| 341 | if (has_no_chance ()) |
| 342 | return false; |
| 343 | idx--; |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 344 | } while (c->should_skip_mark (&c->buffer->out_info[idx], lookup_props, property_out)); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 345 | num_items--; |
Behdad Esfahbod | 5f131d3 | 2012-05-11 17:29:40 +0200 | [diff] [blame] | 346 | return (c->buffer->out_info[idx].mask & mask) && (!syllable || syllable == c->buffer->out_info[idx].syllable ()); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 347 | } |
| 348 | inline bool prev (unsigned int *property_out = NULL) |
| 349 | { |
| 350 | return prev (property_out, c->lookup_props); |
| 351 | } |
| 352 | |
| 353 | unsigned int idx; |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 354 | protected: |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 355 | hb_apply_context_t *c; |
| 356 | unsigned int num_items; |
Behdad Esfahbod | 203d710 | 2012-05-11 16:01:44 +0200 | [diff] [blame] | 357 | hb_mask_t mask; |
Behdad Esfahbod | 5f131d3 | 2012-05-11 17:29:40 +0200 | [diff] [blame] | 358 | uint8_t syllable; |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 359 | }; |
| 360 | |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 361 | inline bool |
| 362 | match_properties_mark (hb_codepoint_t glyph, |
| 363 | unsigned int glyph_props, |
| 364 | unsigned int lookup_props) const |
| 365 | { |
| 366 | /* If using mark filtering sets, the high short of |
| 367 | * lookup_props has the set index. |
| 368 | */ |
| 369 | if (lookup_props & LookupFlag::UseMarkFilteringSet) |
| 370 | return gdef.mark_set_covers (lookup_props >> 16, glyph); |
| 371 | |
| 372 | /* The second byte of lookup_props has the meaning |
| 373 | * "ignore marks of attachment type different than |
| 374 | * the attachment type specified." |
| 375 | */ |
| 376 | if (lookup_props & LookupFlag::MarkAttachmentType) |
| 377 | return (lookup_props & LookupFlag::MarkAttachmentType) == (glyph_props & LookupFlag::MarkAttachmentType); |
| 378 | |
| 379 | return true; |
| 380 | } |
| 381 | |
| 382 | inline bool |
| 383 | match_properties (hb_codepoint_t glyph, |
| 384 | unsigned int glyph_props, |
| 385 | unsigned int lookup_props) const |
| 386 | { |
| 387 | /* Not covered, if, for example, glyph class is ligature and |
| 388 | * lookup_props includes LookupFlags::IgnoreLigatures |
| 389 | */ |
| 390 | if (glyph_props & lookup_props & LookupFlag::IgnoreFlags) |
| 391 | return false; |
| 392 | |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 393 | if (unlikely (glyph_props & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 394 | return match_properties_mark (glyph, glyph_props, lookup_props); |
| 395 | |
| 396 | return true; |
| 397 | } |
| 398 | |
| 399 | inline bool |
| 400 | check_glyph_property (hb_glyph_info_t *info, |
| 401 | unsigned int lookup_props, |
| 402 | unsigned int *property_out) const |
Behdad Esfahbod | 7d47990 | 2012-01-18 21:19:32 -0500 | [diff] [blame] | 403 | { |
Behdad Esfahbod | ce47613 | 2012-06-09 01:10:26 -0400 | [diff] [blame] | 404 | unsigned int property; |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 405 | |
Behdad Esfahbod | c2e42c3 | 2012-07-30 19:54:50 -0400 | [diff] [blame] | 406 | property = info->glyph_props(); |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 407 | *property_out = property; |
| 408 | |
| 409 | return match_properties (info->codepoint, property, lookup_props); |
| 410 | } |
| 411 | |
| 412 | inline bool |
| 413 | should_skip_mark (hb_glyph_info_t *info, |
| 414 | unsigned int lookup_props, |
| 415 | unsigned int *property_out) const |
| 416 | { |
| 417 | unsigned int property; |
| 418 | |
Behdad Esfahbod | c2e42c3 | 2012-07-30 19:54:50 -0400 | [diff] [blame] | 419 | property = info->glyph_props(); |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 420 | if (property_out) |
| 421 | *property_out = property; |
| 422 | |
| 423 | /* If it's a mark, skip it if we don't accept it. */ |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 424 | if (unlikely (property & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) |
Behdad Esfahbod | 03f67bc | 2012-07-30 19:47:53 -0400 | [diff] [blame] | 425 | return !match_properties (info->codepoint, property, lookup_props); |
| 426 | |
| 427 | /* If not a mark, don't skip. */ |
| 428 | return false; |
| 429 | } |
| 430 | |
| 431 | |
| 432 | inline bool should_mark_skip_current_glyph (void) const |
| 433 | { |
| 434 | return should_skip_mark (&buffer->cur(), lookup_props, NULL); |
Behdad Esfahbod | 7d47990 | 2012-01-18 21:19:32 -0500 | [diff] [blame] | 435 | } |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 436 | |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 437 | inline void set_class (hb_codepoint_t glyph_index, unsigned int class_guess) const |
Behdad Esfahbod | 60da763 | 2012-07-16 16:13:32 -0400 | [diff] [blame] | 438 | { |
Behdad Esfahbod | 2fca142 | 2012-07-30 18:46:41 -0400 | [diff] [blame] | 439 | if (likely (has_glyph_classes)) |
Behdad Esfahbod | c2e42c3 | 2012-07-30 19:54:50 -0400 | [diff] [blame] | 440 | buffer->cur().glyph_props() = gdef.get_glyph_props (glyph_index); |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 441 | else if (class_guess) |
Behdad Esfahbod | c2e42c3 | 2012-07-30 19:54:50 -0400 | [diff] [blame] | 442 | buffer->cur().glyph_props() = class_guess; |
Behdad Esfahbod | 60da763 | 2012-07-16 16:13:32 -0400 | [diff] [blame] | 443 | } |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 444 | |
Behdad Esfahbod | 3ec77d6 | 2012-06-08 21:44:06 -0400 | [diff] [blame] | 445 | inline void output_glyph (hb_codepoint_t glyph_index, |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 446 | unsigned int class_guess = 0) const |
Behdad Esfahbod | 3ec77d6 | 2012-06-08 21:44:06 -0400 | [diff] [blame] | 447 | { |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 448 | set_class (glyph_index, class_guess); |
Behdad Esfahbod | 3ec77d6 | 2012-06-08 21:44:06 -0400 | [diff] [blame] | 449 | buffer->output_glyph (glyph_index); |
| 450 | } |
Behdad Esfahbod | ed2f136 | 2012-05-22 22:12:22 -0400 | [diff] [blame] | 451 | inline void replace_glyph (hb_codepoint_t glyph_index, |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 452 | unsigned int class_guess = 0) const |
Behdad Esfahbod | 98370e8 | 2010-10-27 17:39:01 -0400 | [diff] [blame] | 453 | { |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 454 | set_class (glyph_index, class_guess); |
Behdad Esfahbod | 98370e8 | 2010-10-27 17:39:01 -0400 | [diff] [blame] | 455 | buffer->replace_glyph (glyph_index); |
| 456 | } |
Behdad Esfahbod | 7fbbf86 | 2012-07-30 18:36:42 -0400 | [diff] [blame] | 457 | inline void replace_glyph_inplace (hb_codepoint_t glyph_index, |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 458 | unsigned int class_guess = 0) const |
Behdad Esfahbod | 7fbbf86 | 2012-07-30 18:36:42 -0400 | [diff] [blame] | 459 | { |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 460 | set_class (glyph_index, class_guess); |
Behdad Esfahbod | 7fbbf86 | 2012-07-30 18:36:42 -0400 | [diff] [blame] | 461 | buffer->cur().codepoint = glyph_index; |
| 462 | } |
Behdad Esfahbod | 1376fb7 | 2010-04-29 02:19:21 -0400 | [diff] [blame] | 463 | }; |
| 464 | |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 465 | |
Behdad Esfahbod | 94a23aa | 2010-05-05 01:13:09 -0400 | [diff] [blame] | 466 | |
Behdad Esfahbod | 6a9be5b | 2012-04-23 22:23:17 -0400 | [diff] [blame] | 467 | typedef bool (*intersects_func_t) (hb_set_t *glyphs, const USHORT &value, const void *data); |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 468 | typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const void *data); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 469 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 470 | struct ContextClosureFuncs |
| 471 | { |
| 472 | intersects_func_t intersects; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 473 | }; |
| 474 | struct ContextApplyFuncs |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 475 | { |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 476 | match_func_t match; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 477 | }; |
| 478 | |
Behdad Esfahbod | 6a9be5b | 2012-04-23 22:23:17 -0400 | [diff] [blame] | 479 | static inline bool intersects_glyph (hb_set_t *glyphs, const USHORT &value, const void *data HB_UNUSED) |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 480 | { |
| 481 | return glyphs->has (value); |
| 482 | } |
Behdad Esfahbod | 6a9be5b | 2012-04-23 22:23:17 -0400 | [diff] [blame] | 483 | static inline bool intersects_class (hb_set_t *glyphs, const USHORT &value, const void *data) |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 484 | { |
| 485 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
| 486 | return class_def.intersects_class (glyphs, value); |
| 487 | } |
Behdad Esfahbod | 6a9be5b | 2012-04-23 22:23:17 -0400 | [diff] [blame] | 488 | static inline bool intersects_coverage (hb_set_t *glyphs, const USHORT &value, const void *data) |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 489 | { |
| 490 | const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value; |
| 491 | return (data+coverage).intersects (glyphs); |
| 492 | } |
| 493 | |
| 494 | static inline bool intersects_array (hb_closure_context_t *c, |
| 495 | unsigned int count, |
| 496 | const USHORT values[], |
| 497 | intersects_func_t intersects_func, |
| 498 | const void *intersects_data) |
| 499 | { |
| 500 | for (unsigned int i = 0; i < count; i++) |
| 501 | if (likely (!intersects_func (c->glyphs, values[i], intersects_data))) |
| 502 | return false; |
| 503 | return true; |
| 504 | } |
| 505 | |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 506 | |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 507 | static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 508 | { |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 509 | return glyph_id == value; |
| 510 | } |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 511 | static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const void *data) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 512 | { |
Behdad Esfahbod | 2b5a59c | 2009-08-04 11:38:50 -0400 | [diff] [blame] | 513 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 514 | return class_def.get_class (glyph_id) == value; |
| 515 | } |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 516 | static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const void *data) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 517 | { |
Behdad Esfahbod | 6b54c5d | 2009-05-18 18:30:25 -0400 | [diff] [blame] | 518 | const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 519 | return (data+coverage).get_coverage (glyph_id) != NOT_COVERED; |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 520 | } |
| 521 | |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 522 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 523 | static inline bool would_match_input (hb_would_apply_context_t *c, |
| 524 | unsigned int count, /* Including the first glyph (not matched) */ |
| 525 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 526 | match_func_t match_func, |
| 527 | const void *match_data) |
| 528 | { |
| 529 | if (count != c->len) |
| 530 | return false; |
| 531 | |
| 532 | for (unsigned int i = 1; i < count; i++) |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 533 | if (likely (!match_func (c->glyphs[i], input[i - 1], match_data))) |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 534 | return false; |
| 535 | |
| 536 | return true; |
| 537 | } |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 538 | static inline bool match_input (hb_apply_context_t *c, |
Behdad Esfahbod | e072c24 | 2009-05-18 03:47:31 -0400 | [diff] [blame] | 539 | unsigned int count, /* Including the first glyph (not matched) */ |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 540 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 541 | match_func_t match_func, |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 542 | const void *match_data, |
Behdad Esfahbod | 191fa88 | 2012-08-28 22:58:55 -0400 | [diff] [blame] | 543 | unsigned int *end_offset = NULL, |
| 544 | bool *p_is_mark_ligature = NULL, |
| 545 | unsigned int *p_total_component_count = NULL) |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 546 | { |
Behdad Esfahbod | 73c18ae | 2012-11-23 15:34:11 -0500 | [diff] [blame] | 547 | TRACE_APPLY (NULL); |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 548 | |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 549 | hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1); |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 550 | if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false); |
| 551 | |
Behdad Esfahbod | 191fa88 | 2012-08-28 22:58:55 -0400 | [diff] [blame] | 552 | /* |
| 553 | * This is perhaps the trickiest part of OpenType... Remarks: |
| 554 | * |
| 555 | * - If all components of the ligature were marks, we call this a mark ligature. |
| 556 | * |
| 557 | * - If there is no GDEF, and the ligature is NOT a mark ligature, we categorize |
| 558 | * it as a ligature glyph. |
| 559 | * |
| 560 | * - Ligatures cannot be formed across glyphs attached to different components |
| 561 | * of previous ligatures. Eg. the sequence is LAM,SHADDA,LAM,FATHA,HEH, and |
| 562 | * LAM,LAM,HEH form a ligature, leaving SHADDA,FATHA next to eachother. |
| 563 | * However, it would be wrong to ligate that SHADDA,FATHA sequence.o |
| 564 | * There is an exception to this: If a ligature tries ligating with marks that |
| 565 | * belong to it itself, go ahead, assuming that the font designer knows what |
| 566 | * they are doing (otherwise it can break Indic stuff when a matra wants to |
| 567 | * ligate with a conjunct...) |
| 568 | */ |
| 569 | |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 570 | bool is_mark_ligature = !!(c->property & HB_OT_LAYOUT_GLYPH_PROPS_MARK); |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 571 | |
| 572 | unsigned int total_component_count = 0; |
| 573 | total_component_count += get_lig_num_comps (c->buffer->cur()); |
| 574 | |
| 575 | unsigned int first_lig_id = get_lig_id (c->buffer->cur()); |
| 576 | unsigned int first_lig_comp = get_lig_comp (c->buffer->cur()); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 577 | |
Behdad Esfahbod | 370f03e | 2012-01-16 17:03:55 -0500 | [diff] [blame] | 578 | for (unsigned int i = 1; i < count; i++) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 579 | { |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 580 | unsigned int property; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 581 | |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 582 | if (!skippy_iter.next (&property)) return TRACE_RETURN (false); |
| 583 | |
Behdad Esfahbod | 2616689 | 2012-10-29 21:51:56 -0700 | [diff] [blame] | 584 | if (likely (!match_func (c->buffer->info[skippy_iter.idx].codepoint, input[i - 1], match_data))) return TRACE_RETURN (false); |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 585 | |
| 586 | unsigned int this_lig_id = get_lig_id (c->buffer->info[skippy_iter.idx]); |
| 587 | unsigned int this_lig_comp = get_lig_comp (c->buffer->info[skippy_iter.idx]); |
| 588 | |
| 589 | if (first_lig_id && first_lig_comp) { |
| 590 | /* If first component was attached to a previous ligature component, |
| 591 | * all subsequent components should be attached to the same ligature |
| 592 | * component, otherwise we shouldn't ligate them. */ |
| 593 | if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp) |
| 594 | return TRACE_RETURN (false); |
| 595 | } else { |
| 596 | /* If first component was NOT attached to a previous ligature component, |
| 597 | * all subsequent components should also NOT be attached to any ligature |
| 598 | * component, unless they are attached to the first component itself! */ |
| 599 | if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id)) |
| 600 | return TRACE_RETURN (false); |
| 601 | } |
| 602 | |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 603 | is_mark_ligature = is_mark_ligature && (property & HB_OT_LAYOUT_GLYPH_PROPS_MARK); |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 604 | total_component_count += get_lig_num_comps (c->buffer->info[skippy_iter.idx]); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 605 | } |
| 606 | |
Behdad Esfahbod | 5df809b | 2012-05-13 15:17:51 +0200 | [diff] [blame] | 607 | if (end_offset) |
| 608 | *end_offset = skippy_iter.idx - c->buffer->idx + 1; |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 609 | |
Behdad Esfahbod | 191fa88 | 2012-08-28 22:58:55 -0400 | [diff] [blame] | 610 | if (p_is_mark_ligature) |
| 611 | *p_is_mark_ligature = is_mark_ligature; |
| 612 | |
| 613 | if (p_total_component_count) |
| 614 | *p_total_component_count = total_component_count; |
| 615 | |
Behdad Esfahbod | bc513ad | 2012-10-29 19:03:55 -0700 | [diff] [blame] | 616 | return TRACE_RETURN (true); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 617 | } |
Behdad Esfahbod | a177d02 | 2012-08-28 23:18:22 -0400 | [diff] [blame] | 618 | static inline void ligate_input (hb_apply_context_t *c, |
| 619 | unsigned int count, /* Including the first glyph (not matched) */ |
| 620 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 621 | hb_codepoint_t lig_glyph, |
| 622 | match_func_t match_func, |
| 623 | const void *match_data, |
Behdad Esfahbod | a177d02 | 2012-08-28 23:18:22 -0400 | [diff] [blame] | 624 | bool is_mark_ligature, |
| 625 | unsigned int total_component_count) |
| 626 | { |
| 627 | /* |
| 628 | * - If it *is* a mark ligature, we don't allocate a new ligature id, and leave |
| 629 | * the ligature to keep its old ligature id. This will allow it to attach to |
| 630 | * a base ligature in GPOS. Eg. if the sequence is: LAM,LAM,SHADDA,FATHA,HEH, |
| 631 | * and LAM,LAM,HEH for a ligature, they will leave SHADDA and FATHA wit a |
| 632 | * ligature id and component value of 2. Then if SHADDA,FATHA form a ligature |
| 633 | * later, we don't want them to lose their ligature id/component, otherwise |
| 634 | * GPOS will fail to correctly position the mark ligature on top of the |
| 635 | * LAM,LAM,HEH ligature. See: |
| 636 | * https://bugzilla.gnome.org/show_bug.cgi?id=676343 |
| 637 | * |
| 638 | * - If a ligature is formed of components that some of which are also ligatures |
| 639 | * themselves, and those ligature components had marks attached to *their* |
| 640 | * components, we have to attach the marks to the new ligature component |
| 641 | * positions! Now *that*'s tricky! And these marks may be following the |
| 642 | * last component of the whole sequence, so we should loop forward looking |
| 643 | * for them and update them. |
| 644 | * |
| 645 | * Eg. the sequence is LAM,LAM,SHADDA,FATHA,HEH, and the font first forms a |
| 646 | * 'calt' ligature of LAM,HEH, leaving the SHADDA and FATHA with a ligature |
| 647 | * id and component == 1. Now, during 'liga', the LAM and the LAM-HEH ligature |
| 648 | * form a LAM-LAM-HEH ligature. We need to reassign the SHADDA and FATHA to |
| 649 | * the new ligature with a component value of 2. |
| 650 | * |
| 651 | * This in fact happened to a font... See: |
| 652 | * https://bugzilla.gnome.org/show_bug.cgi?id=437633 |
| 653 | */ |
| 654 | |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 655 | unsigned int klass = is_mark_ligature ? 0 : HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE; |
Behdad Esfahbod | a177d02 | 2012-08-28 23:18:22 -0400 | [diff] [blame] | 656 | unsigned int lig_id = is_mark_ligature ? 0 : allocate_lig_id (c->buffer); |
| 657 | unsigned int last_lig_id = get_lig_id (c->buffer->cur()); |
| 658 | unsigned int last_num_components = get_lig_num_comps (c->buffer->cur()); |
| 659 | unsigned int components_so_far = last_num_components; |
| 660 | |
| 661 | if (!is_mark_ligature) |
| 662 | set_lig_props_for_ligature (c->buffer->cur(), lig_id, total_component_count); |
| 663 | c->replace_glyph (lig_glyph, klass); |
| 664 | |
| 665 | for (unsigned int i = 1; i < count; i++) |
| 666 | { |
| 667 | while (c->should_mark_skip_current_glyph ()) |
| 668 | { |
| 669 | if (!is_mark_ligature) { |
| 670 | unsigned int new_lig_comp = components_so_far - last_num_components + |
| 671 | MIN (MAX (get_lig_comp (c->buffer->cur()), 1u), last_num_components); |
| 672 | set_lig_props_for_mark (c->buffer->cur(), lig_id, new_lig_comp); |
| 673 | } |
| 674 | c->buffer->next_glyph (); |
| 675 | } |
| 676 | |
| 677 | last_lig_id = get_lig_id (c->buffer->cur()); |
| 678 | last_num_components = get_lig_num_comps (c->buffer->cur()); |
| 679 | components_so_far += last_num_components; |
| 680 | |
| 681 | /* Skip the base glyph */ |
| 682 | c->buffer->idx++; |
| 683 | } |
| 684 | |
| 685 | if (!is_mark_ligature && last_lig_id) { |
| 686 | /* Re-adjust components for any marks following. */ |
| 687 | for (unsigned int i = c->buffer->idx; i < c->buffer->len; i++) { |
| 688 | if (last_lig_id == get_lig_id (c->buffer->info[i])) { |
| 689 | unsigned int new_lig_comp = components_so_far - last_num_components + |
| 690 | MIN (MAX (get_lig_comp (c->buffer->info[i]), 1u), last_num_components); |
| 691 | set_lig_props_for_mark (c->buffer->info[i], lig_id, new_lig_comp); |
| 692 | } else |
| 693 | break; |
| 694 | } |
| 695 | } |
| 696 | } |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 697 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 698 | static inline bool match_backtrack (hb_apply_context_t *c, |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 699 | unsigned int count, |
| 700 | const USHORT backtrack[], |
| 701 | match_func_t match_func, |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 702 | const void *match_data) |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 703 | { |
Behdad Esfahbod | 73c18ae | 2012-11-23 15:34:11 -0500 | [diff] [blame] | 704 | TRACE_APPLY (NULL); |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 705 | |
Behdad Esfahbod | 28b9d50 | 2012-05-13 15:04:00 +0200 | [diff] [blame] | 706 | hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->backtrack_len (), count, true); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 707 | if (skippy_iter.has_no_chance ()) |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 708 | return TRACE_RETURN (false); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 709 | |
Behdad Esfahbod | 4d3aeb8 | 2012-01-16 16:43:26 -0500 | [diff] [blame] | 710 | for (unsigned int i = 0; i < count; i++) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 711 | { |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 712 | if (!skippy_iter.prev ()) |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 713 | return TRACE_RETURN (false); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 714 | |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 715 | if (likely (!match_func (c->buffer->out_info[skippy_iter.idx].codepoint, backtrack[i], match_data))) |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 716 | return TRACE_RETURN (false); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 717 | } |
| 718 | |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 719 | return TRACE_RETURN (true); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 720 | } |
| 721 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 722 | static inline bool match_lookahead (hb_apply_context_t *c, |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 723 | unsigned int count, |
| 724 | const USHORT lookahead[], |
| 725 | match_func_t match_func, |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 726 | const void *match_data, |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 727 | unsigned int offset) |
| 728 | { |
Behdad Esfahbod | 73c18ae | 2012-11-23 15:34:11 -0500 | [diff] [blame] | 729 | TRACE_APPLY (NULL); |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 730 | |
Behdad Esfahbod | 28b9d50 | 2012-05-13 15:04:00 +0200 | [diff] [blame] | 731 | hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx + offset - 1, count, true); |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 732 | if (skippy_iter.has_no_chance ()) |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 733 | return TRACE_RETURN (false); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 734 | |
Behdad Esfahbod | 370f03e | 2012-01-16 17:03:55 -0500 | [diff] [blame] | 735 | for (unsigned int i = 0; i < count; i++) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 736 | { |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 737 | if (!skippy_iter.next ()) |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 738 | return TRACE_RETURN (false); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 739 | |
Behdad Esfahbod | 4ab9731 | 2012-01-16 22:05:08 -0500 | [diff] [blame] | 740 | if (likely (!match_func (c->buffer->info[skippy_iter.idx].codepoint, lookahead[i], match_data))) |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 741 | return TRACE_RETURN (false); |
Behdad Esfahbod | d0ba055 | 2009-05-18 03:56:39 -0400 | [diff] [blame] | 742 | } |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 743 | |
Behdad Esfahbod | 93814ca | 2012-08-28 22:24:51 -0400 | [diff] [blame] | 744 | return TRACE_RETURN (true); |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 745 | } |
| 746 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 747 | |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 748 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 749 | struct LookupRecord |
| 750 | { |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 751 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 752 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 753 | return TRACE_RETURN (c->check_struct (this)); |
Behdad Esfahbod | cd3827e | 2009-08-04 02:09:34 -0400 | [diff] [blame] | 754 | } |
| 755 | |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 756 | USHORT sequenceIndex; /* Index into current glyph |
| 757 | * sequence--first glyph = 0 */ |
| 758 | USHORT lookupListIndex; /* Lookup to apply to that |
| 759 | * position--zero--based */ |
Behdad Esfahbod | 569da92 | 2010-05-10 16:38:32 -0400 | [diff] [blame] | 760 | public: |
| 761 | DEFINE_SIZE_STATIC (4); |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 762 | }; |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 763 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 764 | |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 765 | static inline void closure_lookup (hb_closure_context_t *c, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 766 | unsigned int lookupCount, |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 767 | const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */) |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 768 | { |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 769 | for (unsigned int i = 0; i < lookupCount; i++) |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 770 | c->recurse (lookupRecord->lookupListIndex); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 771 | } |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 772 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 773 | static inline bool apply_lookup (hb_apply_context_t *c, |
Behdad Esfahbod | e072c24 | 2009-05-18 03:47:31 -0400 | [diff] [blame] | 774 | unsigned int count, /* Including the first glyph */ |
| 775 | unsigned int lookupCount, |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 776 | const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */) |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 777 | { |
Behdad Esfahbod | 73c18ae | 2012-11-23 15:34:11 -0500 | [diff] [blame] | 778 | TRACE_APPLY (NULL); |
Behdad Esfahbod | 902cc8a | 2012-11-23 15:06:59 -0500 | [diff] [blame] | 779 | |
Behdad Esfahbod | 5df809b | 2012-05-13 15:17:51 +0200 | [diff] [blame] | 780 | unsigned int end = c->buffer->len; |
Behdad Esfahbod | 468e9cb | 2011-07-22 11:28:07 -0400 | [diff] [blame] | 781 | if (unlikely (count == 0 || c->buffer->idx + count > end)) |
Behdad Esfahbod | 2616689 | 2012-10-29 21:51:56 -0700 | [diff] [blame] | 782 | return TRACE_RETURN (false); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 783 | |
Behdad Esfahbod | 7cff75b | 2009-05-18 04:09:05 -0400 | [diff] [blame] | 784 | /* TODO We don't support lookupRecord arrays that are not increasing: |
| 785 | * Should be easy for in_place ones at least. */ |
Behdad Esfahbod | 52e9a71 | 2009-09-21 13:58:56 -0400 | [diff] [blame] | 786 | |
Behdad Esfahbod | 7eb8751 | 2010-12-13 14:13:35 -0500 | [diff] [blame] | 787 | /* Note: If sublookup is reverse, it will underflow after the first loop |
Behdad Esfahbod | 52e9a71 | 2009-09-21 13:58:56 -0400 | [diff] [blame] | 788 | * and we jump out of it. Not entirely disastrous. So we don't check |
| 789 | * for reverse lookup here. |
| 790 | */ |
Behdad Esfahbod | f9c0a2d | 2009-09-21 13:43:54 -0400 | [diff] [blame] | 791 | for (unsigned int i = 0; i < count; /* NOP */) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 792 | { |
Behdad Esfahbod | 03408ce | 2012-01-18 21:28:34 -0500 | [diff] [blame] | 793 | if (unlikely (c->buffer->idx == end)) |
Behdad Esfahbod | 2616689 | 2012-10-29 21:51:56 -0700 | [diff] [blame] | 794 | return TRACE_RETURN (true); |
Behdad Esfahbod | 7d47990 | 2012-01-18 21:19:32 -0500 | [diff] [blame] | 795 | while (c->should_mark_skip_current_glyph ()) |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 796 | { |
Behdad Esfahbod | e73a0c2 | 2009-05-18 04:15:25 -0400 | [diff] [blame] | 797 | /* No lookup applied for this index */ |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 798 | c->buffer->next_glyph (); |
Behdad Esfahbod | 03408ce | 2012-01-18 21:28:34 -0500 | [diff] [blame] | 799 | if (unlikely (c->buffer->idx == end)) |
Behdad Esfahbod | 2616689 | 2012-10-29 21:51:56 -0700 | [diff] [blame] | 800 | return TRACE_RETURN (true); |
Behdad Esfahbod | e73a0c2 | 2009-05-18 04:15:25 -0400 | [diff] [blame] | 801 | } |
| 802 | |
Behdad Esfahbod | 47958de | 2009-05-18 04:17:47 -0400 | [diff] [blame] | 803 | if (lookupCount && i == lookupRecord->sequenceIndex) |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 804 | { |
Behdad Esfahbod | 468e9cb | 2011-07-22 11:28:07 -0400 | [diff] [blame] | 805 | unsigned int old_pos = c->buffer->idx; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 806 | |
| 807 | /* Apply a lookup */ |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 808 | bool done = c->recurse (lookupRecord->lookupListIndex); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 809 | |
Behdad Esfahbod | 47958de | 2009-05-18 04:17:47 -0400 | [diff] [blame] | 810 | lookupRecord++; |
| 811 | lookupCount--; |
Behdad Esfahbod | f9c0a2d | 2009-09-21 13:43:54 -0400 | [diff] [blame] | 812 | /* Err, this is wrong if the lookup jumped over some glyphs */ |
Behdad Esfahbod | 468e9cb | 2011-07-22 11:28:07 -0400 | [diff] [blame] | 813 | i += c->buffer->idx - old_pos; |
| 814 | if (unlikely (c->buffer->idx == end)) |
Behdad Esfahbod | 2616689 | 2012-10-29 21:51:56 -0700 | [diff] [blame] | 815 | return TRACE_RETURN (true); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 816 | |
| 817 | if (!done) |
| 818 | goto not_applied; |
| 819 | } |
| 820 | else |
| 821 | { |
| 822 | not_applied: |
| 823 | /* No lookup applied for this index */ |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 824 | c->buffer->next_glyph (); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 825 | i++; |
| 826 | } |
| 827 | } |
| 828 | |
Behdad Esfahbod | 2616689 | 2012-10-29 21:51:56 -0700 | [diff] [blame] | 829 | return TRACE_RETURN (true); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 830 | } |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 831 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 832 | |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 833 | |
| 834 | /* Contextual lookups */ |
| 835 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 836 | struct ContextClosureLookupContext |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 837 | { |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 838 | ContextClosureFuncs funcs; |
| 839 | const void *intersects_data; |
| 840 | }; |
| 841 | |
| 842 | struct ContextApplyLookupContext |
| 843 | { |
| 844 | ContextApplyFuncs funcs; |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 845 | const void *match_data; |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 846 | }; |
| 847 | |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 848 | static inline void context_closure_lookup (hb_closure_context_t *c, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 849 | unsigned int inputCount, /* Including the first glyph (not matched) */ |
| 850 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 851 | unsigned int lookupCount, |
| 852 | const LookupRecord lookupRecord[], |
| 853 | ContextClosureLookupContext &lookup_context) |
| 854 | { |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 855 | if (intersects_array (c, |
| 856 | inputCount ? inputCount - 1 : 0, input, |
| 857 | lookup_context.funcs.intersects, lookup_context.intersects_data)) |
| 858 | closure_lookup (c, |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 859 | lookupCount, lookupRecord); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 863 | static inline bool context_would_apply_lookup (hb_would_apply_context_t *c, |
| 864 | unsigned int inputCount, /* Including the first glyph (not matched) */ |
| 865 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 866 | unsigned int lookupCount, |
| 867 | const LookupRecord lookupRecord[], |
| 868 | ContextApplyLookupContext &lookup_context) |
| 869 | { |
| 870 | return would_match_input (c, |
| 871 | inputCount, input, |
| 872 | lookup_context.funcs.match, lookup_context.match_data); |
| 873 | } |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 874 | static inline bool context_apply_lookup (hb_apply_context_t *c, |
| 875 | unsigned int inputCount, /* Including the first glyph (not matched) */ |
| 876 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 877 | unsigned int lookupCount, |
| 878 | const LookupRecord lookupRecord[], |
| 879 | ContextApplyLookupContext &lookup_context) |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 880 | { |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 881 | return match_input (c, |
Behdad Esfahbod | 4169710 | 2010-05-05 01:37:58 -0400 | [diff] [blame] | 882 | inputCount, input, |
Behdad Esfahbod | 5df809b | 2012-05-13 15:17:51 +0200 | [diff] [blame] | 883 | lookup_context.funcs.match, lookup_context.match_data) |
| 884 | && apply_lookup (c, |
Behdad Esfahbod | 4169710 | 2010-05-05 01:37:58 -0400 | [diff] [blame] | 885 | inputCount, |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 886 | lookupCount, lookupRecord); |
Behdad Esfahbod | f14c2b7 | 2009-05-18 02:36:18 -0400 | [diff] [blame] | 887 | } |
| 888 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 889 | struct Rule |
| 890 | { |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 891 | inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 892 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 893 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 894 | const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 895 | context_closure_lookup (c, |
| 896 | inputCount, input, |
| 897 | lookupCount, lookupRecord, |
| 898 | lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 899 | } |
| 900 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 901 | inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const |
| 902 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 903 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 904 | const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); |
| 905 | return TRACE_RETURN (context_would_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context)); |
| 906 | } |
| 907 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 908 | inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_context) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 909 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 910 | TRACE_APPLY (this); |
Behdad Esfahbod | e45d3f8 | 2010-05-06 19:33:31 -0400 | [diff] [blame] | 911 | const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 912 | return TRACE_RETURN (context_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context)); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 913 | } |
| 914 | |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 915 | public: |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 916 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 917 | TRACE_SANITIZE (this); |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 918 | return inputCount.sanitize (c) |
| 919 | && lookupCount.sanitize (c) |
| 920 | && c->check_range (input, |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 921 | input[0].static_size * inputCount |
| 922 | + lookupRecordX[0].static_size * lookupCount); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 923 | } |
| 924 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 925 | protected: |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 926 | USHORT inputCount; /* Total number of glyphs in input |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 927 | * glyph sequence--includes the first |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 928 | * glyph */ |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 929 | USHORT lookupCount; /* Number of LookupRecords */ |
Behdad Esfahbod | d3480ba | 2009-11-03 10:47:29 -0500 | [diff] [blame] | 930 | USHORT input[VAR]; /* Array of match inputs--start with |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 931 | * second glyph */ |
Behdad Esfahbod | d3480ba | 2009-11-03 10:47:29 -0500 | [diff] [blame] | 932 | LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 933 | * design order */ |
Behdad Esfahbod | 569da92 | 2010-05-10 16:38:32 -0400 | [diff] [blame] | 934 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 935 | DEFINE_SIZE_ARRAY2 (4, input, lookupRecordX); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 936 | }; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 937 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 938 | struct RuleSet |
| 939 | { |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 940 | inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 941 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 942 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 943 | unsigned int num_rules = rule.len; |
| 944 | for (unsigned int i = 0; i < num_rules; i++) |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 945 | (this+rule[i]).closure (c, lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 946 | } |
| 947 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 948 | inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const |
| 949 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 950 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 951 | unsigned int num_rules = rule.len; |
| 952 | for (unsigned int i = 0; i < num_rules; i++) |
| 953 | { |
| 954 | if ((this+rule[i]).would_apply (c, lookup_context)) |
| 955 | return TRACE_RETURN (true); |
| 956 | } |
| 957 | return TRACE_RETURN (false); |
| 958 | } |
| 959 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 960 | inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_context) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 961 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 962 | TRACE_APPLY (this); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 963 | unsigned int num_rules = rule.len; |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 964 | for (unsigned int i = 0; i < num_rules; i++) |
| 965 | { |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 966 | if ((this+rule[i]).apply (c, lookup_context)) |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 967 | return TRACE_RETURN (true); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 968 | } |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 969 | return TRACE_RETURN (false); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 970 | } |
| 971 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 972 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 973 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 974 | return TRACE_RETURN (rule.sanitize (c, this)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 975 | } |
| 976 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 977 | protected: |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 978 | OffsetArrayOf<Rule> |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 979 | rule; /* Array of Rule tables |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 980 | * ordered by preference */ |
Behdad Esfahbod | ed07422 | 2010-05-10 18:08:46 -0400 | [diff] [blame] | 981 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 982 | DEFINE_SIZE_ARRAY (2, rule); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 983 | }; |
| 984 | |
| 985 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 986 | struct ContextFormat1 |
| 987 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 988 | inline void closure (hb_closure_context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 989 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 990 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 991 | |
| 992 | const Coverage &cov = (this+coverage); |
| 993 | |
| 994 | struct ContextClosureLookupContext lookup_context = { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 995 | {intersects_glyph}, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 996 | NULL |
| 997 | }; |
| 998 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 999 | unsigned int count = ruleSet.len; |
| 1000 | for (unsigned int i = 0; i < count; i++) |
| 1001 | if (cov.intersects_coverage (c->glyphs, i)) { |
| 1002 | const RuleSet &rule_set = this+ruleSet[i]; |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1003 | rule_set.closure (c, lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1004 | } |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1005 | } |
| 1006 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1007 | inline bool would_apply (hb_would_apply_context_t *c) const |
| 1008 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1009 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1010 | |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 1011 | const RuleSet &rule_set = this+ruleSet[(this+coverage) (c->glyphs[0])]; |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1012 | struct ContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1013 | {match_glyph}, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1014 | NULL |
| 1015 | }; |
| 1016 | return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); |
| 1017 | } |
| 1018 | |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1019 | inline const Coverage &get_coverage (void) const |
| 1020 | { |
| 1021 | return this+coverage; |
| 1022 | } |
| 1023 | |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1024 | inline bool apply (hb_apply_context_t *c) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1025 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1026 | TRACE_APPLY (this); |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1027 | unsigned int index = (this+coverage) (c->buffer->cur().codepoint); |
Behdad Esfahbod | 64d3fc8 | 2010-05-03 22:51:19 -0400 | [diff] [blame] | 1028 | if (likely (index == NOT_COVERED)) |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1029 | return TRACE_RETURN (false); |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1030 | |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1031 | const RuleSet &rule_set = this+ruleSet[index]; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1032 | struct ContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1033 | {match_glyph}, |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1034 | NULL |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1035 | }; |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1036 | return TRACE_RETURN (rule_set.apply (c, lookup_context)); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1037 | } |
| 1038 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1039 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1040 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1041 | return TRACE_RETURN (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1042 | } |
| 1043 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1044 | protected: |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1045 | USHORT format; /* Format identifier--format = 1 */ |
| 1046 | OffsetTo<Coverage> |
| 1047 | coverage; /* Offset to Coverage table--from |
| 1048 | * beginning of table */ |
| 1049 | OffsetArrayOf<RuleSet> |
| 1050 | ruleSet; /* Array of RuleSet tables |
| 1051 | * ordered by Coverage Index */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1052 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 1053 | DEFINE_SIZE_ARRAY (6, ruleSet); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1054 | }; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1055 | |
| 1056 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1057 | struct ContextFormat2 |
| 1058 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1059 | inline void closure (hb_closure_context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1060 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1061 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1062 | if (!(this+coverage).intersects (c->glyphs)) |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1063 | return; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1064 | |
| 1065 | const ClassDef &class_def = this+classDef; |
| 1066 | |
| 1067 | struct ContextClosureLookupContext lookup_context = { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1068 | {intersects_class}, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1069 | NULL |
| 1070 | }; |
| 1071 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1072 | unsigned int count = ruleSet.len; |
| 1073 | for (unsigned int i = 0; i < count; i++) |
| 1074 | if (class_def.intersects_class (c->glyphs, i)) { |
| 1075 | const RuleSet &rule_set = this+ruleSet[i]; |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1076 | rule_set.closure (c, lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1077 | } |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1078 | } |
| 1079 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1080 | inline bool would_apply (hb_would_apply_context_t *c) const |
| 1081 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1082 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1083 | |
| 1084 | const ClassDef &class_def = this+classDef; |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 1085 | unsigned int index = class_def (c->glyphs[0]); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1086 | const RuleSet &rule_set = this+ruleSet[index]; |
| 1087 | struct ContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1088 | {match_class}, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1089 | &class_def |
| 1090 | }; |
| 1091 | return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); |
| 1092 | } |
| 1093 | |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1094 | inline const Coverage &get_coverage (void) const |
| 1095 | { |
| 1096 | return this+coverage; |
| 1097 | } |
| 1098 | |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1099 | inline bool apply (hb_apply_context_t *c) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1100 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1101 | TRACE_APPLY (this); |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1102 | unsigned int index = (this+coverage) (c->buffer->cur().codepoint); |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1103 | if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1104 | |
| 1105 | const ClassDef &class_def = this+classDef; |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1106 | index = class_def (c->buffer->cur().codepoint); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1107 | const RuleSet &rule_set = this+ruleSet[index]; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1108 | struct ContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1109 | {match_class}, |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 1110 | &class_def |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1111 | }; |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1112 | return TRACE_RETURN (rule_set.apply (c, lookup_context)); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1113 | } |
| 1114 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1115 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1116 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1117 | return TRACE_RETURN (coverage.sanitize (c, this) && classDef.sanitize (c, this) && ruleSet.sanitize (c, this)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1118 | } |
| 1119 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1120 | protected: |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1121 | USHORT format; /* Format identifier--format = 2 */ |
| 1122 | OffsetTo<Coverage> |
| 1123 | coverage; /* Offset to Coverage table--from |
| 1124 | * beginning of table */ |
| 1125 | OffsetTo<ClassDef> |
| 1126 | classDef; /* Offset to glyph ClassDef table--from |
| 1127 | * beginning of table */ |
| 1128 | OffsetArrayOf<RuleSet> |
| 1129 | ruleSet; /* Array of RuleSet tables |
| 1130 | * ordered by class */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1131 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 1132 | DEFINE_SIZE_ARRAY (8, ruleSet); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1133 | }; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1134 | |
| 1135 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1136 | struct ContextFormat3 |
| 1137 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1138 | inline void closure (hb_closure_context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1139 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1140 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1141 | if (!(this+coverage[0]).intersects (c->glyphs)) |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1142 | return; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1143 | |
| 1144 | const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); |
| 1145 | struct ContextClosureLookupContext lookup_context = { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1146 | {intersects_coverage}, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1147 | this |
| 1148 | }; |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1149 | context_closure_lookup (c, |
| 1150 | glyphCount, (const USHORT *) (coverage + 1), |
| 1151 | lookupCount, lookupRecord, |
| 1152 | lookup_context); |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1153 | } |
| 1154 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1155 | inline bool would_apply (hb_would_apply_context_t *c) const |
| 1156 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1157 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1158 | |
| 1159 | const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); |
| 1160 | struct ContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1161 | {match_coverage}, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1162 | this |
| 1163 | }; |
| 1164 | return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context)); |
| 1165 | } |
| 1166 | |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1167 | inline const Coverage &get_coverage (void) const |
| 1168 | { |
| 1169 | return this+coverage[0]; |
| 1170 | } |
| 1171 | |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1172 | inline bool apply (hb_apply_context_t *c) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1173 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1174 | TRACE_APPLY (this); |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1175 | unsigned int index = (this+coverage[0]) (c->buffer->cur().codepoint); |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1176 | if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); |
Behdad Esfahbod | 02e1e5c | 2009-05-18 02:47:57 -0400 | [diff] [blame] | 1177 | |
Behdad Esfahbod | e45d3f8 | 2010-05-06 19:33:31 -0400 | [diff] [blame] | 1178 | const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1179 | struct ContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1180 | {match_coverage}, |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 1181 | this |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1182 | }; |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1183 | return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context)); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1184 | } |
| 1185 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1186 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1187 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1188 | if (!c->check_struct (this)) return TRACE_RETURN (false); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1189 | unsigned int count = glyphCount; |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1190 | if (!c->check_array (coverage, coverage[0].static_size, count)) return TRACE_RETURN (false); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1191 | for (unsigned int i = 0; i < count; i++) |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1192 | if (!coverage[i].sanitize (c, this)) return TRACE_RETURN (false); |
Behdad Esfahbod | e45d3f8 | 2010-05-06 19:33:31 -0400 | [diff] [blame] | 1193 | LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * count); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1194 | return TRACE_RETURN (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1195 | } |
| 1196 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1197 | protected: |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1198 | USHORT format; /* Format identifier--format = 3 */ |
| 1199 | USHORT glyphCount; /* Number of glyphs in the input glyph |
| 1200 | * sequence */ |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1201 | USHORT lookupCount; /* Number of LookupRecords */ |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1202 | OffsetTo<Coverage> |
Behdad Esfahbod | d3480ba | 2009-11-03 10:47:29 -0500 | [diff] [blame] | 1203 | coverage[VAR]; /* Array of offsets to Coverage |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1204 | * table in glyph sequence order */ |
Behdad Esfahbod | d3480ba | 2009-11-03 10:47:29 -0500 | [diff] [blame] | 1205 | LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1206 | * design order */ |
Behdad Esfahbod | 569da92 | 2010-05-10 16:38:32 -0400 | [diff] [blame] | 1207 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 1208 | DEFINE_SIZE_ARRAY2 (6, coverage, lookupRecordX); |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1209 | }; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1210 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1211 | struct Context |
| 1212 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1213 | template <typename context_t> |
| 1214 | inline typename context_t::return_t process (context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1215 | { |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1216 | switch (u.format) { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1217 | case 1: return c->process (u.format1); |
| 1218 | case 2: return c->process (u.format2); |
| 1219 | case 3: return c->process (u.format3); |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 1220 | default:return c->default_return_value (); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1221 | } |
| 1222 | } |
| 1223 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1224 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1225 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1226 | if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1227 | switch (u.format) { |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1228 | case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 1229 | case 2: return TRACE_RETURN (u.format2.sanitize (c)); |
| 1230 | case 3: return TRACE_RETURN (u.format3.sanitize (c)); |
| 1231 | default:return TRACE_RETURN (true); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1232 | } |
| 1233 | } |
| 1234 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1235 | protected: |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1236 | union { |
Behdad Esfahbod | f8dc67b | 2009-05-17 19:47:54 -0400 | [diff] [blame] | 1237 | USHORT format; /* Format identifier */ |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 1238 | ContextFormat1 format1; |
| 1239 | ContextFormat2 format2; |
| 1240 | ContextFormat3 format3; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1241 | } u; |
| 1242 | }; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1243 | |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1244 | |
| 1245 | /* Chaining Contextual lookups */ |
| 1246 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1247 | struct ChainContextClosureLookupContext |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1248 | { |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1249 | ContextClosureFuncs funcs; |
| 1250 | const void *intersects_data[3]; |
| 1251 | }; |
| 1252 | |
| 1253 | struct ChainContextApplyLookupContext |
| 1254 | { |
| 1255 | ContextApplyFuncs funcs; |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 1256 | const void *match_data[3]; |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1257 | }; |
| 1258 | |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1259 | static inline void chain_context_closure_lookup (hb_closure_context_t *c, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1260 | unsigned int backtrackCount, |
| 1261 | const USHORT backtrack[], |
| 1262 | unsigned int inputCount, /* Including the first glyph (not matched) */ |
| 1263 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 1264 | unsigned int lookaheadCount, |
| 1265 | const USHORT lookahead[], |
| 1266 | unsigned int lookupCount, |
| 1267 | const LookupRecord lookupRecord[], |
| 1268 | ChainContextClosureLookupContext &lookup_context) |
| 1269 | { |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1270 | if (intersects_array (c, |
| 1271 | backtrackCount, backtrack, |
| 1272 | lookup_context.funcs.intersects, lookup_context.intersects_data[0]) |
| 1273 | && intersects_array (c, |
| 1274 | inputCount ? inputCount - 1 : 0, input, |
| 1275 | lookup_context.funcs.intersects, lookup_context.intersects_data[1]) |
| 1276 | && intersects_array (c, |
| 1277 | lookaheadCount, lookahead, |
| 1278 | lookup_context.funcs.intersects, lookup_context.intersects_data[2])) |
| 1279 | closure_lookup (c, |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1280 | lookupCount, lookupRecord); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1281 | } |
| 1282 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1283 | static inline bool chain_context_would_apply_lookup (hb_would_apply_context_t *c, |
| 1284 | unsigned int backtrackCount, |
| 1285 | const USHORT backtrack[], |
| 1286 | unsigned int inputCount, /* Including the first glyph (not matched) */ |
| 1287 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 1288 | unsigned int lookaheadCount, |
| 1289 | const USHORT lookahead[], |
| 1290 | unsigned int lookupCount, |
| 1291 | const LookupRecord lookupRecord[], |
| 1292 | ChainContextApplyLookupContext &lookup_context) |
| 1293 | { |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 1294 | return (c->zero_context ? !backtrackCount && !lookaheadCount : true) |
Behdad Esfahbod | 1f2bb17 | 2012-08-23 16:10:37 -0400 | [diff] [blame] | 1295 | && would_match_input (c, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1296 | inputCount, input, |
| 1297 | lookup_context.funcs.match, lookup_context.match_data[1]); |
| 1298 | } |
| 1299 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1300 | static inline bool chain_context_apply_lookup (hb_apply_context_t *c, |
| 1301 | unsigned int backtrackCount, |
| 1302 | const USHORT backtrack[], |
| 1303 | unsigned int inputCount, /* Including the first glyph (not matched) */ |
| 1304 | const USHORT input[], /* Array of input values--start with second glyph */ |
| 1305 | unsigned int lookaheadCount, |
| 1306 | const USHORT lookahead[], |
| 1307 | unsigned int lookupCount, |
| 1308 | const LookupRecord lookupRecord[], |
| 1309 | ChainContextApplyLookupContext &lookup_context) |
Behdad Esfahbod | 02e1e5c | 2009-05-18 02:47:57 -0400 | [diff] [blame] | 1310 | { |
Behdad Esfahbod | c779d82 | 2012-11-23 14:07:24 -0500 | [diff] [blame] | 1311 | unsigned int lookahead_offset = 0; |
Behdad Esfahbod | f19e0b0 | 2012-06-09 02:26:57 -0400 | [diff] [blame] | 1312 | return match_input (c, |
Behdad Esfahbod | 4169710 | 2010-05-05 01:37:58 -0400 | [diff] [blame] | 1313 | inputCount, input, |
| 1314 | lookup_context.funcs.match, lookup_context.match_data[1], |
Behdad Esfahbod | 5df809b | 2012-05-13 15:17:51 +0200 | [diff] [blame] | 1315 | &lookahead_offset) |
Behdad Esfahbod | f19e0b0 | 2012-06-09 02:26:57 -0400 | [diff] [blame] | 1316 | && match_backtrack (c, |
| 1317 | backtrackCount, backtrack, |
| 1318 | lookup_context.funcs.match, lookup_context.match_data[0]) |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1319 | && match_lookahead (c, |
Behdad Esfahbod | 4169710 | 2010-05-05 01:37:58 -0400 | [diff] [blame] | 1320 | lookaheadCount, lookahead, |
| 1321 | lookup_context.funcs.match, lookup_context.match_data[2], |
Behdad Esfahbod | 5df809b | 2012-05-13 15:17:51 +0200 | [diff] [blame] | 1322 | lookahead_offset) |
| 1323 | && apply_lookup (c, |
Behdad Esfahbod | 4169710 | 2010-05-05 01:37:58 -0400 | [diff] [blame] | 1324 | inputCount, |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1325 | lookupCount, lookupRecord); |
Behdad Esfahbod | 02e1e5c | 2009-05-18 02:47:57 -0400 | [diff] [blame] | 1326 | } |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1327 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1328 | struct ChainRule |
| 1329 | { |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1330 | inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1331 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1332 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1333 | const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack); |
| 1334 | const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); |
| 1335 | const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1336 | chain_context_closure_lookup (c, |
| 1337 | backtrack.len, backtrack.array, |
| 1338 | input.len, input.array, |
| 1339 | lookahead.len, lookahead.array, |
| 1340 | lookup.len, lookup.array, |
| 1341 | lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1342 | } |
| 1343 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1344 | inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
| 1345 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1346 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1347 | const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack); |
| 1348 | const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); |
| 1349 | const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
| 1350 | return TRACE_RETURN (chain_context_would_apply_lookup (c, |
| 1351 | backtrack.len, backtrack.array, |
| 1352 | input.len, input.array, |
| 1353 | lookahead.len, lookahead.array, lookup.len, |
| 1354 | lookup.array, lookup_context)); |
| 1355 | } |
| 1356 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1357 | inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1358 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1359 | TRACE_APPLY (this); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1360 | const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack); |
| 1361 | const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); |
| 1362 | const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1363 | return TRACE_RETURN (chain_context_apply_lookup (c, |
| 1364 | backtrack.len, backtrack.array, |
| 1365 | input.len, input.array, |
| 1366 | lookahead.len, lookahead.array, lookup.len, |
| 1367 | lookup.array, lookup_context)); |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1368 | } |
| 1369 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1370 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1371 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1372 | if (!backtrack.sanitize (c)) return TRACE_RETURN (false); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1373 | HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1374 | if (!input.sanitize (c)) return TRACE_RETURN (false); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1375 | ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1376 | if (!lookahead.sanitize (c)) return TRACE_RETURN (false); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1377 | ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1378 | return TRACE_RETURN (lookup.sanitize (c)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1379 | } |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1380 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1381 | protected: |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1382 | ArrayOf<USHORT> |
| 1383 | backtrack; /* Array of backtracking values |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1384 | * (to be matched before the input |
| 1385 | * sequence) */ |
Behdad Esfahbod | e8cbaaf | 2009-05-18 02:03:58 -0400 | [diff] [blame] | 1386 | HeadlessArrayOf<USHORT> |
| 1387 | inputX; /* Array of input values (start with |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1388 | * second glyph) */ |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1389 | ArrayOf<USHORT> |
| 1390 | lookaheadX; /* Array of lookahead values's (to be |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1391 | * matched after the input sequence) */ |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1392 | ArrayOf<LookupRecord> |
Behdad Esfahbod | 02e1e5c | 2009-05-18 02:47:57 -0400 | [diff] [blame] | 1393 | lookupX; /* Array of LookupRecords--in |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1394 | * design order) */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1395 | public: |
Behdad Esfahbod | bea34c7 | 2010-05-10 17:28:16 -0400 | [diff] [blame] | 1396 | DEFINE_SIZE_MIN (8); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1397 | }; |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1398 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1399 | struct ChainRuleSet |
| 1400 | { |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1401 | inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1402 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1403 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1404 | unsigned int num_rules = rule.len; |
| 1405 | for (unsigned int i = 0; i < num_rules; i++) |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1406 | (this+rule[i]).closure (c, lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1407 | } |
| 1408 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1409 | inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
| 1410 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1411 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1412 | unsigned int num_rules = rule.len; |
| 1413 | for (unsigned int i = 0; i < num_rules; i++) |
| 1414 | if ((this+rule[i]).would_apply (c, lookup_context)) |
| 1415 | return TRACE_RETURN (true); |
| 1416 | |
| 1417 | return TRACE_RETURN (false); |
| 1418 | } |
| 1419 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1420 | inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1421 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1422 | TRACE_APPLY (this); |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1423 | unsigned int num_rules = rule.len; |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1424 | for (unsigned int i = 0; i < num_rules; i++) |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1425 | if ((this+rule[i]).apply (c, lookup_context)) |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1426 | return TRACE_RETURN (true); |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1427 | |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1428 | return TRACE_RETURN (false); |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1429 | } |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1430 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1431 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1432 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1433 | return TRACE_RETURN (rule.sanitize (c, this)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1434 | } |
| 1435 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1436 | protected: |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1437 | OffsetArrayOf<ChainRule> |
| 1438 | rule; /* Array of ChainRule tables |
| 1439 | * ordered by preference */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1440 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 1441 | DEFINE_SIZE_ARRAY (2, rule); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1442 | }; |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1443 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1444 | struct ChainContextFormat1 |
| 1445 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1446 | inline void closure (hb_closure_context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1447 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1448 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1449 | const Coverage &cov = (this+coverage); |
| 1450 | |
| 1451 | struct ChainContextClosureLookupContext lookup_context = { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1452 | {intersects_glyph}, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1453 | {NULL, NULL, NULL} |
| 1454 | }; |
| 1455 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1456 | unsigned int count = ruleSet.len; |
| 1457 | for (unsigned int i = 0; i < count; i++) |
| 1458 | if (cov.intersects_coverage (c->glyphs, i)) { |
| 1459 | const ChainRuleSet &rule_set = this+ruleSet[i]; |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1460 | rule_set.closure (c, lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1461 | } |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1462 | } |
| 1463 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1464 | inline bool would_apply (hb_would_apply_context_t *c) const |
| 1465 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1466 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1467 | |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 1468 | const ChainRuleSet &rule_set = this+ruleSet[(this+coverage) (c->glyphs[0])]; |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1469 | struct ChainContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1470 | {match_glyph}, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1471 | {NULL, NULL, NULL} |
| 1472 | }; |
| 1473 | return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); |
| 1474 | } |
| 1475 | |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1476 | inline const Coverage &get_coverage (void) const |
| 1477 | { |
| 1478 | return this+coverage; |
| 1479 | } |
| 1480 | |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1481 | inline bool apply (hb_apply_context_t *c) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1482 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1483 | TRACE_APPLY (this); |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1484 | unsigned int index = (this+coverage) (c->buffer->cur().codepoint); |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1485 | if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1486 | |
| 1487 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1488 | struct ChainContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1489 | {match_glyph}, |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1490 | {NULL, NULL, NULL} |
| 1491 | }; |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1492 | return TRACE_RETURN (rule_set.apply (c, lookup_context)); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1493 | } |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1494 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1495 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1496 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1497 | return TRACE_RETURN (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1498 | } |
| 1499 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1500 | protected: |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1501 | USHORT format; /* Format identifier--format = 1 */ |
Behdad Esfahbod | 48f16ed | 2009-05-17 22:11:30 -0400 | [diff] [blame] | 1502 | OffsetTo<Coverage> |
| 1503 | coverage; /* Offset to Coverage table--from |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1504 | * beginning of table */ |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1505 | OffsetArrayOf<ChainRuleSet> |
| 1506 | ruleSet; /* Array of ChainRuleSet tables |
| 1507 | * ordered by Coverage Index */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1508 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 1509 | DEFINE_SIZE_ARRAY (6, ruleSet); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1510 | }; |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1511 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1512 | struct ChainContextFormat2 |
| 1513 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1514 | inline void closure (hb_closure_context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1515 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1516 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1517 | if (!(this+coverage).intersects (c->glyphs)) |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1518 | return; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1519 | |
| 1520 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
| 1521 | const ClassDef &input_class_def = this+inputClassDef; |
| 1522 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
| 1523 | |
| 1524 | struct ChainContextClosureLookupContext lookup_context = { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1525 | {intersects_class}, |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1526 | {&backtrack_class_def, |
| 1527 | &input_class_def, |
| 1528 | &lookahead_class_def} |
| 1529 | }; |
| 1530 | |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1531 | unsigned int count = ruleSet.len; |
| 1532 | for (unsigned int i = 0; i < count; i++) |
| 1533 | if (input_class_def.intersects_class (c->glyphs, i)) { |
| 1534 | const ChainRuleSet &rule_set = this+ruleSet[i]; |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1535 | rule_set.closure (c, lookup_context); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1536 | } |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1537 | } |
| 1538 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1539 | inline bool would_apply (hb_would_apply_context_t *c) const |
| 1540 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1541 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1542 | |
| 1543 | const ClassDef &input_class_def = this+inputClassDef; |
| 1544 | |
Behdad Esfahbod | 472f229 | 2012-08-07 22:25:24 -0400 | [diff] [blame] | 1545 | unsigned int index = input_class_def (c->glyphs[0]); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1546 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
| 1547 | struct ChainContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1548 | {match_class}, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1549 | {NULL, &input_class_def, NULL} |
| 1550 | }; |
| 1551 | return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); |
| 1552 | } |
| 1553 | |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1554 | inline const Coverage &get_coverage (void) const |
| 1555 | { |
| 1556 | return this+coverage; |
| 1557 | } |
| 1558 | |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1559 | inline bool apply (hb_apply_context_t *c) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1560 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1561 | TRACE_APPLY (this); |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1562 | unsigned int index = (this+coverage) (c->buffer->cur().codepoint); |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1563 | if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1564 | |
| 1565 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
| 1566 | const ClassDef &input_class_def = this+inputClassDef; |
| 1567 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
| 1568 | |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1569 | index = input_class_def (c->buffer->cur().codepoint); |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1570 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1571 | struct ChainContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1572 | {match_class}, |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 1573 | {&backtrack_class_def, |
| 1574 | &input_class_def, |
| 1575 | &lookahead_class_def} |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1576 | }; |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1577 | return TRACE_RETURN (rule_set.apply (c, lookup_context)); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1578 | } |
| 1579 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1580 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1581 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1582 | return TRACE_RETURN (coverage.sanitize (c, this) && backtrackClassDef.sanitize (c, this) && |
| 1583 | inputClassDef.sanitize (c, this) && lookaheadClassDef.sanitize (c, this) && |
| 1584 | ruleSet.sanitize (c, this)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1585 | } |
| 1586 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1587 | protected: |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1588 | USHORT format; /* Format identifier--format = 2 */ |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1589 | OffsetTo<Coverage> |
| 1590 | coverage; /* Offset to Coverage table--from |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1591 | * beginning of table */ |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1592 | OffsetTo<ClassDef> |
| 1593 | backtrackClassDef; /* Offset to glyph ClassDef table |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1594 | * containing backtrack sequence |
| 1595 | * data--from beginning of table */ |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1596 | OffsetTo<ClassDef> |
| 1597 | inputClassDef; /* Offset to glyph ClassDef |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1598 | * table containing input sequence |
| 1599 | * data--from beginning of table */ |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1600 | OffsetTo<ClassDef> |
| 1601 | lookaheadClassDef; /* Offset to glyph ClassDef table |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1602 | * containing lookahead sequence |
| 1603 | * data--from beginning of table */ |
Behdad Esfahbod | aa3d7ad | 2009-05-17 23:17:56 -0400 | [diff] [blame] | 1604 | OffsetArrayOf<ChainRuleSet> |
| 1605 | ruleSet; /* Array of ChainRuleSet tables |
| 1606 | * ordered by class */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1607 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 1608 | DEFINE_SIZE_ARRAY (12, ruleSet); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1609 | }; |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1610 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1611 | struct ChainContextFormat3 |
| 1612 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1613 | inline void closure (hb_closure_context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1614 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1615 | TRACE_CLOSURE (this); |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1616 | const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |
| 1617 | |
| 1618 | if (!(this+input[0]).intersects (c->glyphs)) |
| 1619 | return; |
| 1620 | |
| 1621 | const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input); |
| 1622 | const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
| 1623 | struct ChainContextClosureLookupContext lookup_context = { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1624 | {intersects_coverage}, |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1625 | {this, this, this} |
| 1626 | }; |
| 1627 | chain_context_closure_lookup (c, |
| 1628 | backtrack.len, (const USHORT *) backtrack.array, |
| 1629 | input.len, (const USHORT *) input.array + 1, |
| 1630 | lookahead.len, (const USHORT *) lookahead.array, |
| 1631 | lookup.len, lookup.array, |
| 1632 | lookup_context); |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1633 | } |
| 1634 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1635 | inline bool would_apply (hb_would_apply_context_t *c) const |
| 1636 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1637 | TRACE_WOULD_APPLY (this); |
Behdad Esfahbod | e6f7479 | 2012-07-28 18:34:58 -0400 | [diff] [blame] | 1638 | |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1639 | const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1640 | const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input); |
| 1641 | const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
| 1642 | struct ChainContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1643 | {match_coverage}, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1644 | {this, this, this} |
| 1645 | }; |
| 1646 | return TRACE_RETURN (chain_context_would_apply_lookup (c, |
| 1647 | backtrack.len, (const USHORT *) backtrack.array, |
| 1648 | input.len, (const USHORT *) input.array + 1, |
| 1649 | lookahead.len, (const USHORT *) lookahead.array, |
| 1650 | lookup.len, lookup.array, lookup_context)); |
| 1651 | } |
| 1652 | |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1653 | inline const Coverage &get_coverage (void) const |
| 1654 | { |
| 1655 | const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |
| 1656 | return this+input[0]; |
| 1657 | } |
| 1658 | |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1659 | inline bool apply (hb_apply_context_t *c) const |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1660 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1661 | TRACE_APPLY (this); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1662 | const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |
Behdad Esfahbod | 02e1e5c | 2009-05-18 02:47:57 -0400 | [diff] [blame] | 1663 | |
Behdad Esfahbod | 99c2695 | 2012-05-13 15:45:18 +0200 | [diff] [blame] | 1664 | unsigned int index = (this+input[0]) (c->buffer->cur().codepoint); |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1665 | if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1666 | |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1667 | const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input); |
| 1668 | const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
Behdad Esfahbod | 31081f7 | 2012-04-23 16:54:58 -0400 | [diff] [blame] | 1669 | struct ChainContextApplyLookupContext lookup_context = { |
Behdad Esfahbod | ec35a72 | 2012-11-22 16:05:59 -0500 | [diff] [blame] | 1670 | {match_coverage}, |
Behdad Esfahbod | 40cbefe | 2010-05-10 17:47:22 -0400 | [diff] [blame] | 1671 | {this, this, this} |
Behdad Esfahbod | 02e1e5c | 2009-05-18 02:47:57 -0400 | [diff] [blame] | 1672 | }; |
Behdad Esfahbod | acea183 | 2012-05-11 02:33:11 +0200 | [diff] [blame] | 1673 | return TRACE_RETURN (chain_context_apply_lookup (c, |
| 1674 | backtrack.len, (const USHORT *) backtrack.array, |
| 1675 | input.len, (const USHORT *) input.array + 1, |
| 1676 | lookahead.len, (const USHORT *) lookahead.array, |
| 1677 | lookup.len, lookup.array, lookup_context)); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1678 | } |
| 1679 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1680 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1681 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1682 | if (!backtrack.sanitize (c, this)) return TRACE_RETURN (false); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1683 | OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1684 | if (!input.sanitize (c, this)) return TRACE_RETURN (false); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1685 | OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1686 | if (!lookahead.sanitize (c, this)) return TRACE_RETURN (false); |
Behdad Esfahbod | e961c86 | 2010-04-21 15:56:11 -0400 | [diff] [blame] | 1687 | ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1688 | return TRACE_RETURN (lookup.sanitize (c)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1689 | } |
| 1690 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1691 | protected: |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1692 | USHORT format; /* Format identifier--format = 3 */ |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1693 | OffsetArrayOf<Coverage> |
Behdad Esfahbod | 13ed440 | 2009-05-18 02:14:37 -0400 | [diff] [blame] | 1694 | backtrack; /* Array of coverage tables |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1695 | * in backtracking sequence, in glyph |
| 1696 | * sequence order */ |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1697 | OffsetArrayOf<Coverage> |
Behdad Esfahbod | 13ed440 | 2009-05-18 02:14:37 -0400 | [diff] [blame] | 1698 | inputX ; /* Array of coverage |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1699 | * tables in input sequence, in glyph |
| 1700 | * sequence order */ |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1701 | OffsetArrayOf<Coverage> |
Behdad Esfahbod | 13ed440 | 2009-05-18 02:14:37 -0400 | [diff] [blame] | 1702 | lookaheadX; /* Array of coverage tables |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1703 | * in lookahead sequence, in glyph |
| 1704 | * sequence order */ |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1705 | ArrayOf<LookupRecord> |
Behdad Esfahbod | 02e1e5c | 2009-05-18 02:47:57 -0400 | [diff] [blame] | 1706 | lookupX; /* Array of LookupRecords--in |
Behdad Esfahbod | dcb6b60 | 2009-05-18 01:49:57 -0400 | [diff] [blame] | 1707 | * design order) */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1708 | public: |
Behdad Esfahbod | bea34c7 | 2010-05-10 17:28:16 -0400 | [diff] [blame] | 1709 | DEFINE_SIZE_MIN (10); |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1710 | }; |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1711 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1712 | struct ChainContext |
| 1713 | { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1714 | template <typename context_t> |
| 1715 | inline typename context_t::return_t process (context_t *c) const |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1716 | { |
Behdad Esfahbod | a1733db | 2012-11-23 16:40:04 -0500 | [diff] [blame] | 1717 | TRACE_PROCESS (this); |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1718 | switch (u.format) { |
Behdad Esfahbod | 44fc237 | 2012-11-21 23:33:13 -0500 | [diff] [blame] | 1719 | case 1: return c->process (u.format1); |
| 1720 | case 2: return c->process (u.format2); |
| 1721 | case 3: return c->process (u.format3); |
Behdad Esfahbod | 2005fa5 | 2012-11-22 14:38:10 -0500 | [diff] [blame] | 1722 | default:return c->default_return_value (); |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1723 | } |
| 1724 | } |
| 1725 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1726 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1727 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1728 | if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1729 | switch (u.format) { |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1730 | case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 1731 | case 2: return TRACE_RETURN (u.format2.sanitize (c)); |
| 1732 | case 3: return TRACE_RETURN (u.format3.sanitize (c)); |
| 1733 | default:return TRACE_RETURN (true); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1734 | } |
| 1735 | } |
| 1736 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1737 | protected: |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1738 | union { |
| 1739 | USHORT format; /* Format identifier */ |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 1740 | ChainContextFormat1 format1; |
| 1741 | ChainContextFormat2 format2; |
| 1742 | ChainContextFormat3 format3; |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1743 | } u; |
| 1744 | }; |
Behdad Esfahbod | ca5290f | 2009-05-17 20:48:27 -0400 | [diff] [blame] | 1745 | |
| 1746 | |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1747 | struct ExtensionFormat1 |
| 1748 | { |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1749 | inline unsigned int get_type (void) const { return extensionLookupType; } |
Behdad Esfahbod | 3b2c2df | 2010-04-22 16:51:42 -0400 | [diff] [blame] | 1750 | inline unsigned int get_offset (void) const { return extensionOffset; } |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1751 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1752 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1753 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1754 | return TRACE_RETURN (c->check_struct (this)); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1755 | } |
| 1756 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1757 | protected: |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1758 | USHORT format; /* Format identifier. Set to 1. */ |
| 1759 | USHORT extensionLookupType; /* Lookup type of subtable referenced |
| 1760 | * by ExtensionOffset (i.e. the |
| 1761 | * extension subtable). */ |
Behdad Esfahbod | 81f2af4 | 2010-04-22 00:58:49 -0400 | [diff] [blame] | 1762 | ULONG extensionOffset; /* Offset to the extension subtable, |
| 1763 | * of lookup type subtable. */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1764 | public: |
| 1765 | DEFINE_SIZE_STATIC (8); |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1766 | }; |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1767 | |
Behdad Esfahbod | 653eeb2 | 2012-11-23 16:57:36 -0500 | [diff] [blame] | 1768 | template <typename T> |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1769 | struct Extension |
| 1770 | { |
| 1771 | inline unsigned int get_type (void) const |
| 1772 | { |
| 1773 | switch (u.format) { |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 1774 | case 1: return u.format1.get_type (); |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1775 | default:return 0; |
| 1776 | } |
| 1777 | } |
Behdad Esfahbod | 3b2c2df | 2010-04-22 16:51:42 -0400 | [diff] [blame] | 1778 | inline unsigned int get_offset (void) const |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1779 | { |
| 1780 | switch (u.format) { |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 1781 | case 1: return u.format1.get_offset (); |
Behdad Esfahbod | 3b2c2df | 2010-04-22 16:51:42 -0400 | [diff] [blame] | 1782 | default:return 0; |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1783 | } |
| 1784 | } |
| 1785 | |
Behdad Esfahbod | 7dddd4e | 2012-11-23 17:04:55 -0500 | [diff] [blame^] | 1786 | template <typename X> |
| 1787 | inline const X& get_subtable (void) const |
| 1788 | { |
| 1789 | unsigned int offset = get_offset (); |
| 1790 | if (unlikely (!offset)) return Null(typename T::LookupSubTable); |
| 1791 | return StructAtOffset<typename T::LookupSubTable> (this, offset); |
| 1792 | } |
| 1793 | |
Behdad Esfahbod | 653eeb2 | 2012-11-23 16:57:36 -0500 | [diff] [blame] | 1794 | template <typename context_t> |
| 1795 | inline typename context_t::return_t process (context_t *c) const |
| 1796 | { |
Behdad Esfahbod | 7dddd4e | 2012-11-23 17:04:55 -0500 | [diff] [blame^] | 1797 | return CastP<T>(this)->get_subtable<typename T::LookupSubTable> ().process (c, get_type ()); |
Behdad Esfahbod | 653eeb2 | 2012-11-23 16:57:36 -0500 | [diff] [blame] | 1798 | } |
| 1799 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1800 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1801 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1802 | if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1803 | switch (u.format) { |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1804 | case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 1805 | default:return TRACE_RETURN (true); |
Behdad Esfahbod | 70de50c | 2009-08-04 00:58:28 -0400 | [diff] [blame] | 1806 | } |
| 1807 | } |
| 1808 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 1809 | protected: |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1810 | union { |
| 1811 | USHORT format; /* Format identifier */ |
Behdad Esfahbod | 6d08c7f | 2012-07-11 18:01:27 -0400 | [diff] [blame] | 1812 | ExtensionFormat1 format1; |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1813 | } u; |
| 1814 | }; |
Behdad Esfahbod | d468f9a | 2009-05-21 22:31:33 -0400 | [diff] [blame] | 1815 | |
| 1816 | |
Behdad Esfahbod | f45107f | 2009-05-17 20:13:02 -0400 | [diff] [blame] | 1817 | /* |
| 1818 | * GSUB/GPOS Common |
| 1819 | */ |
| 1820 | |
Behdad Esfahbod | 60d77cf | 2009-05-19 23:58:54 -0400 | [diff] [blame] | 1821 | struct GSUBGPOS |
| 1822 | { |
Behdad Esfahbod | a328d66 | 2009-08-04 20:27:05 -0400 | [diff] [blame] | 1823 | static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB; |
| 1824 | static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS; |
Behdad Esfahbod | f45107f | 2009-05-17 20:13:02 -0400 | [diff] [blame] | 1825 | |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 1826 | inline unsigned int get_script_count (void) const |
| 1827 | { return (this+scriptList).len; } |
| 1828 | inline const Tag& get_script_tag (unsigned int i) const |
| 1829 | { return (this+scriptList).get_tag (i); } |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 1830 | inline unsigned int get_script_tags (unsigned int start_offset, |
| 1831 | unsigned int *script_count /* IN/OUT */, |
| 1832 | hb_tag_t *script_tags /* OUT */) const |
| 1833 | { return (this+scriptList).get_tags (start_offset, script_count, script_tags); } |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 1834 | inline const Script& get_script (unsigned int i) const |
| 1835 | { return (this+scriptList)[i]; } |
| 1836 | inline bool find_script_index (hb_tag_t tag, unsigned int *index) const |
| 1837 | { return (this+scriptList).find_index (tag, index); } |
Behdad Esfahbod | f45107f | 2009-05-17 20:13:02 -0400 | [diff] [blame] | 1838 | |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 1839 | inline unsigned int get_feature_count (void) const |
| 1840 | { return (this+featureList).len; } |
| 1841 | inline const Tag& get_feature_tag (unsigned int i) const |
| 1842 | { return (this+featureList).get_tag (i); } |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 1843 | inline unsigned int get_feature_tags (unsigned int start_offset, |
| 1844 | unsigned int *feature_count /* IN/OUT */, |
| 1845 | hb_tag_t *feature_tags /* OUT */) const |
| 1846 | { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); } |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 1847 | inline const Feature& get_feature (unsigned int i) const |
| 1848 | { return (this+featureList)[i]; } |
| 1849 | inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const |
| 1850 | { return (this+featureList).find_index (tag, index); } |
| 1851 | |
| 1852 | inline unsigned int get_lookup_count (void) const |
| 1853 | { return (this+lookupList).len; } |
| 1854 | inline const Lookup& get_lookup (unsigned int i) const |
| 1855 | { return (this+lookupList)[i]; } |
Behdad Esfahbod | f45107f | 2009-05-17 20:13:02 -0400 | [diff] [blame] | 1856 | |
Behdad Esfahbod | d7cfb3b | 2010-05-13 14:18:49 -0400 | [diff] [blame] | 1857 | inline bool sanitize (hb_sanitize_context_t *c) { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 1858 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 1859 | return TRACE_RETURN (version.sanitize (c) && likely (version.major == 1) && |
| 1860 | scriptList.sanitize (c, this) && |
| 1861 | featureList.sanitize (c, this) && |
| 1862 | lookupList.sanitize (c, this)); |
Behdad Esfahbod | cd3827e | 2009-08-04 02:09:34 -0400 | [diff] [blame] | 1863 | } |
| 1864 | |
Behdad Esfahbod | 212aba6 | 2009-05-24 00:50:27 -0400 | [diff] [blame] | 1865 | protected: |
Behdad Esfahbod | 87fcdcb | 2009-05-24 01:03:24 -0400 | [diff] [blame] | 1866 | FixedVersion version; /* Version of the GSUB/GPOS table--initially set |
Behdad Esfahbod | f45107f | 2009-05-17 20:13:02 -0400 | [diff] [blame] | 1867 | * to 0x00010000 */ |
| 1868 | OffsetTo<ScriptList> |
| 1869 | scriptList; /* ScriptList table */ |
| 1870 | OffsetTo<FeatureList> |
| 1871 | featureList; /* FeatureList table */ |
| 1872 | OffsetTo<LookupList> |
| 1873 | lookupList; /* LookupList table */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 1874 | public: |
| 1875 | DEFINE_SIZE_STATIC (10); |
Behdad Esfahbod | f45107f | 2009-05-17 20:13:02 -0400 | [diff] [blame] | 1876 | }; |
Behdad Esfahbod | 66bf7ce | 2009-05-17 08:28:42 -0400 | [diff] [blame] | 1877 | |
Behdad Esfahbod | 6f20f72 | 2009-05-17 20:28:01 -0400 | [diff] [blame] | 1878 | |
Behdad Esfahbod | 7d52e66 | 2012-11-16 18:49:54 -0800 | [diff] [blame] | 1879 | } /* namespace OT */ |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 1880 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 1881 | |
Behdad Esfahbod | 5f5b24f | 2009-08-02 20:03:12 -0400 | [diff] [blame] | 1882 | #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */ |