| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
| 3 * Copyright © 2010,2012 Google, Inc. | 3 * Copyright © 2010,2012 Google, Inc. |
| 4 * | 4 * |
| 5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
| 6 * | 6 * |
| 7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
| 8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
| 9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
| 10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 #ifndef HB_DEBUG_CLOSURE | 40 #ifndef HB_DEBUG_CLOSURE |
| 41 #define HB_DEBUG_CLOSURE (HB_DEBUG+0) | 41 #define HB_DEBUG_CLOSURE (HB_DEBUG+0) |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #define TRACE_CLOSURE(this) \ | 44 #define TRACE_CLOSURE(this) \ |
| 45 hb_auto_trace_t<HB_DEBUG_CLOSURE, hb_void_t> trace \ | 45 hb_auto_trace_t<HB_DEBUG_CLOSURE, hb_void_t> trace \ |
| 46 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ | 46 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 47 ""); | 47 ""); |
| 48 | 48 |
| 49 struct hb_closure_context_t | 49 struct hb_closure_context_t : |
| 50 hb_dispatch_context_t<hb_closure_context_t, hb_void_t, HB_DEBUG_CLOSURE> |
| 50 { | 51 { |
| 51 inline const char *get_name (void) { return "CLOSURE"; } | 52 inline const char *get_name (void) { return "CLOSURE"; } |
| 52 static const unsigned int max_debug_depth = HB_DEBUG_CLOSURE; | |
| 53 typedef hb_void_t return_t; | |
| 54 typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int look
up_index); | 53 typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int look
up_index); |
| 55 template <typename T, typename F> | |
| 56 inline bool may_dispatch (const T *obj, const F *format) { return true; } | |
| 57 template <typename T> | 54 template <typename T> |
| 58 inline return_t dispatch (const T &obj) { obj.closure (this); return HB_VOID;
} | 55 inline return_t dispatch (const T &obj) { obj.closure (this); return HB_VOID;
} |
| 59 static return_t default_return_value (void) { return HB_VOID; } | 56 static return_t default_return_value (void) { return HB_VOID; } |
| 60 bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; } | 57 bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; } |
| 61 return_t recurse (unsigned int lookup_index) | 58 return_t recurse (unsigned int lookup_index) |
| 62 { | 59 { |
| 63 if (unlikely (nesting_level_left == 0 || !recurse_func)) | 60 if (unlikely (nesting_level_left == 0 || !recurse_func)) |
| 64 return default_return_value (); | 61 return default_return_value (); |
| 65 | 62 |
| 66 nesting_level_left--; | 63 nesting_level_left--; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 | 88 |
| 92 #ifndef HB_DEBUG_WOULD_APPLY | 89 #ifndef HB_DEBUG_WOULD_APPLY |
| 93 #define HB_DEBUG_WOULD_APPLY (HB_DEBUG+0) | 90 #define HB_DEBUG_WOULD_APPLY (HB_DEBUG+0) |
| 94 #endif | 91 #endif |
| 95 | 92 |
| 96 #define TRACE_WOULD_APPLY(this) \ | 93 #define TRACE_WOULD_APPLY(this) \ |
| 97 hb_auto_trace_t<HB_DEBUG_WOULD_APPLY, bool> trace \ | 94 hb_auto_trace_t<HB_DEBUG_WOULD_APPLY, bool> trace \ |
| 98 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ | 95 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 99 "%d glyphs", c->len); | 96 "%d glyphs", c->len); |
| 100 | 97 |
| 101 struct hb_would_apply_context_t | 98 struct hb_would_apply_context_t : |
| 99 hb_dispatch_context_t<hb_would_apply_context_t, bool, HB_DEBUG_WOULD_APPL
Y> |
| 102 { | 100 { |
| 103 inline const char *get_name (void) { return "WOULD_APPLY"; } | 101 inline const char *get_name (void) { return "WOULD_APPLY"; } |
| 104 static const unsigned int max_debug_depth = HB_DEBUG_WOULD_APPLY; | |
| 105 typedef bool return_t; | |
| 106 template <typename T, typename F> | |
| 107 inline bool may_dispatch (const T *obj, const F *format) { return true; } | |
| 108 template <typename T> | 102 template <typename T> |
| 109 inline return_t dispatch (const T &obj) { return obj.would_apply (this); } | 103 inline return_t dispatch (const T &obj) { return obj.would_apply (this); } |
| 110 static return_t default_return_value (void) { return false; } | 104 static return_t default_return_value (void) { return false; } |
| 111 bool stop_sublookup_iteration (return_t r) const { return r; } | 105 bool stop_sublookup_iteration (return_t r) const { return r; } |
| 112 | 106 |
| 113 hb_face_t *face; | 107 hb_face_t *face; |
| 114 const hb_codepoint_t *glyphs; | 108 const hb_codepoint_t *glyphs; |
| 115 unsigned int len; | 109 unsigned int len; |
| 116 bool zero_context; | 110 bool zero_context; |
| 117 unsigned int debug_depth; | 111 unsigned int debug_depth; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 131 | 125 |
| 132 #ifndef HB_DEBUG_COLLECT_GLYPHS | 126 #ifndef HB_DEBUG_COLLECT_GLYPHS |
| 133 #define HB_DEBUG_COLLECT_GLYPHS (HB_DEBUG+0) | 127 #define HB_DEBUG_COLLECT_GLYPHS (HB_DEBUG+0) |
| 134 #endif | 128 #endif |
| 135 | 129 |
| 136 #define TRACE_COLLECT_GLYPHS(this) \ | 130 #define TRACE_COLLECT_GLYPHS(this) \ |
| 137 hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS, hb_void_t> trace \ | 131 hb_auto_trace_t<HB_DEBUG_COLLECT_GLYPHS, hb_void_t> trace \ |
| 138 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ | 132 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 139 ""); | 133 ""); |
| 140 | 134 |
| 141 struct hb_collect_glyphs_context_t | 135 struct hb_collect_glyphs_context_t : |
| 136 hb_dispatch_context_t<hb_collect_glyphs_context_t, hb_void_t, HB_DEBUG_CO
LLECT_GLYPHS> |
| 142 { | 137 { |
| 143 inline const char *get_name (void) { return "COLLECT_GLYPHS"; } | 138 inline const char *get_name (void) { return "COLLECT_GLYPHS"; } |
| 144 static const unsigned int max_debug_depth = HB_DEBUG_COLLECT_GLYPHS; | |
| 145 typedef hb_void_t return_t; | |
| 146 typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned i
nt lookup_index); | 139 typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned i
nt lookup_index); |
| 147 template <typename T, typename F> | |
| 148 inline bool may_dispatch (const T *obj, const F *format) { return true; } | |
| 149 template <typename T> | 140 template <typename T> |
| 150 inline return_t dispatch (const T &obj) { obj.collect_glyphs (this); return HB
_VOID; } | 141 inline return_t dispatch (const T &obj) { obj.collect_glyphs (this); return HB
_VOID; } |
| 151 static return_t default_return_value (void) { return HB_VOID; } | 142 static return_t default_return_value (void) { return HB_VOID; } |
| 152 bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; } | 143 bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; } |
| 153 return_t recurse (unsigned int lookup_index) | 144 return_t recurse (unsigned int lookup_index) |
| 154 { | 145 { |
| 155 if (unlikely (nesting_level_left == 0 || !recurse_func)) | 146 if (unlikely (nesting_level_left == 0 || !recurse_func)) |
| 156 return default_return_value (); | 147 return default_return_value (); |
| 157 | 148 |
| 158 /* Note that GPOS sets recurse_func to NULL already, so it doesn't get | 149 /* Note that GPOS sets recurse_func to NULL already, so it doesn't get |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 216 |
| 226 void set_recurse_func (recurse_func_t func) { recurse_func = func; } | 217 void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
| 227 }; | 218 }; |
| 228 | 219 |
| 229 | 220 |
| 230 | 221 |
| 231 #ifndef HB_DEBUG_GET_COVERAGE | 222 #ifndef HB_DEBUG_GET_COVERAGE |
| 232 #define HB_DEBUG_GET_COVERAGE (HB_DEBUG+0) | 223 #define HB_DEBUG_GET_COVERAGE (HB_DEBUG+0) |
| 233 #endif | 224 #endif |
| 234 | 225 |
| 226 /* XXX Can we remove this? */ |
| 227 |
| 235 template <typename set_t> | 228 template <typename set_t> |
| 236 struct hb_add_coverage_context_t | 229 struct hb_add_coverage_context_t : |
| 230 hb_dispatch_context_t<hb_add_coverage_context_t<set_t>, const Coverage &,
HB_DEBUG_GET_COVERAGE> |
| 237 { | 231 { |
| 238 inline const char *get_name (void) { return "GET_COVERAGE"; } | 232 inline const char *get_name (void) { return "GET_COVERAGE"; } |
| 239 static const unsigned int max_debug_depth = HB_DEBUG_GET_COVERAGE; | |
| 240 typedef const Coverage &return_t; | 233 typedef const Coverage &return_t; |
| 241 template <typename T, typename F> | |
| 242 inline bool may_dispatch (const T *obj, const F *format) { return true; } | |
| 243 template <typename T> | 234 template <typename T> |
| 244 inline return_t dispatch (const T &obj) { return obj.get_coverage (); } | 235 inline return_t dispatch (const T &obj) { return obj.get_coverage (); } |
| 245 static return_t default_return_value (void) { return Null(Coverage); } | 236 static return_t default_return_value (void) { return Null(Coverage); } |
| 246 bool stop_sublookup_iteration (return_t r) const | 237 bool stop_sublookup_iteration (return_t r) const |
| 247 { | 238 { |
| 248 r.add_coverage (set); | 239 r.add_coverage (set); |
| 249 return false; | 240 return false; |
| 250 } | 241 } |
| 251 | 242 |
| 252 hb_add_coverage_context_t (set_t *set_) : | 243 hb_add_coverage_context_t (set_t *set_) : |
| 253 set (set_), | 244 set (set_), |
| 254 debug_depth (0) {} | 245 debug_depth (0) {} |
| 255 | 246 |
| 256 set_t *set; | 247 set_t *set; |
| 257 unsigned int debug_depth; | 248 unsigned int debug_depth; |
| 258 }; | 249 }; |
| 259 | 250 |
| 260 | 251 |
| 261 | 252 |
| 262 #ifndef HB_DEBUG_APPLY | 253 #ifndef HB_DEBUG_APPLY |
| 263 #define HB_DEBUG_APPLY (HB_DEBUG+0) | 254 #define HB_DEBUG_APPLY (HB_DEBUG+0) |
| 264 #endif | 255 #endif |
| 265 | 256 |
| 266 #define TRACE_APPLY(this) \ | 257 #define TRACE_APPLY(this) \ |
| 267 hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \ | 258 hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \ |
| 268 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ | 259 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
| 269 "idx %d gid %u lookup %d", \ | 260 "idx %d gid %u lookup %d", \ |
| 270 c->buffer->idx, c->buffer->cur().codepoint, (int) c->lookup_index); | 261 c->buffer->idx, c->buffer->cur().codepoint, (int) c->lookup_index); |
| 271 | 262 |
| 272 struct hb_apply_context_t | 263 struct hb_apply_context_t : |
| 264 hb_dispatch_context_t<hb_apply_context_t, bool, HB_DEBUG_APPLY> |
| 273 { | 265 { |
| 274 struct matcher_t | 266 struct matcher_t |
| 275 { | 267 { |
| 276 inline matcher_t (void) : | 268 inline matcher_t (void) : |
| 277 lookup_props (0), | 269 lookup_props (0), |
| 278 ignore_zwnj (false), | 270 ignore_zwnj (false), |
| 279 ignore_zwj (false), | 271 ignore_zwj (false), |
| 280 mask (-1), | 272 mask (-1), |
| 281 #define arg1(arg) (arg) /* Remove the macro to see why it's needed! */ | 273 #define arg1(arg) (arg) /* Remove the macro to see why it's needed! */ |
| 282 syllable arg1(0), | 274 syllable arg1(0), |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 hb_apply_context_t *c; | 434 hb_apply_context_t *c; |
| 443 matcher_t matcher; | 435 matcher_t matcher; |
| 444 const USHORT *match_glyph_data; | 436 const USHORT *match_glyph_data; |
| 445 | 437 |
| 446 unsigned int num_items; | 438 unsigned int num_items; |
| 447 unsigned int end; | 439 unsigned int end; |
| 448 }; | 440 }; |
| 449 | 441 |
| 450 | 442 |
| 451 inline const char *get_name (void) { return "APPLY"; } | 443 inline const char *get_name (void) { return "APPLY"; } |
| 452 static const unsigned int max_debug_depth = HB_DEBUG_APPLY; | |
| 453 typedef bool return_t; | |
| 454 typedef return_t (*recurse_func_t) (hb_apply_context_t *c, unsigned int lookup
_index); | 444 typedef return_t (*recurse_func_t) (hb_apply_context_t *c, unsigned int lookup
_index); |
| 455 template <typename T, typename F> | |
| 456 inline bool may_dispatch (const T *obj, const F *format) { return true; } | |
| 457 template <typename T> | 445 template <typename T> |
| 458 inline return_t dispatch (const T &obj) { return obj.apply (this); } | 446 inline return_t dispatch (const T &obj) { return obj.apply (this); } |
| 459 static return_t default_return_value (void) { return false; } | 447 static return_t default_return_value (void) { return false; } |
| 460 bool stop_sublookup_iteration (return_t r) const { return r; } | 448 bool stop_sublookup_iteration (return_t r) const { return r; } |
| 461 return_t recurse (unsigned int lookup_index) | 449 return_t recurse (unsigned int lookup_index) |
| 462 { | 450 { |
| 463 if (unlikely (nesting_level_left == 0 || !recurse_func)) | 451 if (unlikely (nesting_level_left == 0 || !recurse_func)) |
| 464 return default_return_value (); | 452 return default_return_value (); |
| 465 | 453 |
| 466 nesting_level_left--; | 454 nesting_level_left--; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 const USHORT input[], /* Array of input values--
start with second glyph */ | 703 const USHORT input[], /* Array of input values--
start with second glyph */ |
| 716 match_func_t match_func, | 704 match_func_t match_func, |
| 717 const void *match_data, | 705 const void *match_data, |
| 718 unsigned int *end_offset, | 706 unsigned int *end_offset, |
| 719 unsigned int match_positions[MAX_CONTEXT_LENGTH]
, | 707 unsigned int match_positions[MAX_CONTEXT_LENGTH]
, |
| 720 bool *p_is_mark_ligature = NULL, | 708 bool *p_is_mark_ligature = NULL, |
| 721 unsigned int *p_total_component_count = NULL) | 709 unsigned int *p_total_component_count = NULL) |
| 722 { | 710 { |
| 723 TRACE_APPLY (NULL); | 711 TRACE_APPLY (NULL); |
| 724 | 712 |
| 725 if (unlikely (count > MAX_CONTEXT_LENGTH)) return TRACE_RETURN (false); | 713 if (unlikely (count > MAX_CONTEXT_LENGTH)) return_trace (false); |
| 726 | 714 |
| 727 hb_buffer_t *buffer = c->buffer; | 715 hb_buffer_t *buffer = c->buffer; |
| 728 | 716 |
| 729 hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; | 717 hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; |
| 730 skippy_iter.reset (buffer->idx, count - 1); | 718 skippy_iter.reset (buffer->idx, count - 1); |
| 731 skippy_iter.set_match_func (match_func, match_data, input); | 719 skippy_iter.set_match_func (match_func, match_data, input); |
| 732 | 720 |
| 733 /* | 721 /* |
| 734 * This is perhaps the trickiest part of OpenType... Remarks: | 722 * This is perhaps the trickiest part of OpenType... Remarks: |
| 735 * | 723 * |
| (...skipping 16 matching lines...) Expand all Loading... |
| 752 | 740 |
| 753 unsigned int total_component_count = 0; | 741 unsigned int total_component_count = 0; |
| 754 total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur()); | 742 total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur()); |
| 755 | 743 |
| 756 unsigned int first_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); | 744 unsigned int first_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); |
| 757 unsigned int first_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); | 745 unsigned int first_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); |
| 758 | 746 |
| 759 match_positions[0] = buffer->idx; | 747 match_positions[0] = buffer->idx; |
| 760 for (unsigned int i = 1; i < count; i++) | 748 for (unsigned int i = 1; i < count; i++) |
| 761 { | 749 { |
| 762 if (!skippy_iter.next ()) return TRACE_RETURN (false); | 750 if (!skippy_iter.next ()) return_trace (false); |
| 763 | 751 |
| 764 match_positions[i] = skippy_iter.idx; | 752 match_positions[i] = skippy_iter.idx; |
| 765 | 753 |
| 766 unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[skippy_i
ter.idx]); | 754 unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[skippy_i
ter.idx]); |
| 767 unsigned int this_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->info[skip
py_iter.idx]); | 755 unsigned int this_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->info[skip
py_iter.idx]); |
| 768 | 756 |
| 769 if (first_lig_id && first_lig_comp) { | 757 if (first_lig_id && first_lig_comp) { |
| 770 /* If first component was attached to a previous ligature component, | 758 /* If first component was attached to a previous ligature component, |
| 771 * all subsequent components should be attached to the same ligature | 759 * all subsequent components should be attached to the same ligature |
| 772 * component, otherwise we shouldn't ligate them. */ | 760 * component, otherwise we shouldn't ligate them. */ |
| 773 if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp) | 761 if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp) |
| 774 » return TRACE_RETURN (false); | 762 » return_trace (false); |
| 775 } else { | 763 } else { |
| 776 /* If first component was NOT attached to a previous ligature component, | 764 /* If first component was NOT attached to a previous ligature component, |
| 777 * all subsequent components should also NOT be attached to any ligature | 765 * all subsequent components should also NOT be attached to any ligature |
| 778 * component, unless they are attached to the first component itself! */ | 766 * component, unless they are attached to the first component itself! */ |
| 779 if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id)) | 767 if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id)) |
| 780 » return TRACE_RETURN (false); | 768 » return_trace (false); |
| 781 } | 769 } |
| 782 | 770 |
| 783 is_mark_ligature = is_mark_ligature && _hb_glyph_info_is_mark (&buffer->info
[skippy_iter.idx]); | 771 is_mark_ligature = is_mark_ligature && _hb_glyph_info_is_mark (&buffer->info
[skippy_iter.idx]); |
| 784 total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[ski
ppy_iter.idx]); | 772 total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[ski
ppy_iter.idx]); |
| 785 } | 773 } |
| 786 | 774 |
| 787 *end_offset = skippy_iter.idx - buffer->idx + 1; | 775 *end_offset = skippy_iter.idx - buffer->idx + 1; |
| 788 | 776 |
| 789 if (p_is_mark_ligature) | 777 if (p_is_mark_ligature) |
| 790 *p_is_mark_ligature = is_mark_ligature; | 778 *p_is_mark_ligature = is_mark_ligature; |
| 791 | 779 |
| 792 if (p_total_component_count) | 780 if (p_total_component_count) |
| 793 *p_total_component_count = total_component_count; | 781 *p_total_component_count = total_component_count; |
| 794 | 782 |
| 795 return TRACE_RETURN (true); | 783 return_trace (true); |
| 796 } | 784 } |
| 797 static inline void ligate_input (hb_apply_context_t *c, | 785 static inline bool ligate_input (hb_apply_context_t *c, |
| 798 unsigned int count, /* Including the first glyp
h */ | 786 unsigned int count, /* Including the first glyp
h */ |
| 799 unsigned int match_positions[MAX_CONTEXT_LENGTH
], /* Including the first glyph */ | 787 unsigned int match_positions[MAX_CONTEXT_LENGTH
], /* Including the first glyph */ |
| 800 unsigned int match_length, | 788 unsigned int match_length, |
| 801 hb_codepoint_t lig_glyph, | 789 hb_codepoint_t lig_glyph, |
| 802 bool is_mark_ligature, | 790 bool is_mark_ligature, |
| 803 unsigned int total_component_count) | 791 unsigned int total_component_count) |
| 804 { | 792 { |
| 805 TRACE_APPLY (NULL); | 793 TRACE_APPLY (NULL); |
| 806 | 794 |
| 807 hb_buffer_t *buffer = c->buffer; | 795 hb_buffer_t *buffer = c->buffer; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 /* Re-adjust components for any marks following. */ | 865 /* Re-adjust components for any marks following. */ |
| 878 for (unsigned int i = buffer->idx; i < buffer->len; i++) { | 866 for (unsigned int i = buffer->idx; i < buffer->len; i++) { |
| 879 if (last_lig_id == _hb_glyph_info_get_lig_id (&buffer->info[i])) { | 867 if (last_lig_id == _hb_glyph_info_get_lig_id (&buffer->info[i])) { |
| 880 unsigned int new_lig_comp = components_so_far - last_num_components + | 868 unsigned int new_lig_comp = components_so_far - last_num_components + |
| 881 MIN (MAX (_hb_glyph_info_get_lig_comp (&buff
er->info[i]), 1u), last_num_components); | 869 MIN (MAX (_hb_glyph_info_get_lig_comp (&buff
er->info[i]), 1u), last_num_components); |
| 882 _hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig
_comp); | 870 _hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig
_comp); |
| 883 } else | 871 } else |
| 884 break; | 872 break; |
| 885 } | 873 } |
| 886 } | 874 } |
| 887 TRACE_RETURN (true); | 875 return_trace (true); |
| 888 } | 876 } |
| 889 | 877 |
| 890 static inline bool match_backtrack (hb_apply_context_t *c, | 878 static inline bool match_backtrack (hb_apply_context_t *c, |
| 891 unsigned int count, | 879 unsigned int count, |
| 892 const USHORT backtrack[], | 880 const USHORT backtrack[], |
| 893 match_func_t match_func, | 881 match_func_t match_func, |
| 894 const void *match_data) | 882 const void *match_data) |
| 895 { | 883 { |
| 896 TRACE_APPLY (NULL); | 884 TRACE_APPLY (NULL); |
| 897 | 885 |
| 898 hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; | 886 hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; |
| 899 skippy_iter.reset (c->buffer->backtrack_len (), count); | 887 skippy_iter.reset (c->buffer->backtrack_len (), count); |
| 900 skippy_iter.set_match_func (match_func, match_data, backtrack); | 888 skippy_iter.set_match_func (match_func, match_data, backtrack); |
| 901 | 889 |
| 902 for (unsigned int i = 0; i < count; i++) | 890 for (unsigned int i = 0; i < count; i++) |
| 903 if (!skippy_iter.prev ()) | 891 if (!skippy_iter.prev ()) |
| 904 return TRACE_RETURN (false); | 892 return_trace (false); |
| 905 | 893 |
| 906 return TRACE_RETURN (true); | 894 return_trace (true); |
| 907 } | 895 } |
| 908 | 896 |
| 909 static inline bool match_lookahead (hb_apply_context_t *c, | 897 static inline bool match_lookahead (hb_apply_context_t *c, |
| 910 unsigned int count, | 898 unsigned int count, |
| 911 const USHORT lookahead[], | 899 const USHORT lookahead[], |
| 912 match_func_t match_func, | 900 match_func_t match_func, |
| 913 const void *match_data, | 901 const void *match_data, |
| 914 unsigned int offset) | 902 unsigned int offset) |
| 915 { | 903 { |
| 916 TRACE_APPLY (NULL); | 904 TRACE_APPLY (NULL); |
| 917 | 905 |
| 918 hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; | 906 hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; |
| 919 skippy_iter.reset (c->buffer->idx + offset - 1, count); | 907 skippy_iter.reset (c->buffer->idx + offset - 1, count); |
| 920 skippy_iter.set_match_func (match_func, match_data, lookahead); | 908 skippy_iter.set_match_func (match_func, match_data, lookahead); |
| 921 | 909 |
| 922 for (unsigned int i = 0; i < count; i++) | 910 for (unsigned int i = 0; i < count; i++) |
| 923 if (!skippy_iter.next ()) | 911 if (!skippy_iter.next ()) |
| 924 return TRACE_RETURN (false); | 912 return_trace (false); |
| 925 | 913 |
| 926 return TRACE_RETURN (true); | 914 return_trace (true); |
| 927 } | 915 } |
| 928 | 916 |
| 929 | 917 |
| 930 | 918 |
| 931 struct LookupRecord | 919 struct LookupRecord |
| 932 { | 920 { |
| 933 inline bool sanitize (hb_sanitize_context_t *c) const | 921 inline bool sanitize (hb_sanitize_context_t *c) const |
| 934 { | 922 { |
| 935 TRACE_SANITIZE (this); | 923 TRACE_SANITIZE (this); |
| 936 return TRACE_RETURN (c->check_struct (this)); | 924 return_trace (c->check_struct (this)); |
| 937 } | 925 } |
| 938 | 926 |
| 939 USHORT sequenceIndex; /* Index into current glyph | 927 USHORT sequenceIndex; /* Index into current glyph |
| 940 * sequence--first glyph = 0 */ | 928 * sequence--first glyph = 0 */ |
| 941 USHORT lookupListIndex; /* Lookup to apply to that | 929 USHORT lookupListIndex; /* Lookup to apply to that |
| 942 * position--zero--based */ | 930 * position--zero--based */ |
| 943 public: | 931 public: |
| 944 DEFINE_SIZE_STATIC (4); | 932 DEFINE_SIZE_STATIC (4); |
| 945 }; | 933 }; |
| 946 | 934 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 for (unsigned int j = idx + 1; j < next; j++) | 1015 for (unsigned int j = idx + 1; j < next; j++) |
| 1028 match_positions[j] = match_positions[j - 1] + 1; | 1016 match_positions[j] = match_positions[j - 1] + 1; |
| 1029 | 1017 |
| 1030 /* And fixup the rest. */ | 1018 /* And fixup the rest. */ |
| 1031 for (; next < count; next++) | 1019 for (; next < count; next++) |
| 1032 match_positions[next] += delta; | 1020 match_positions[next] += delta; |
| 1033 } | 1021 } |
| 1034 | 1022 |
| 1035 buffer->move_to (end); | 1023 buffer->move_to (end); |
| 1036 | 1024 |
| 1037 return TRACE_RETURN (true); | 1025 return_trace (true); |
| 1038 } | 1026 } |
| 1039 | 1027 |
| 1040 | 1028 |
| 1041 | 1029 |
| 1042 /* Contextual lookups */ | 1030 /* Contextual lookups */ |
| 1043 | 1031 |
| 1044 struct ContextClosureLookupContext | 1032 struct ContextClosureLookupContext |
| 1045 { | 1033 { |
| 1046 ContextClosureFuncs funcs; | 1034 ContextClosureFuncs funcs; |
| 1047 const void *intersects_data; | 1035 const void *intersects_data; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 context_collect_glyphs_lookup (c, | 1124 context_collect_glyphs_lookup (c, |
| 1137 inputCount, inputZ, | 1125 inputCount, inputZ, |
| 1138 lookupCount, lookupRecord, | 1126 lookupCount, lookupRecord, |
| 1139 lookup_context); | 1127 lookup_context); |
| 1140 } | 1128 } |
| 1141 | 1129 |
| 1142 inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContex
t &lookup_context) const | 1130 inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContex
t &lookup_context) const |
| 1143 { | 1131 { |
| 1144 TRACE_WOULD_APPLY (this); | 1132 TRACE_WOULD_APPLY (this); |
| 1145 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, in
putZ[0].static_size * (inputCount ? inputCount - 1 : 0)); | 1133 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, in
putZ[0].static_size * (inputCount ? inputCount - 1 : 0)); |
| 1146 return TRACE_RETURN (context_would_apply_lookup (c, inputCount, inputZ, look
upCount, lookupRecord, lookup_context)); | 1134 return_trace (context_would_apply_lookup (c, inputCount, inputZ, lookupCount
, lookupRecord, lookup_context)); |
| 1147 } | 1135 } |
| 1148 | 1136 |
| 1149 inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_co
ntext) const | 1137 inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_co
ntext) const |
| 1150 { | 1138 { |
| 1151 TRACE_APPLY (this); | 1139 TRACE_APPLY (this); |
| 1152 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, in
putZ[0].static_size * (inputCount ? inputCount - 1 : 0)); | 1140 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, in
putZ[0].static_size * (inputCount ? inputCount - 1 : 0)); |
| 1153 return TRACE_RETURN (context_apply_lookup (c, inputCount, inputZ, lookupCoun
t, lookupRecord, lookup_context)); | 1141 return_trace (context_apply_lookup (c, inputCount, inputZ, lookupCount, look
upRecord, lookup_context)); |
| 1154 } | 1142 } |
| 1155 | 1143 |
| 1156 public: | 1144 public: |
| 1157 inline bool sanitize (hb_sanitize_context_t *c) const | 1145 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1158 { | 1146 { |
| 1159 TRACE_SANITIZE (this); | 1147 TRACE_SANITIZE (this); |
| 1160 return inputCount.sanitize (c) | 1148 return inputCount.sanitize (c) |
| 1161 && lookupCount.sanitize (c) | 1149 && lookupCount.sanitize (c) |
| 1162 && c->check_range (inputZ, | 1150 && c->check_range (inputZ, |
| 1163 inputZ[0].static_size * inputCount | 1151 inputZ[0].static_size * inputCount |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 (this+rule[i]).collect_glyphs (c, lookup_context); | 1183 (this+rule[i]).collect_glyphs (c, lookup_context); |
| 1196 } | 1184 } |
| 1197 | 1185 |
| 1198 inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContex
t &lookup_context) const | 1186 inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContex
t &lookup_context) const |
| 1199 { | 1187 { |
| 1200 TRACE_WOULD_APPLY (this); | 1188 TRACE_WOULD_APPLY (this); |
| 1201 unsigned int num_rules = rule.len; | 1189 unsigned int num_rules = rule.len; |
| 1202 for (unsigned int i = 0; i < num_rules; i++) | 1190 for (unsigned int i = 0; i < num_rules; i++) |
| 1203 { | 1191 { |
| 1204 if ((this+rule[i]).would_apply (c, lookup_context)) | 1192 if ((this+rule[i]).would_apply (c, lookup_context)) |
| 1205 return TRACE_RETURN (true); | 1193 return_trace (true); |
| 1206 } | 1194 } |
| 1207 return TRACE_RETURN (false); | 1195 return_trace (false); |
| 1208 } | 1196 } |
| 1209 | 1197 |
| 1210 inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_co
ntext) const | 1198 inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_co
ntext) const |
| 1211 { | 1199 { |
| 1212 TRACE_APPLY (this); | 1200 TRACE_APPLY (this); |
| 1213 unsigned int num_rules = rule.len; | 1201 unsigned int num_rules = rule.len; |
| 1214 for (unsigned int i = 0; i < num_rules; i++) | 1202 for (unsigned int i = 0; i < num_rules; i++) |
| 1215 { | 1203 { |
| 1216 if ((this+rule[i]).apply (c, lookup_context)) | 1204 if ((this+rule[i]).apply (c, lookup_context)) |
| 1217 return TRACE_RETURN (true); | 1205 return_trace (true); |
| 1218 } | 1206 } |
| 1219 return TRACE_RETURN (false); | 1207 return_trace (false); |
| 1220 } | 1208 } |
| 1221 | 1209 |
| 1222 inline bool sanitize (hb_sanitize_context_t *c) const | 1210 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1223 { | 1211 { |
| 1224 TRACE_SANITIZE (this); | 1212 TRACE_SANITIZE (this); |
| 1225 return TRACE_RETURN (rule.sanitize (c, this)); | 1213 return_trace (rule.sanitize (c, this)); |
| 1226 } | 1214 } |
| 1227 | 1215 |
| 1228 protected: | 1216 protected: |
| 1229 OffsetArrayOf<Rule> | 1217 OffsetArrayOf<Rule> |
| 1230 rule; /* Array of Rule tables | 1218 rule; /* Array of Rule tables |
| 1231 * ordered by preference */ | 1219 * ordered by preference */ |
| 1232 public: | 1220 public: |
| 1233 DEFINE_SIZE_ARRAY (2, rule); | 1221 DEFINE_SIZE_ARRAY (2, rule); |
| 1234 }; | 1222 }; |
| 1235 | 1223 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 | 1260 |
| 1273 inline bool would_apply (hb_would_apply_context_t *c) const | 1261 inline bool would_apply (hb_would_apply_context_t *c) const |
| 1274 { | 1262 { |
| 1275 TRACE_WOULD_APPLY (this); | 1263 TRACE_WOULD_APPLY (this); |
| 1276 | 1264 |
| 1277 const RuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyp
hs[0])]; | 1265 const RuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyp
hs[0])]; |
| 1278 struct ContextApplyLookupContext lookup_context = { | 1266 struct ContextApplyLookupContext lookup_context = { |
| 1279 {match_glyph}, | 1267 {match_glyph}, |
| 1280 NULL | 1268 NULL |
| 1281 }; | 1269 }; |
| 1282 return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); | 1270 return_trace (rule_set.would_apply (c, lookup_context)); |
| 1283 } | 1271 } |
| 1284 | 1272 |
| 1285 inline const Coverage &get_coverage (void) const | 1273 inline const Coverage &get_coverage (void) const |
| 1286 { | 1274 { |
| 1287 return this+coverage; | 1275 return this+coverage; |
| 1288 } | 1276 } |
| 1289 | 1277 |
| 1290 inline bool apply (hb_apply_context_t *c) const | 1278 inline bool apply (hb_apply_context_t *c) const |
| 1291 { | 1279 { |
| 1292 TRACE_APPLY (this); | 1280 TRACE_APPLY (this); |
| 1293 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); | 1281 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); |
| 1294 if (likely (index == NOT_COVERED)) | 1282 if (likely (index == NOT_COVERED)) |
| 1295 return TRACE_RETURN (false); | 1283 return_trace (false); |
| 1296 | 1284 |
| 1297 const RuleSet &rule_set = this+ruleSet[index]; | 1285 const RuleSet &rule_set = this+ruleSet[index]; |
| 1298 struct ContextApplyLookupContext lookup_context = { | 1286 struct ContextApplyLookupContext lookup_context = { |
| 1299 {match_glyph}, | 1287 {match_glyph}, |
| 1300 NULL | 1288 NULL |
| 1301 }; | 1289 }; |
| 1302 return TRACE_RETURN (rule_set.apply (c, lookup_context)); | 1290 return_trace (rule_set.apply (c, lookup_context)); |
| 1303 } | 1291 } |
| 1304 | 1292 |
| 1305 inline bool sanitize (hb_sanitize_context_t *c) const | 1293 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1306 { | 1294 { |
| 1307 TRACE_SANITIZE (this); | 1295 TRACE_SANITIZE (this); |
| 1308 return TRACE_RETURN (coverage.sanitize (c, this) && ruleSet.sanitize (c, thi
s)); | 1296 return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); |
| 1309 } | 1297 } |
| 1310 | 1298 |
| 1311 protected: | 1299 protected: |
| 1312 USHORT format; /* Format identifier--format = 1 */ | 1300 USHORT format; /* Format identifier--format = 1 */ |
| 1313 OffsetTo<Coverage> | 1301 OffsetTo<Coverage> |
| 1314 coverage; /* Offset to Coverage table--from | 1302 coverage; /* Offset to Coverage table--from |
| 1315 * beginning of table */ | 1303 * beginning of table */ |
| 1316 OffsetArrayOf<RuleSet> | 1304 OffsetArrayOf<RuleSet> |
| 1317 ruleSet; /* Array of RuleSet tables | 1305 ruleSet; /* Array of RuleSet tables |
| 1318 * ordered by Coverage Index */ | 1306 * ordered by Coverage Index */ |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 { | 1352 { |
| 1365 TRACE_WOULD_APPLY (this); | 1353 TRACE_WOULD_APPLY (this); |
| 1366 | 1354 |
| 1367 const ClassDef &class_def = this+classDef; | 1355 const ClassDef &class_def = this+classDef; |
| 1368 unsigned int index = class_def.get_class (c->glyphs[0]); | 1356 unsigned int index = class_def.get_class (c->glyphs[0]); |
| 1369 const RuleSet &rule_set = this+ruleSet[index]; | 1357 const RuleSet &rule_set = this+ruleSet[index]; |
| 1370 struct ContextApplyLookupContext lookup_context = { | 1358 struct ContextApplyLookupContext lookup_context = { |
| 1371 {match_class}, | 1359 {match_class}, |
| 1372 &class_def | 1360 &class_def |
| 1373 }; | 1361 }; |
| 1374 return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); | 1362 return_trace (rule_set.would_apply (c, lookup_context)); |
| 1375 } | 1363 } |
| 1376 | 1364 |
| 1377 inline const Coverage &get_coverage (void) const | 1365 inline const Coverage &get_coverage (void) const |
| 1378 { | 1366 { |
| 1379 return this+coverage; | 1367 return this+coverage; |
| 1380 } | 1368 } |
| 1381 | 1369 |
| 1382 inline bool apply (hb_apply_context_t *c) const | 1370 inline bool apply (hb_apply_context_t *c) const |
| 1383 { | 1371 { |
| 1384 TRACE_APPLY (this); | 1372 TRACE_APPLY (this); |
| 1385 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); | 1373 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); |
| 1386 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 1374 if (likely (index == NOT_COVERED)) return_trace (false); |
| 1387 | 1375 |
| 1388 const ClassDef &class_def = this+classDef; | 1376 const ClassDef &class_def = this+classDef; |
| 1389 index = class_def.get_class (c->buffer->cur().codepoint); | 1377 index = class_def.get_class (c->buffer->cur().codepoint); |
| 1390 const RuleSet &rule_set = this+ruleSet[index]; | 1378 const RuleSet &rule_set = this+ruleSet[index]; |
| 1391 struct ContextApplyLookupContext lookup_context = { | 1379 struct ContextApplyLookupContext lookup_context = { |
| 1392 {match_class}, | 1380 {match_class}, |
| 1393 &class_def | 1381 &class_def |
| 1394 }; | 1382 }; |
| 1395 return TRACE_RETURN (rule_set.apply (c, lookup_context)); | 1383 return_trace (rule_set.apply (c, lookup_context)); |
| 1396 } | 1384 } |
| 1397 | 1385 |
| 1398 inline bool sanitize (hb_sanitize_context_t *c) const | 1386 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1399 { | 1387 { |
| 1400 TRACE_SANITIZE (this); | 1388 TRACE_SANITIZE (this); |
| 1401 return TRACE_RETURN (coverage.sanitize (c, this) && classDef.sanitize (c, th
is) && ruleSet.sanitize (c, this)); | 1389 return_trace (coverage.sanitize (c, this) && classDef.sanitize (c, this) &&
ruleSet.sanitize (c, this)); |
| 1402 } | 1390 } |
| 1403 | 1391 |
| 1404 protected: | 1392 protected: |
| 1405 USHORT format; /* Format identifier--format = 2 */ | 1393 USHORT format; /* Format identifier--format = 2 */ |
| 1406 OffsetTo<Coverage> | 1394 OffsetTo<Coverage> |
| 1407 coverage; /* Offset to Coverage table--from | 1395 coverage; /* Offset to Coverage table--from |
| 1408 * beginning of table */ | 1396 * beginning of table */ |
| 1409 OffsetTo<ClassDef> | 1397 OffsetTo<ClassDef> |
| 1410 classDef; /* Offset to glyph ClassDef table--from | 1398 classDef; /* Offset to glyph ClassDef table--from |
| 1411 * beginning of table */ | 1399 * beginning of table */ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 | 1443 |
| 1456 inline bool would_apply (hb_would_apply_context_t *c) const | 1444 inline bool would_apply (hb_would_apply_context_t *c) const |
| 1457 { | 1445 { |
| 1458 TRACE_WOULD_APPLY (this); | 1446 TRACE_WOULD_APPLY (this); |
| 1459 | 1447 |
| 1460 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ,
coverageZ[0].static_size * glyphCount); | 1448 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ,
coverageZ[0].static_size * glyphCount); |
| 1461 struct ContextApplyLookupContext lookup_context = { | 1449 struct ContextApplyLookupContext lookup_context = { |
| 1462 {match_coverage}, | 1450 {match_coverage}, |
| 1463 this | 1451 this |
| 1464 }; | 1452 }; |
| 1465 return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHOR
T *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context)); | 1453 return_trace (context_would_apply_lookup (c, glyphCount, (const USHORT *) (c
overageZ + 1), lookupCount, lookupRecord, lookup_context)); |
| 1466 } | 1454 } |
| 1467 | 1455 |
| 1468 inline const Coverage &get_coverage (void) const | 1456 inline const Coverage &get_coverage (void) const |
| 1469 { | 1457 { |
| 1470 return this+coverageZ[0]; | 1458 return this+coverageZ[0]; |
| 1471 } | 1459 } |
| 1472 | 1460 |
| 1473 inline bool apply (hb_apply_context_t *c) const | 1461 inline bool apply (hb_apply_context_t *c) const |
| 1474 { | 1462 { |
| 1475 TRACE_APPLY (this); | 1463 TRACE_APPLY (this); |
| 1476 unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().code
point); | 1464 unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().code
point); |
| 1477 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 1465 if (likely (index == NOT_COVERED)) return_trace (false); |
| 1478 | 1466 |
| 1479 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ,
coverageZ[0].static_size * glyphCount); | 1467 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ,
coverageZ[0].static_size * glyphCount); |
| 1480 struct ContextApplyLookupContext lookup_context = { | 1468 struct ContextApplyLookupContext lookup_context = { |
| 1481 {match_coverage}, | 1469 {match_coverage}, |
| 1482 this | 1470 this |
| 1483 }; | 1471 }; |
| 1484 return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (
coverageZ + 1), lookupCount, lookupRecord, lookup_context)); | 1472 return_trace (context_apply_lookup (c, glyphCount, (const USHORT *) (coverag
eZ + 1), lookupCount, lookupRecord, lookup_context)); |
| 1485 } | 1473 } |
| 1486 | 1474 |
| 1487 inline bool sanitize (hb_sanitize_context_t *c) const | 1475 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1488 { | 1476 { |
| 1489 TRACE_SANITIZE (this); | 1477 TRACE_SANITIZE (this); |
| 1490 if (!c->check_struct (this)) return TRACE_RETURN (false); | 1478 if (!c->check_struct (this)) return_trace (false); |
| 1491 unsigned int count = glyphCount; | 1479 unsigned int count = glyphCount; |
| 1492 if (!count) return TRACE_RETURN (false); /* We want to access coverageZ[0] f
reely. */ | 1480 if (!count) return_trace (false); /* We want to access coverageZ[0] freely.
*/ |
| 1493 if (!c->check_array (coverageZ, coverageZ[0].static_size, count)) return TRA
CE_RETURN (false); | 1481 if (!c->check_array (coverageZ, coverageZ[0].static_size, count)) return_tra
ce (false); |
| 1494 for (unsigned int i = 0; i < count; i++) | 1482 for (unsigned int i = 0; i < count; i++) |
| 1495 if (!coverageZ[i].sanitize (c, this)) return TRACE_RETURN (false); | 1483 if (!coverageZ[i].sanitize (c, this)) return_trace (false); |
| 1496 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ,
coverageZ[0].static_size * count); | 1484 const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ,
coverageZ[0].static_size * count); |
| 1497 return TRACE_RETURN (c->check_array (lookupRecord, lookupRecord[0].static_si
ze, lookupCount)); | 1485 return_trace (c->check_array (lookupRecord, lookupRecord[0].static_size, loo
kupCount)); |
| 1498 } | 1486 } |
| 1499 | 1487 |
| 1500 protected: | 1488 protected: |
| 1501 USHORT format; /* Format identifier--format = 3 */ | 1489 USHORT format; /* Format identifier--format = 3 */ |
| 1502 USHORT glyphCount; /* Number of glyphs in the input glyph | 1490 USHORT glyphCount; /* Number of glyphs in the input glyph |
| 1503 * sequence */ | 1491 * sequence */ |
| 1504 USHORT lookupCount; /* Number of LookupRecords */ | 1492 USHORT lookupCount; /* Number of LookupRecords */ |
| 1505 OffsetTo<Coverage> | 1493 OffsetTo<Coverage> |
| 1506 coverageZ[VAR]; /* Array of offsets to Coverage | 1494 coverageZ[VAR]; /* Array of offsets to Coverage |
| 1507 * table in glyph sequence order */ | 1495 * table in glyph sequence order */ |
| 1508 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in | 1496 LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in |
| 1509 * design order */ | 1497 * design order */ |
| 1510 public: | 1498 public: |
| 1511 DEFINE_SIZE_ARRAY2 (6, coverageZ, lookupRecordX); | 1499 DEFINE_SIZE_ARRAY2 (6, coverageZ, lookupRecordX); |
| 1512 }; | 1500 }; |
| 1513 | 1501 |
| 1514 struct Context | 1502 struct Context |
| 1515 { | 1503 { |
| 1516 template <typename context_t> | 1504 template <typename context_t> |
| 1517 inline typename context_t::return_t dispatch (context_t *c) const | 1505 inline typename context_t::return_t dispatch (context_t *c) const |
| 1518 { | 1506 { |
| 1519 TRACE_DISPATCH (this, u.format); | 1507 TRACE_DISPATCH (this, u.format); |
| 1520 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 1508 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 1521 switch (u.format) { | 1509 switch (u.format) { |
| 1522 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 1510 case 1: return_trace (c->dispatch (u.format1)); |
| 1523 case 2: return TRACE_RETURN (c->dispatch (u.format2)); | 1511 case 2: return_trace (c->dispatch (u.format2)); |
| 1524 case 3: return TRACE_RETURN (c->dispatch (u.format3)); | 1512 case 3: return_trace (c->dispatch (u.format3)); |
| 1525 default:return TRACE_RETURN (c->default_return_value ()); | 1513 default:return_trace (c->default_return_value ()); |
| 1526 } | 1514 } |
| 1527 } | 1515 } |
| 1528 | 1516 |
| 1529 protected: | 1517 protected: |
| 1530 union { | 1518 union { |
| 1531 USHORT format; /* Format identifier */ | 1519 USHORT format; /* Format identifier */ |
| 1532 ContextFormat1 format1; | 1520 ContextFormat1 format1; |
| 1533 ContextFormat2 format2; | 1521 ContextFormat2 format2; |
| 1534 ContextFormat3 format3; | 1522 ContextFormat3 format3; |
| 1535 } u; | 1523 } u; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 lookup.len, lookup.array, | 1668 lookup.len, lookup.array, |
| 1681 lookup_context); | 1669 lookup_context); |
| 1682 } | 1670 } |
| 1683 | 1671 |
| 1684 inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupC
ontext &lookup_context) const | 1672 inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupC
ontext &lookup_context) const |
| 1685 { | 1673 { |
| 1686 TRACE_WOULD_APPLY (this); | 1674 TRACE_WOULD_APPLY (this); |
| 1687 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> >
(backtrack); | 1675 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> >
(backtrack); |
| 1688 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); | 1676 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); |
| 1689 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); | 1677 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); |
| 1690 return TRACE_RETURN (chain_context_would_apply_lookup (c, | 1678 return_trace (chain_context_would_apply_lookup (c, |
| 1691 » » » » » » » backtrack.len, backtr
ack.array, | 1679 » » » » » » backtrack.len, backtrack.arr
ay, |
| 1692 » » » » » » » input.len, input.arra
y, | 1680 » » » » » » input.len, input.array, |
| 1693 » » » » » » » lookahead.len, lookah
ead.array, lookup.len, | 1681 » » » » » » lookahead.len, lookahead.arr
ay, lookup.len, |
| 1694 » » » » » » » lookup.array, lookup_
context)); | 1682 » » » » » » lookup.array, lookup_context
)); |
| 1695 } | 1683 } |
| 1696 | 1684 |
| 1697 inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &look
up_context) const | 1685 inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &look
up_context) const |
| 1698 { | 1686 { |
| 1699 TRACE_APPLY (this); | 1687 TRACE_APPLY (this); |
| 1700 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> >
(backtrack); | 1688 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> >
(backtrack); |
| 1701 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); | 1689 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); |
| 1702 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); | 1690 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); |
| 1703 return TRACE_RETURN (chain_context_apply_lookup (c, | 1691 return_trace (chain_context_apply_lookup (c, |
| 1704 » » » » » » backtrack.len, backtrack.ar
ray, | 1692 » » » » » backtrack.len, backtrack.array, |
| 1705 » » » » » » input.len, input.array, | 1693 » » » » » input.len, input.array, |
| 1706 » » » » » » lookahead.len, lookahead.ar
ray, lookup.len, | 1694 » » » » » lookahead.len, lookahead.array, lo
okup.len, |
| 1707 » » » » » » lookup.array, lookup_contex
t)); | 1695 » » » » » lookup.array, lookup_context)); |
| 1708 } | 1696 } |
| 1709 | 1697 |
| 1710 inline bool sanitize (hb_sanitize_context_t *c) const | 1698 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1711 { | 1699 { |
| 1712 TRACE_SANITIZE (this); | 1700 TRACE_SANITIZE (this); |
| 1713 if (!backtrack.sanitize (c)) return TRACE_RETURN (false); | 1701 if (!backtrack.sanitize (c)) return_trace (false); |
| 1714 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> >
(backtrack); | 1702 const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> >
(backtrack); |
| 1715 if (!input.sanitize (c)) return TRACE_RETURN (false); | 1703 if (!input.sanitize (c)) return_trace (false); |
| 1716 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); | 1704 const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input); |
| 1717 if (!lookahead.sanitize (c)) return TRACE_RETURN (false); | 1705 if (!lookahead.sanitize (c)) return_trace (false); |
| 1718 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); | 1706 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); |
| 1719 return TRACE_RETURN (lookup.sanitize (c)); | 1707 return_trace (lookup.sanitize (c)); |
| 1720 } | 1708 } |
| 1721 | 1709 |
| 1722 protected: | 1710 protected: |
| 1723 ArrayOf<USHORT> | 1711 ArrayOf<USHORT> |
| 1724 backtrack; /* Array of backtracking values | 1712 backtrack; /* Array of backtracking values |
| 1725 * (to be matched before the input | 1713 * (to be matched before the input |
| 1726 * sequence) */ | 1714 * sequence) */ |
| 1727 HeadlessArrayOf<USHORT> | 1715 HeadlessArrayOf<USHORT> |
| 1728 inputX; /* Array of input values (start with | 1716 inputX; /* Array of input values (start with |
| 1729 * second glyph) */ | 1717 * second glyph) */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1754 for (unsigned int i = 0; i < num_rules; i++) | 1742 for (unsigned int i = 0; i < num_rules; i++) |
| 1755 (this+rule[i]).collect_glyphs (c, lookup_context); | 1743 (this+rule[i]).collect_glyphs (c, lookup_context); |
| 1756 } | 1744 } |
| 1757 | 1745 |
| 1758 inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupC
ontext &lookup_context) const | 1746 inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupC
ontext &lookup_context) const |
| 1759 { | 1747 { |
| 1760 TRACE_WOULD_APPLY (this); | 1748 TRACE_WOULD_APPLY (this); |
| 1761 unsigned int num_rules = rule.len; | 1749 unsigned int num_rules = rule.len; |
| 1762 for (unsigned int i = 0; i < num_rules; i++) | 1750 for (unsigned int i = 0; i < num_rules; i++) |
| 1763 if ((this+rule[i]).would_apply (c, lookup_context)) | 1751 if ((this+rule[i]).would_apply (c, lookup_context)) |
| 1764 return TRACE_RETURN (true); | 1752 return_trace (true); |
| 1765 | 1753 |
| 1766 return TRACE_RETURN (false); | 1754 return_trace (false); |
| 1767 } | 1755 } |
| 1768 | 1756 |
| 1769 inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &look
up_context) const | 1757 inline bool apply (hb_apply_context_t *c, ChainContextApplyLookupContext &look
up_context) const |
| 1770 { | 1758 { |
| 1771 TRACE_APPLY (this); | 1759 TRACE_APPLY (this); |
| 1772 unsigned int num_rules = rule.len; | 1760 unsigned int num_rules = rule.len; |
| 1773 for (unsigned int i = 0; i < num_rules; i++) | 1761 for (unsigned int i = 0; i < num_rules; i++) |
| 1774 if ((this+rule[i]).apply (c, lookup_context)) | 1762 if ((this+rule[i]).apply (c, lookup_context)) |
| 1775 return TRACE_RETURN (true); | 1763 return_trace (true); |
| 1776 | 1764 |
| 1777 return TRACE_RETURN (false); | 1765 return_trace (false); |
| 1778 } | 1766 } |
| 1779 | 1767 |
| 1780 inline bool sanitize (hb_sanitize_context_t *c) const | 1768 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1781 { | 1769 { |
| 1782 TRACE_SANITIZE (this); | 1770 TRACE_SANITIZE (this); |
| 1783 return TRACE_RETURN (rule.sanitize (c, this)); | 1771 return_trace (rule.sanitize (c, this)); |
| 1784 } | 1772 } |
| 1785 | 1773 |
| 1786 protected: | 1774 protected: |
| 1787 OffsetArrayOf<ChainRule> | 1775 OffsetArrayOf<ChainRule> |
| 1788 rule; /* Array of ChainRule tables | 1776 rule; /* Array of ChainRule tables |
| 1789 * ordered by preference */ | 1777 * ordered by preference */ |
| 1790 public: | 1778 public: |
| 1791 DEFINE_SIZE_ARRAY (2, rule); | 1779 DEFINE_SIZE_ARRAY (2, rule); |
| 1792 }; | 1780 }; |
| 1793 | 1781 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 | 1816 |
| 1829 inline bool would_apply (hb_would_apply_context_t *c) const | 1817 inline bool would_apply (hb_would_apply_context_t *c) const |
| 1830 { | 1818 { |
| 1831 TRACE_WOULD_APPLY (this); | 1819 TRACE_WOULD_APPLY (this); |
| 1832 | 1820 |
| 1833 const ChainRuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c-
>glyphs[0])]; | 1821 const ChainRuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c-
>glyphs[0])]; |
| 1834 struct ChainContextApplyLookupContext lookup_context = { | 1822 struct ChainContextApplyLookupContext lookup_context = { |
| 1835 {match_glyph}, | 1823 {match_glyph}, |
| 1836 {NULL, NULL, NULL} | 1824 {NULL, NULL, NULL} |
| 1837 }; | 1825 }; |
| 1838 return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); | 1826 return_trace (rule_set.would_apply (c, lookup_context)); |
| 1839 } | 1827 } |
| 1840 | 1828 |
| 1841 inline const Coverage &get_coverage (void) const | 1829 inline const Coverage &get_coverage (void) const |
| 1842 { | 1830 { |
| 1843 return this+coverage; | 1831 return this+coverage; |
| 1844 } | 1832 } |
| 1845 | 1833 |
| 1846 inline bool apply (hb_apply_context_t *c) const | 1834 inline bool apply (hb_apply_context_t *c) const |
| 1847 { | 1835 { |
| 1848 TRACE_APPLY (this); | 1836 TRACE_APPLY (this); |
| 1849 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); | 1837 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); |
| 1850 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 1838 if (likely (index == NOT_COVERED)) return_trace (false); |
| 1851 | 1839 |
| 1852 const ChainRuleSet &rule_set = this+ruleSet[index]; | 1840 const ChainRuleSet &rule_set = this+ruleSet[index]; |
| 1853 struct ChainContextApplyLookupContext lookup_context = { | 1841 struct ChainContextApplyLookupContext lookup_context = { |
| 1854 {match_glyph}, | 1842 {match_glyph}, |
| 1855 {NULL, NULL, NULL} | 1843 {NULL, NULL, NULL} |
| 1856 }; | 1844 }; |
| 1857 return TRACE_RETURN (rule_set.apply (c, lookup_context)); | 1845 return_trace (rule_set.apply (c, lookup_context)); |
| 1858 } | 1846 } |
| 1859 | 1847 |
| 1860 inline bool sanitize (hb_sanitize_context_t *c) const | 1848 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1861 { | 1849 { |
| 1862 TRACE_SANITIZE (this); | 1850 TRACE_SANITIZE (this); |
| 1863 return TRACE_RETURN (coverage.sanitize (c, this) && ruleSet.sanitize (c, thi
s)); | 1851 return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); |
| 1864 } | 1852 } |
| 1865 | 1853 |
| 1866 protected: | 1854 protected: |
| 1867 USHORT format; /* Format identifier--format = 1 */ | 1855 USHORT format; /* Format identifier--format = 1 */ |
| 1868 OffsetTo<Coverage> | 1856 OffsetTo<Coverage> |
| 1869 coverage; /* Offset to Coverage table--from | 1857 coverage; /* Offset to Coverage table--from |
| 1870 * beginning of table */ | 1858 * beginning of table */ |
| 1871 OffsetArrayOf<ChainRuleSet> | 1859 OffsetArrayOf<ChainRuleSet> |
| 1872 ruleSet; /* Array of ChainRuleSet tables | 1860 ruleSet; /* Array of ChainRuleSet tables |
| 1873 * ordered by Coverage Index */ | 1861 * ordered by Coverage Index */ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 const ClassDef &lookahead_class_def = this+lookaheadClassDef; | 1920 const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
| 1933 | 1921 |
| 1934 unsigned int index = input_class_def.get_class (c->glyphs[0]); | 1922 unsigned int index = input_class_def.get_class (c->glyphs[0]); |
| 1935 const ChainRuleSet &rule_set = this+ruleSet[index]; | 1923 const ChainRuleSet &rule_set = this+ruleSet[index]; |
| 1936 struct ChainContextApplyLookupContext lookup_context = { | 1924 struct ChainContextApplyLookupContext lookup_context = { |
| 1937 {match_class}, | 1925 {match_class}, |
| 1938 {&backtrack_class_def, | 1926 {&backtrack_class_def, |
| 1939 &input_class_def, | 1927 &input_class_def, |
| 1940 &lookahead_class_def} | 1928 &lookahead_class_def} |
| 1941 }; | 1929 }; |
| 1942 return TRACE_RETURN (rule_set.would_apply (c, lookup_context)); | 1930 return_trace (rule_set.would_apply (c, lookup_context)); |
| 1943 } | 1931 } |
| 1944 | 1932 |
| 1945 inline const Coverage &get_coverage (void) const | 1933 inline const Coverage &get_coverage (void) const |
| 1946 { | 1934 { |
| 1947 return this+coverage; | 1935 return this+coverage; |
| 1948 } | 1936 } |
| 1949 | 1937 |
| 1950 inline bool apply (hb_apply_context_t *c) const | 1938 inline bool apply (hb_apply_context_t *c) const |
| 1951 { | 1939 { |
| 1952 TRACE_APPLY (this); | 1940 TRACE_APPLY (this); |
| 1953 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); | 1941 unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoin
t); |
| 1954 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 1942 if (likely (index == NOT_COVERED)) return_trace (false); |
| 1955 | 1943 |
| 1956 const ClassDef &backtrack_class_def = this+backtrackClassDef; | 1944 const ClassDef &backtrack_class_def = this+backtrackClassDef; |
| 1957 const ClassDef &input_class_def = this+inputClassDef; | 1945 const ClassDef &input_class_def = this+inputClassDef; |
| 1958 const ClassDef &lookahead_class_def = this+lookaheadClassDef; | 1946 const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
| 1959 | 1947 |
| 1960 index = input_class_def.get_class (c->buffer->cur().codepoint); | 1948 index = input_class_def.get_class (c->buffer->cur().codepoint); |
| 1961 const ChainRuleSet &rule_set = this+ruleSet[index]; | 1949 const ChainRuleSet &rule_set = this+ruleSet[index]; |
| 1962 struct ChainContextApplyLookupContext lookup_context = { | 1950 struct ChainContextApplyLookupContext lookup_context = { |
| 1963 {match_class}, | 1951 {match_class}, |
| 1964 {&backtrack_class_def, | 1952 {&backtrack_class_def, |
| 1965 &input_class_def, | 1953 &input_class_def, |
| 1966 &lookahead_class_def} | 1954 &lookahead_class_def} |
| 1967 }; | 1955 }; |
| 1968 return TRACE_RETURN (rule_set.apply (c, lookup_context)); | 1956 return_trace (rule_set.apply (c, lookup_context)); |
| 1969 } | 1957 } |
| 1970 | 1958 |
| 1971 inline bool sanitize (hb_sanitize_context_t *c) const | 1959 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1972 { | 1960 { |
| 1973 TRACE_SANITIZE (this); | 1961 TRACE_SANITIZE (this); |
| 1974 return TRACE_RETURN (coverage.sanitize (c, this) && backtrackClassDef.saniti
ze (c, this) && | 1962 return_trace (coverage.sanitize (c, this) && |
| 1975 » » » inputClassDef.sanitize (c, this) && lookaheadClassDef.s
anitize (c, this) && | 1963 » » backtrackClassDef.sanitize (c, this) && |
| 1976 » » » ruleSet.sanitize (c, this)); | 1964 » » inputClassDef.sanitize (c, this) && |
| 1965 » » lookaheadClassDef.sanitize (c, this) && |
| 1966 » » ruleSet.sanitize (c, this)); |
| 1977 } | 1967 } |
| 1978 | 1968 |
| 1979 protected: | 1969 protected: |
| 1980 USHORT format; /* Format identifier--format = 2 */ | 1970 USHORT format; /* Format identifier--format = 2 */ |
| 1981 OffsetTo<Coverage> | 1971 OffsetTo<Coverage> |
| 1982 coverage; /* Offset to Coverage table--from | 1972 coverage; /* Offset to Coverage table--from |
| 1983 * beginning of table */ | 1973 * beginning of table */ |
| 1984 OffsetTo<ClassDef> | 1974 OffsetTo<ClassDef> |
| 1985 backtrackClassDef; /* Offset to glyph ClassDef table | 1975 backtrackClassDef; /* Offset to glyph ClassDef table |
| 1986 * containing backtrack sequence | 1976 * containing backtrack sequence |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 { | 2039 { |
| 2050 TRACE_WOULD_APPLY (this); | 2040 TRACE_WOULD_APPLY (this); |
| 2051 | 2041 |
| 2052 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); | 2042 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); |
| 2053 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (input); | 2043 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (input); |
| 2054 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); | 2044 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); |
| 2055 struct ChainContextApplyLookupContext lookup_context = { | 2045 struct ChainContextApplyLookupContext lookup_context = { |
| 2056 {match_coverage}, | 2046 {match_coverage}, |
| 2057 {this, this, this} | 2047 {this, this, this} |
| 2058 }; | 2048 }; |
| 2059 return TRACE_RETURN (chain_context_would_apply_lookup (c, | 2049 return_trace (chain_context_would_apply_lookup (c, |
| 2060 » » » » » » » backtrack.len, (const
USHORT *) backtrack.array, | 2050 » » » » » » backtrack.len, (const USHORT
*) backtrack.array, |
| 2061 » » » » » » » input.len, (const USH
ORT *) input.array + 1, | 2051 » » » » » » input.len, (const USHORT *)
input.array + 1, |
| 2062 » » » » » » » lookahead.len, (const
USHORT *) lookahead.array, | 2052 » » » » » » lookahead.len, (const USHORT
*) lookahead.array, |
| 2063 » » » » » » » lookup.len, lookup.ar
ray, lookup_context)); | 2053 » » » » » » lookup.len, lookup.array, lo
okup_context)); |
| 2064 } | 2054 } |
| 2065 | 2055 |
| 2066 inline const Coverage &get_coverage (void) const | 2056 inline const Coverage &get_coverage (void) const |
| 2067 { | 2057 { |
| 2068 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); | 2058 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); |
| 2069 return this+input[0]; | 2059 return this+input[0]; |
| 2070 } | 2060 } |
| 2071 | 2061 |
| 2072 inline bool apply (hb_apply_context_t *c) const | 2062 inline bool apply (hb_apply_context_t *c) const |
| 2073 { | 2063 { |
| 2074 TRACE_APPLY (this); | 2064 TRACE_APPLY (this); |
| 2075 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); | 2065 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); |
| 2076 | 2066 |
| 2077 unsigned int index = (this+input[0]).get_coverage (c->buffer->cur().codepoin
t); | 2067 unsigned int index = (this+input[0]).get_coverage (c->buffer->cur().codepoin
t); |
| 2078 if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); | 2068 if (likely (index == NOT_COVERED)) return_trace (false); |
| 2079 | 2069 |
| 2080 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (input); | 2070 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (input); |
| 2081 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); | 2071 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); |
| 2082 struct ChainContextApplyLookupContext lookup_context = { | 2072 struct ChainContextApplyLookupContext lookup_context = { |
| 2083 {match_coverage}, | 2073 {match_coverage}, |
| 2084 {this, this, this} | 2074 {this, this, this} |
| 2085 }; | 2075 }; |
| 2086 return TRACE_RETURN (chain_context_apply_lookup (c, | 2076 return_trace (chain_context_apply_lookup (c, |
| 2087 » » » » » » backtrack.len, (const USHOR
T *) backtrack.array, | 2077 » » » » » backtrack.len, (const USHORT *) ba
cktrack.array, |
| 2088 » » » » » » input.len, (const USHORT *)
input.array + 1, | 2078 » » » » » input.len, (const USHORT *) input.
array + 1, |
| 2089 » » » » » » lookahead.len, (const USHOR
T *) lookahead.array, | 2079 » » » » » lookahead.len, (const USHORT *) lo
okahead.array, |
| 2090 » » » » » » lookup.len, lookup.array, l
ookup_context)); | 2080 » » » » » lookup.len, lookup.array, lookup_c
ontext)); |
| 2091 } | 2081 } |
| 2092 | 2082 |
| 2093 inline bool sanitize (hb_sanitize_context_t *c) const | 2083 inline bool sanitize (hb_sanitize_context_t *c) const |
| 2094 { | 2084 { |
| 2095 TRACE_SANITIZE (this); | 2085 TRACE_SANITIZE (this); |
| 2096 if (!backtrack.sanitize (c, this)) return TRACE_RETURN (false); | 2086 if (!backtrack.sanitize (c, this)) return_trace (false); |
| 2097 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); | 2087 const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> >
(backtrack); |
| 2098 if (!input.sanitize (c, this)) return TRACE_RETURN (false); | 2088 if (!input.sanitize (c, this)) return_trace (false); |
| 2099 if (!input.len) return TRACE_RETURN (false); /* To be consistent with Contex
t. */ | 2089 if (!input.len) return_trace (false); /* To be consistent with Context. */ |
| 2100 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (input); | 2090 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (input); |
| 2101 if (!lookahead.sanitize (c, this)) return TRACE_RETURN (false); | 2091 if (!lookahead.sanitize (c, this)) return_trace (false); |
| 2102 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); | 2092 const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (l
ookahead); |
| 2103 return TRACE_RETURN (lookup.sanitize (c)); | 2093 return_trace (lookup.sanitize (c)); |
| 2104 } | 2094 } |
| 2105 | 2095 |
| 2106 protected: | 2096 protected: |
| 2107 USHORT format; /* Format identifier--format = 3 */ | 2097 USHORT format; /* Format identifier--format = 3 */ |
| 2108 OffsetArrayOf<Coverage> | 2098 OffsetArrayOf<Coverage> |
| 2109 backtrack; /* Array of coverage tables | 2099 backtrack; /* Array of coverage tables |
| 2110 * in backtracking sequence, in glyph | 2100 * in backtracking sequence, in glyph |
| 2111 * sequence order */ | 2101 * sequence order */ |
| 2112 OffsetArrayOf<Coverage> | 2102 OffsetArrayOf<Coverage> |
| 2113 inputX ; /* Array of coverage | 2103 inputX ; /* Array of coverage |
| 2114 * tables in input sequence, in glyph | 2104 * tables in input sequence, in glyph |
| 2115 * sequence order */ | 2105 * sequence order */ |
| 2116 OffsetArrayOf<Coverage> | 2106 OffsetArrayOf<Coverage> |
| 2117 lookaheadX; /* Array of coverage tables | 2107 lookaheadX; /* Array of coverage tables |
| 2118 * in lookahead sequence, in glyph | 2108 * in lookahead sequence, in glyph |
| 2119 * sequence order */ | 2109 * sequence order */ |
| 2120 ArrayOf<LookupRecord> | 2110 ArrayOf<LookupRecord> |
| 2121 lookupX; /* Array of LookupRecords--in | 2111 lookupX; /* Array of LookupRecords--in |
| 2122 * design order) */ | 2112 * design order) */ |
| 2123 public: | 2113 public: |
| 2124 DEFINE_SIZE_MIN (10); | 2114 DEFINE_SIZE_MIN (10); |
| 2125 }; | 2115 }; |
| 2126 | 2116 |
| 2127 struct ChainContext | 2117 struct ChainContext |
| 2128 { | 2118 { |
| 2129 template <typename context_t> | 2119 template <typename context_t> |
| 2130 inline typename context_t::return_t dispatch (context_t *c) const | 2120 inline typename context_t::return_t dispatch (context_t *c) const |
| 2131 { | 2121 { |
| 2132 TRACE_DISPATCH (this, u.format); | 2122 TRACE_DISPATCH (this, u.format); |
| 2133 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 2123 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 2134 switch (u.format) { | 2124 switch (u.format) { |
| 2135 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 2125 case 1: return_trace (c->dispatch (u.format1)); |
| 2136 case 2: return TRACE_RETURN (c->dispatch (u.format2)); | 2126 case 2: return_trace (c->dispatch (u.format2)); |
| 2137 case 3: return TRACE_RETURN (c->dispatch (u.format3)); | 2127 case 3: return_trace (c->dispatch (u.format3)); |
| 2138 default:return TRACE_RETURN (c->default_return_value ()); | 2128 default:return_trace (c->default_return_value ()); |
| 2139 } | 2129 } |
| 2140 } | 2130 } |
| 2141 | 2131 |
| 2142 protected: | 2132 protected: |
| 2143 union { | 2133 union { |
| 2144 USHORT format; /* Format identifier */ | 2134 USHORT format; /* Format identifier */ |
| 2145 ChainContextFormat1 format1; | 2135 ChainContextFormat1 format1; |
| 2146 ChainContextFormat2 format2; | 2136 ChainContextFormat2 format2; |
| 2147 ChainContextFormat3 format3; | 2137 ChainContextFormat3 format3; |
| 2148 } u; | 2138 } u; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2159 { | 2149 { |
| 2160 unsigned int offset = extensionOffset; | 2150 unsigned int offset = extensionOffset; |
| 2161 if (unlikely (!offset)) return Null(typename T::LookupSubTable); | 2151 if (unlikely (!offset)) return Null(typename T::LookupSubTable); |
| 2162 return StructAtOffset<typename T::LookupSubTable> (this, offset); | 2152 return StructAtOffset<typename T::LookupSubTable> (this, offset); |
| 2163 } | 2153 } |
| 2164 | 2154 |
| 2165 template <typename context_t> | 2155 template <typename context_t> |
| 2166 inline typename context_t::return_t dispatch (context_t *c) const | 2156 inline typename context_t::return_t dispatch (context_t *c) const |
| 2167 { | 2157 { |
| 2168 TRACE_DISPATCH (this, format); | 2158 TRACE_DISPATCH (this, format); |
| 2169 if (unlikely (!c->may_dispatch (this, this))) TRACE_RETURN (c->default_retur
n_value ()); | 2159 if (unlikely (!c->may_dispatch (this, this))) return_trace (c->no_dispatch_r
eturn_value ()); |
| 2170 return TRACE_RETURN (get_subtable<typename T::LookupSubTable> ().dispatch (c
, get_type ())); | 2160 return_trace (get_subtable<typename T::LookupSubTable> ().dispatch (c, get_t
ype ())); |
| 2171 } | 2161 } |
| 2172 | 2162 |
| 2173 /* This is called from may_dispatch() above with hb_sanitize_context_t. */ | 2163 /* This is called from may_dispatch() above with hb_sanitize_context_t. */ |
| 2174 inline bool sanitize (hb_sanitize_context_t *c) const | 2164 inline bool sanitize (hb_sanitize_context_t *c) const |
| 2175 { | 2165 { |
| 2176 TRACE_SANITIZE (this); | 2166 TRACE_SANITIZE (this); |
| 2177 return TRACE_RETURN (c->check_struct (this) && extensionOffset != 0); | 2167 return_trace (c->check_struct (this) && extensionOffset != 0); |
| 2178 } | 2168 } |
| 2179 | 2169 |
| 2180 protected: | 2170 protected: |
| 2181 USHORT format; /* Format identifier. Set to 1. */ | 2171 USHORT format; /* Format identifier. Set to 1. */ |
| 2182 USHORT extensionLookupType; /* Lookup type of subtable referenced | 2172 USHORT extensionLookupType; /* Lookup type of subtable referenced |
| 2183 * by ExtensionOffset (i.e. the | 2173 * by ExtensionOffset (i.e. the |
| 2184 * extension subtable). */ | 2174 * extension subtable). */ |
| 2185 ULONG extensionOffset; /* Offset to the extension subtable, | 2175 ULONG extensionOffset; /* Offset to the extension subtable, |
| 2186 * of lookup type subtable. */ | 2176 * of lookup type subtable. */ |
| 2187 public: | 2177 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2204 switch (u.format) { | 2194 switch (u.format) { |
| 2205 case 1: return u.format1.template get_subtable<typename T::LookupSubTable> (
); | 2195 case 1: return u.format1.template get_subtable<typename T::LookupSubTable> (
); |
| 2206 default:return Null(typename T::LookupSubTable); | 2196 default:return Null(typename T::LookupSubTable); |
| 2207 } | 2197 } |
| 2208 } | 2198 } |
| 2209 | 2199 |
| 2210 template <typename context_t> | 2200 template <typename context_t> |
| 2211 inline typename context_t::return_t dispatch (context_t *c) const | 2201 inline typename context_t::return_t dispatch (context_t *c) const |
| 2212 { | 2202 { |
| 2213 TRACE_DISPATCH (this, u.format); | 2203 TRACE_DISPATCH (this, u.format); |
| 2214 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); | 2204 if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispa
tch_return_value ()); |
| 2215 switch (u.format) { | 2205 switch (u.format) { |
| 2216 case 1: return TRACE_RETURN (u.format1.dispatch (c)); | 2206 case 1: return_trace (u.format1.dispatch (c)); |
| 2217 default:return TRACE_RETURN (c->default_return_value ()); | 2207 default:return_trace (c->default_return_value ()); |
| 2218 } | 2208 } |
| 2219 } | 2209 } |
| 2220 | 2210 |
| 2221 protected: | 2211 protected: |
| 2222 union { | 2212 union { |
| 2223 USHORT format; /* Format identifier */ | 2213 USHORT format; /* Format identifier */ |
| 2224 ExtensionFormat1<T> format1; | 2214 ExtensionFormat1<T> format1; |
| 2225 } u; | 2215 } u; |
| 2226 }; | 2216 }; |
| 2227 | 2217 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 { return (this+featureList).find_index (tag, index); } | 2252 { return (this+featureList).find_index (tag, index); } |
| 2263 | 2253 |
| 2264 inline unsigned int get_lookup_count (void) const | 2254 inline unsigned int get_lookup_count (void) const |
| 2265 { return (this+lookupList).len; } | 2255 { return (this+lookupList).len; } |
| 2266 inline const Lookup& get_lookup (unsigned int i) const | 2256 inline const Lookup& get_lookup (unsigned int i) const |
| 2267 { return (this+lookupList)[i]; } | 2257 { return (this+lookupList)[i]; } |
| 2268 | 2258 |
| 2269 inline bool sanitize (hb_sanitize_context_t *c) const | 2259 inline bool sanitize (hb_sanitize_context_t *c) const |
| 2270 { | 2260 { |
| 2271 TRACE_SANITIZE (this); | 2261 TRACE_SANITIZE (this); |
| 2272 return TRACE_RETURN (version.sanitize (c) && likely (version.major == 1) && | 2262 return_trace (version.sanitize (c) && |
| 2273 » » » scriptList.sanitize (c, this) && | 2263 » » likely (version.major == 1) && |
| 2274 » » » featureList.sanitize (c, this) && | 2264 » » scriptList.sanitize (c, this) && |
| 2275 » » » lookupList.sanitize (c, this)); | 2265 » » featureList.sanitize (c, this) && |
| 2266 » » lookupList.sanitize (c, this)); |
| 2276 } | 2267 } |
| 2277 | 2268 |
| 2278 protected: | 2269 protected: |
| 2279 FixedVersion version; /* Version of the GSUB/GPOS table--initially set | 2270 FixedVersion version; /* Version of the GSUB/GPOS table--initially set |
| 2280 * to 0x00010000u */ | 2271 * to 0x00010000u */ |
| 2281 OffsetTo<ScriptList> | 2272 OffsetTo<ScriptList> |
| 2282 scriptList; /* ScriptList table */ | 2273 scriptList; /* ScriptList table */ |
| 2283 OffsetTo<FeatureList> | 2274 OffsetTo<FeatureList> |
| 2284 featureList; /* FeatureList table */ | 2275 featureList; /* FeatureList table */ |
| 2285 OffsetTo<LookupList> | 2276 OffsetTo<LookupList> |
| 2286 lookupList; /* LookupList table */ | 2277 lookupList; /* LookupList table */ |
| 2287 public: | 2278 public: |
| 2288 DEFINE_SIZE_STATIC (10); | 2279 DEFINE_SIZE_STATIC (10); |
| 2289 }; | 2280 }; |
| 2290 | 2281 |
| 2291 | 2282 |
| 2292 } /* namespace OT */ | 2283 } /* namespace OT */ |
| 2293 | 2284 |
| 2294 | 2285 |
| 2295 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */ | 2286 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */ |
| OLD | NEW |