/src/harfbuzz/src/hb-ot-layout-gsubgpos.hh
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
3 | | * Copyright © 2010,2012 Google, Inc. |
4 | | * |
5 | | * This is part of HarfBuzz, a text shaping library. |
6 | | * |
7 | | * Permission is hereby granted, without written agreement and without |
8 | | * license or royalty fees, to use, copy, modify, and distribute this |
9 | | * software and its documentation for any purpose, provided that the |
10 | | * above copyright notice and the following two paragraphs appear in |
11 | | * all copies of this software. |
12 | | * |
13 | | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
14 | | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
15 | | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
16 | | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
17 | | * DAMAGE. |
18 | | * |
19 | | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
20 | | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
21 | | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
22 | | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
23 | | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
24 | | * |
25 | | * Red Hat Author(s): Behdad Esfahbod |
26 | | * Google Author(s): Behdad Esfahbod |
27 | | */ |
28 | | |
29 | | #ifndef HB_OT_LAYOUT_GSUBGPOS_HH |
30 | | #define HB_OT_LAYOUT_GSUBGPOS_HH |
31 | | |
32 | | #include "hb.hh" |
33 | | #include "hb-buffer.hh" |
34 | | #include "hb-map.hh" |
35 | | #include "hb-set.hh" |
36 | | #include "hb-ot-map.hh" |
37 | | #include "hb-ot-layout-common.hh" |
38 | | #include "hb-ot-layout-gdef-table.hh" |
39 | | |
40 | | |
41 | | namespace OT { |
42 | | |
43 | | |
44 | | struct hb_intersects_context_t : |
45 | | hb_dispatch_context_t<hb_intersects_context_t, bool> |
46 | | { |
47 | | template <typename T> |
48 | 0 | return_t dispatch (const T &obj) { return obj.intersects (this->glyphs); } Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
49 | 0 | static return_t default_return_value () { return false; } |
50 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
51 | | |
52 | | const hb_set_t *glyphs; |
53 | | |
54 | | hb_intersects_context_t (const hb_set_t *glyphs_) : |
55 | 0 | glyphs (glyphs_) {} |
56 | | }; |
57 | | |
58 | | struct hb_have_non_1to1_context_t : |
59 | | hb_dispatch_context_t<hb_have_non_1to1_context_t, bool> |
60 | | { |
61 | | template <typename T> |
62 | 0 | return_t dispatch (const T &obj) { return obj.may_have_non_1to1 (); } Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
63 | 0 | static return_t default_return_value () { return false; } |
64 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
65 | | }; |
66 | | |
67 | | struct hb_closure_context_t : |
68 | | hb_dispatch_context_t<hb_closure_context_t> |
69 | | { |
70 | | typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indicies, unsigned seq_index, unsigned end_index); |
71 | | template <typename T> |
72 | 0 | return_t dispatch (const T &obj) { obj.closure (this); return hb_empty_t (); } Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
73 | 0 | static return_t default_return_value () { return hb_empty_t (); } |
74 | | void recurse (unsigned lookup_index, hb_set_t *covered_seq_indicies, unsigned seq_index, unsigned end_index) |
75 | 0 | { |
76 | 0 | if (unlikely (nesting_level_left == 0 || !recurse_func)) |
77 | 0 | return; |
78 | | |
79 | 0 | nesting_level_left--; |
80 | 0 | recurse_func (this, lookup_index, covered_seq_indicies, seq_index, end_index); |
81 | 0 | nesting_level_left++; |
82 | 0 | } |
83 | | |
84 | | void reset_lookup_visit_count () |
85 | 0 | { lookup_count = 0; } |
86 | | |
87 | | bool lookup_limit_exceeded () |
88 | 0 | { return lookup_count > HB_MAX_LOOKUP_VISIT_COUNT; } |
89 | | |
90 | | bool should_visit_lookup (unsigned int lookup_index) |
91 | 0 | { |
92 | 0 | if (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT) |
93 | 0 | return false; |
94 | | |
95 | 0 | if (is_lookup_done (lookup_index)) |
96 | 0 | return false; |
97 | | |
98 | 0 | return true; |
99 | 0 | } |
100 | | |
101 | | bool is_lookup_done (unsigned int lookup_index) |
102 | 0 | { |
103 | 0 | if (unlikely (done_lookups_glyph_count->in_error () || |
104 | 0 | done_lookups_glyph_set->in_error ())) |
105 | 0 | return true; |
106 | | |
107 | | /* Have we visited this lookup with the current set of glyphs? */ |
108 | 0 | if (done_lookups_glyph_count->get (lookup_index) != glyphs->get_population ()) |
109 | 0 | { |
110 | 0 | done_lookups_glyph_count->set (lookup_index, glyphs->get_population ()); |
111 | |
|
112 | 0 | if (!done_lookups_glyph_set->has (lookup_index)) |
113 | 0 | { |
114 | 0 | if (unlikely (!done_lookups_glyph_set->set (lookup_index, hb::unique_ptr<hb_set_t> {hb_set_create ()}))) |
115 | 0 | return true; |
116 | 0 | } |
117 | | |
118 | 0 | done_lookups_glyph_set->get (lookup_index)->clear (); |
119 | 0 | } |
120 | | |
121 | 0 | hb_set_t *covered_glyph_set = done_lookups_glyph_set->get (lookup_index); |
122 | 0 | if (unlikely (covered_glyph_set->in_error ())) |
123 | 0 | return true; |
124 | 0 | if (parent_active_glyphs ().is_subset (*covered_glyph_set)) |
125 | 0 | return true; |
126 | | |
127 | 0 | covered_glyph_set->union_ (parent_active_glyphs ()); |
128 | 0 | return false; |
129 | 0 | } |
130 | | |
131 | 0 | const hb_set_t& previous_parent_active_glyphs () { |
132 | 0 | if (active_glyphs_stack.length <= 1) |
133 | 0 | return *glyphs; |
134 | | |
135 | 0 | return active_glyphs_stack[active_glyphs_stack.length - 2]; |
136 | 0 | } |
137 | | |
138 | | const hb_set_t& parent_active_glyphs () |
139 | 0 | { |
140 | 0 | if (!active_glyphs_stack) |
141 | 0 | return *glyphs; |
142 | | |
143 | 0 | return active_glyphs_stack.tail (); |
144 | 0 | } |
145 | | |
146 | | hb_set_t* push_cur_active_glyphs () |
147 | 0 | { |
148 | 0 | hb_set_t *s = active_glyphs_stack.push (); |
149 | 0 | if (unlikely (active_glyphs_stack.in_error ())) |
150 | 0 | return nullptr; |
151 | 0 | return s; |
152 | 0 | } |
153 | | |
154 | | bool pop_cur_done_glyphs () |
155 | 0 | { |
156 | 0 | if (!active_glyphs_stack) |
157 | 0 | return false; |
158 | | |
159 | 0 | active_glyphs_stack.pop (); |
160 | 0 | return true; |
161 | 0 | } |
162 | | |
163 | | hb_face_t *face; |
164 | | hb_set_t *glyphs; |
165 | | hb_set_t output[1]; |
166 | | hb_vector_t<hb_set_t> active_glyphs_stack; |
167 | | recurse_func_t recurse_func = nullptr; |
168 | | unsigned int nesting_level_left; |
169 | | |
170 | | hb_closure_context_t (hb_face_t *face_, |
171 | | hb_set_t *glyphs_, |
172 | | hb_map_t *done_lookups_glyph_count_, |
173 | | hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *done_lookups_glyph_set_, |
174 | | unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
175 | 0 | face (face_), |
176 | 0 | glyphs (glyphs_), |
177 | 0 | nesting_level_left (nesting_level_left_), |
178 | 0 | done_lookups_glyph_count (done_lookups_glyph_count_), |
179 | 0 | done_lookups_glyph_set (done_lookups_glyph_set_) |
180 | 0 | {} |
181 | | |
182 | 0 | ~hb_closure_context_t () { flush (); } |
183 | | |
184 | 0 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
185 | | |
186 | | void flush () |
187 | 0 | { |
188 | 0 | output->del_range (face->get_num_glyphs (), HB_SET_VALUE_INVALID); /* Remove invalid glyphs. */ |
189 | 0 | glyphs->union_ (*output); |
190 | 0 | output->clear (); |
191 | 0 | active_glyphs_stack.pop (); |
192 | 0 | active_glyphs_stack.reset (); |
193 | 0 | } |
194 | | |
195 | | private: |
196 | | hb_map_t *done_lookups_glyph_count; |
197 | | hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *done_lookups_glyph_set; |
198 | | unsigned int lookup_count = 0; |
199 | | }; |
200 | | |
201 | | |
202 | | |
203 | | struct hb_closure_lookups_context_t : |
204 | | hb_dispatch_context_t<hb_closure_lookups_context_t> |
205 | | { |
206 | | typedef return_t (*recurse_func_t) (hb_closure_lookups_context_t *c, unsigned lookup_index); |
207 | | template <typename T> |
208 | 0 | return_t dispatch (const T &obj) { obj.closure_lookups (this); return hb_empty_t (); } Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
209 | 0 | static return_t default_return_value () { return hb_empty_t (); } |
210 | | void recurse (unsigned lookup_index) |
211 | 0 | { |
212 | 0 | if (unlikely (nesting_level_left == 0 || !recurse_func)) |
213 | 0 | return; |
214 | 0 |
|
215 | 0 | /* Return if new lookup was recursed to before. */ |
216 | 0 | if (lookup_limit_exceeded () |
217 | 0 | || visited_lookups->in_error () |
218 | 0 | || visited_lookups->has (lookup_index)) |
219 | 0 | // Don't increment lookup count here, that will be done in the call to closure_lookups() |
220 | 0 | // made by recurse_func. |
221 | 0 | return; |
222 | 0 |
|
223 | 0 | nesting_level_left--; |
224 | 0 | recurse_func (this, lookup_index); |
225 | 0 | nesting_level_left++; |
226 | 0 | } |
227 | | |
228 | | void set_lookup_visited (unsigned lookup_index) |
229 | 0 | { visited_lookups->add (lookup_index); } |
230 | | |
231 | | void set_lookup_inactive (unsigned lookup_index) |
232 | 0 | { inactive_lookups->add (lookup_index); } |
233 | | |
234 | | bool lookup_limit_exceeded () |
235 | 0 | { |
236 | 0 | bool ret = lookup_count > HB_MAX_LOOKUP_VISIT_COUNT; |
237 | 0 | if (ret) |
238 | 0 | DEBUG_MSG (SUBSET, nullptr, "lookup visit count limit exceeded in lookup closure!"); |
239 | 0 | return ret; } |
240 | | |
241 | | bool is_lookup_visited (unsigned lookup_index) |
242 | 0 | { |
243 | 0 | if (unlikely (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT)) |
244 | 0 | { |
245 | 0 | DEBUG_MSG (SUBSET, nullptr, "total visited lookup count %u exceeds max limit, lookup %u is dropped.", |
246 | 0 | lookup_count, lookup_index); |
247 | 0 | return true; |
248 | 0 | } |
249 | 0 |
|
250 | 0 | if (unlikely (visited_lookups->in_error ())) |
251 | 0 | return true; |
252 | 0 |
|
253 | 0 | return visited_lookups->has (lookup_index); |
254 | 0 | } |
255 | | |
256 | | hb_face_t *face; |
257 | | const hb_set_t *glyphs; |
258 | | recurse_func_t recurse_func; |
259 | | unsigned int nesting_level_left; |
260 | | |
261 | | hb_closure_lookups_context_t (hb_face_t *face_, |
262 | | const hb_set_t *glyphs_, |
263 | | hb_set_t *visited_lookups_, |
264 | | hb_set_t *inactive_lookups_, |
265 | | unsigned nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
266 | | face (face_), |
267 | | glyphs (glyphs_), |
268 | | recurse_func (nullptr), |
269 | | nesting_level_left (nesting_level_left_), |
270 | | visited_lookups (visited_lookups_), |
271 | | inactive_lookups (inactive_lookups_), |
272 | 0 | lookup_count (0) {} |
273 | | |
274 | 0 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
275 | | |
276 | | private: |
277 | | hb_set_t *visited_lookups; |
278 | | hb_set_t *inactive_lookups; |
279 | | unsigned int lookup_count; |
280 | | }; |
281 | | |
282 | | struct hb_would_apply_context_t : |
283 | | hb_dispatch_context_t<hb_would_apply_context_t, bool> |
284 | | { |
285 | | template <typename T> |
286 | 0 | return_t dispatch (const T &obj) { return obj.would_apply (this); } Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
287 | 0 | static return_t default_return_value () { return false; } |
288 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
289 | | |
290 | | hb_face_t *face; |
291 | | const hb_codepoint_t *glyphs; |
292 | | unsigned int len; |
293 | | bool zero_context; |
294 | | |
295 | | hb_would_apply_context_t (hb_face_t *face_, |
296 | | const hb_codepoint_t *glyphs_, |
297 | | unsigned int len_, |
298 | | bool zero_context_) : |
299 | 0 | face (face_), |
300 | 0 | glyphs (glyphs_), |
301 | 0 | len (len_), |
302 | 0 | zero_context (zero_context_) {} |
303 | | }; |
304 | | |
305 | | struct hb_collect_glyphs_context_t : |
306 | | hb_dispatch_context_t<hb_collect_glyphs_context_t> |
307 | | { |
308 | | typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index); |
309 | | template <typename T> |
310 | 0 | return_t dispatch (const T &obj) { obj.collect_glyphs (this); return hb_empty_t (); } Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
311 | 0 | static return_t default_return_value () { return hb_empty_t (); } |
312 | | void recurse (unsigned int lookup_index) |
313 | 0 | { |
314 | 0 | if (unlikely (nesting_level_left == 0 || !recurse_func)) |
315 | 0 | return; |
316 | | |
317 | | /* Note that GPOS sets recurse_func to nullptr already, so it doesn't get |
318 | | * past the previous check. For GSUB, we only want to collect the output |
319 | | * glyphs in the recursion. If output is not requested, we can go home now. |
320 | | * |
321 | | * Note further, that the above is not exactly correct. A recursed lookup |
322 | | * is allowed to match input that is not matched in the context, but that's |
323 | | * not how most fonts are built. It's possible to relax that and recurse |
324 | | * with all sets here if it proves to be an issue. |
325 | | */ |
326 | | |
327 | 0 | if (output == hb_set_get_empty ()) |
328 | 0 | return; |
329 | | |
330 | | /* Return if new lookup was recursed to before. */ |
331 | 0 | if (recursed_lookups->has (lookup_index)) |
332 | 0 | return; |
333 | | |
334 | 0 | hb_set_t *old_before = before; |
335 | 0 | hb_set_t *old_input = input; |
336 | 0 | hb_set_t *old_after = after; |
337 | 0 | before = input = after = hb_set_get_empty (); |
338 | |
|
339 | 0 | nesting_level_left--; |
340 | 0 | recurse_func (this, lookup_index); |
341 | 0 | nesting_level_left++; |
342 | |
|
343 | 0 | before = old_before; |
344 | 0 | input = old_input; |
345 | 0 | after = old_after; |
346 | |
|
347 | 0 | recursed_lookups->add (lookup_index); |
348 | 0 | } |
349 | | |
350 | | hb_face_t *face; |
351 | | hb_set_t *before; |
352 | | hb_set_t *input; |
353 | | hb_set_t *after; |
354 | | hb_set_t *output; |
355 | | recurse_func_t recurse_func; |
356 | | hb_set_t *recursed_lookups; |
357 | | unsigned int nesting_level_left; |
358 | | |
359 | | hb_collect_glyphs_context_t (hb_face_t *face_, |
360 | | hb_set_t *glyphs_before, /* OUT. May be NULL */ |
361 | | hb_set_t *glyphs_input, /* OUT. May be NULL */ |
362 | | hb_set_t *glyphs_after, /* OUT. May be NULL */ |
363 | | hb_set_t *glyphs_output, /* OUT. May be NULL */ |
364 | | unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
365 | 0 | face (face_), |
366 | 0 | before (glyphs_before ? glyphs_before : hb_set_get_empty ()), |
367 | 0 | input (glyphs_input ? glyphs_input : hb_set_get_empty ()), |
368 | 0 | after (glyphs_after ? glyphs_after : hb_set_get_empty ()), |
369 | 0 | output (glyphs_output ? glyphs_output : hb_set_get_empty ()), |
370 | 0 | recurse_func (nullptr), |
371 | 0 | recursed_lookups (hb_set_create ()), |
372 | 0 | nesting_level_left (nesting_level_left_) {} |
373 | 0 | ~hb_collect_glyphs_context_t () { hb_set_destroy (recursed_lookups); } |
374 | | |
375 | 0 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
376 | | }; |
377 | | |
378 | | |
379 | | |
380 | | template <typename set_t> |
381 | | struct hb_collect_coverage_context_t : |
382 | | hb_dispatch_context_t<hb_collect_coverage_context_t<set_t>, const Coverage &> |
383 | | { |
384 | | typedef const Coverage &return_t; // Stoopid that we have to dupe this here. |
385 | | template <typename T> |
386 | | return_t dispatch (const T &obj) { return obj.get_coverage (); } |
387 | | static return_t default_return_value () { return Null (Coverage); } |
388 | | bool stop_sublookup_iteration (return_t r) const |
389 | | { |
390 | | r.collect_coverage (set); |
391 | | return false; |
392 | | } |
393 | | |
394 | | hb_collect_coverage_context_t (set_t *set_) : |
395 | | set (set_) {} |
396 | | |
397 | | set_t *set; |
398 | | }; |
399 | | |
400 | | struct matcher_t |
401 | | { |
402 | | typedef bool (*match_func_t) (hb_glyph_info_t &info, unsigned value, const void *data); |
403 | | |
404 | | template <typename context_t> |
405 | | void init (const context_t *c, bool context_match = false) |
406 | 805k | { |
407 | 805k | set_match_func (nullptr, nullptr); |
408 | 805k | lookup_props = c->lookup_props; |
409 | | /* Ignore ZWNJ if we are matching GPOS, or matching GSUB context and asked to. */ |
410 | 805k | ignore_zwnj = c->table_index == 1 || (context_match && c->auto_zwnj); |
411 | | /* Ignore ZWJ if we are matching context, or asked to. */ |
412 | 805k | ignore_zwj = context_match || c->auto_zwj; |
413 | | /* Ignore hidden glyphs (like CGJ) during GPOS. */ |
414 | 805k | ignore_hidden = c->table_index == 1; |
415 | 805k | mask = context_match ? -1 : c->lookup_mask; |
416 | | /* Per syllable matching is only for GSUB. */ |
417 | 805k | per_syllable = c->table_index == 0 && c->per_syllable; |
418 | 805k | syllable = 0; |
419 | 805k | } |
420 | | |
421 | | void set_match_func (match_func_t match_func_, |
422 | | const void *match_data_) |
423 | 805k | { match_func = match_func_; match_data = match_data_; } |
424 | | |
425 | | enum may_match_t { |
426 | | MATCH_NO, |
427 | | MATCH_YES, |
428 | | MATCH_MAYBE |
429 | | }; |
430 | | |
431 | | #ifndef HB_OPTIMIZE_SIZE |
432 | | HB_ALWAYS_INLINE |
433 | | #endif |
434 | | may_match_t may_match (hb_glyph_info_t &info, |
435 | | hb_codepoint_t glyph_data) const |
436 | 0 | { |
437 | 0 | if (!(info.mask & mask) || |
438 | 0 | (per_syllable && syllable && syllable != info.syllable ())) |
439 | 0 | return MATCH_NO; |
440 | | |
441 | 0 | if (match_func) |
442 | 0 | return match_func (info, glyph_data, match_data) ? MATCH_YES : MATCH_NO; |
443 | | |
444 | 0 | return MATCH_MAYBE; |
445 | 0 | } |
446 | | |
447 | | enum may_skip_t { |
448 | | SKIP_NO, |
449 | | SKIP_YES, |
450 | | SKIP_MAYBE |
451 | | }; |
452 | | |
453 | | template <typename context_t> |
454 | | #ifndef HB_OPTIMIZE_SIZE |
455 | | HB_ALWAYS_INLINE |
456 | | #endif |
457 | | may_skip_t may_skip (const context_t *c, |
458 | | const hb_glyph_info_t &info) const |
459 | 0 | { |
460 | 0 | if (!c->check_glyph_property (&info, lookup_props)) |
461 | 0 | return SKIP_YES; |
462 | | |
463 | 0 | if (unlikely (_hb_glyph_info_is_default_ignorable (&info) && |
464 | 0 | (ignore_zwnj || !_hb_glyph_info_is_zwnj (&info)) && |
465 | 0 | (ignore_zwj || !_hb_glyph_info_is_zwj (&info)) && |
466 | 0 | (ignore_hidden || !_hb_glyph_info_is_hidden (&info)))) |
467 | 0 | return SKIP_MAYBE; |
468 | | |
469 | 0 | return SKIP_NO; |
470 | 0 | } |
471 | | |
472 | | public: |
473 | | unsigned int lookup_props = 0; |
474 | | hb_mask_t mask = -1; |
475 | | bool ignore_zwnj = false; |
476 | | bool ignore_zwj = false; |
477 | | bool ignore_hidden = false; |
478 | | bool per_syllable = false; |
479 | | uint8_t syllable = 0; |
480 | | match_func_t match_func = nullptr; |
481 | | const void *match_data = nullptr; |
482 | | }; |
483 | | |
484 | | template <typename context_t> |
485 | | struct skipping_iterator_t |
486 | | { |
487 | | void init (context_t *c_, bool context_match = false) |
488 | 805k | { |
489 | 805k | c = c_; |
490 | 805k | end = c->buffer->len; |
491 | 805k | match_glyph_data16 = nullptr; |
492 | | #ifndef HB_NO_BEYOND_64K |
493 | | match_glyph_data24 = nullptr; |
494 | | #endif |
495 | 805k | matcher.init (c, context_match); |
496 | 805k | } |
497 | | void set_lookup_props (unsigned int lookup_props) |
498 | 0 | { |
499 | 0 | matcher.lookup_props = lookup_props; |
500 | 0 | } |
501 | | void set_match_func (matcher_t::match_func_t match_func_, |
502 | | const void *match_data_) |
503 | 0 | { |
504 | 0 | matcher.set_match_func (match_func_, match_data_); |
505 | 0 | } |
506 | | void set_glyph_data (const HBUINT16 glyph_data[]) |
507 | 0 | { |
508 | 0 | match_glyph_data16 = glyph_data; |
509 | | #ifndef HB_NO_BEYOND_64K |
510 | | match_glyph_data24 = nullptr; |
511 | | #endif |
512 | 0 | } |
513 | | #ifndef HB_NO_BEYOND_64K |
514 | | void set_glyph_data (const HBUINT24 glyph_data[]) |
515 | | { |
516 | | match_glyph_data16 = nullptr; |
517 | | match_glyph_data24 = glyph_data; |
518 | | } |
519 | | #endif |
520 | | |
521 | | #ifndef HB_OPTIMIZE_SIZE |
522 | | HB_ALWAYS_INLINE |
523 | | #endif |
524 | | void reset (unsigned int start_index_) |
525 | 0 | { |
526 | 0 | idx = start_index_; |
527 | 0 | end = c->buffer->len; |
528 | 0 | matcher.syllable = start_index_ == c->buffer->idx ? c->buffer->cur().syllable () : 0; |
529 | 0 | } |
530 | | |
531 | | #ifndef HB_OPTIMIZE_SIZE |
532 | | HB_ALWAYS_INLINE |
533 | | #endif |
534 | | void reset_fast (unsigned int start_index_) |
535 | 0 | { |
536 | | // Doesn't set end or syllable. Used by GPOS which doesn't care / change. |
537 | 0 | idx = start_index_; |
538 | 0 | } |
539 | | |
540 | | #ifndef HB_OPTIMIZE_SIZE |
541 | | HB_ALWAYS_INLINE |
542 | | #endif |
543 | | matcher_t::may_skip_t may_skip (const hb_glyph_info_t &info) const |
544 | 0 | { return matcher.may_skip (c, info); } |
545 | | |
546 | | enum match_t { |
547 | | MATCH, |
548 | | NOT_MATCH, |
549 | | SKIP |
550 | | }; |
551 | | |
552 | | #ifndef HB_OPTIMIZE_SIZE |
553 | | HB_ALWAYS_INLINE |
554 | | #endif |
555 | | match_t match (hb_glyph_info_t &info) |
556 | 0 | { |
557 | 0 | matcher_t::may_skip_t skip = matcher.may_skip (c, info); |
558 | 0 | if (unlikely (skip == matcher_t::SKIP_YES)) |
559 | 0 | return SKIP; |
560 | | |
561 | 0 | matcher_t::may_match_t match = matcher.may_match (info, get_glyph_data ()); |
562 | 0 | if (match == matcher_t::MATCH_YES || |
563 | 0 | (match == matcher_t::MATCH_MAYBE && |
564 | 0 | skip == matcher_t::SKIP_NO)) |
565 | 0 | return MATCH; |
566 | | |
567 | 0 | if (skip == matcher_t::SKIP_NO) |
568 | 0 | return NOT_MATCH; |
569 | | |
570 | 0 | return SKIP; |
571 | 0 | } |
572 | | |
573 | | #ifndef HB_OPTIMIZE_SIZE |
574 | | HB_ALWAYS_INLINE |
575 | | #endif |
576 | | bool next (unsigned *unsafe_to = nullptr) |
577 | 0 | { |
578 | 0 | const signed stop = (signed) end - 1; |
579 | 0 | while ((signed) idx < stop) |
580 | 0 | { |
581 | 0 | idx++; |
582 | 0 | switch (match (c->buffer->info[idx])) |
583 | 0 | { |
584 | 0 | case MATCH: |
585 | 0 | { |
586 | 0 | advance_glyph_data (); |
587 | 0 | return true; |
588 | 0 | } |
589 | 0 | case NOT_MATCH: |
590 | 0 | { |
591 | 0 | if (unsafe_to) |
592 | 0 | *unsafe_to = idx + 1; |
593 | 0 | return false; |
594 | 0 | } |
595 | 0 | case SKIP: |
596 | 0 | continue; |
597 | 0 | } |
598 | 0 | } |
599 | 0 | if (unsafe_to) |
600 | 0 | *unsafe_to = end; |
601 | 0 | return false; |
602 | 0 | } |
603 | | #ifndef HB_OPTIMIZE_SIZE |
604 | | HB_ALWAYS_INLINE |
605 | | #endif |
606 | | bool prev (unsigned *unsafe_from = nullptr) |
607 | 0 | { |
608 | 0 | const unsigned stop = 0; |
609 | 0 | while (idx > stop) |
610 | 0 | { |
611 | 0 | idx--; |
612 | 0 | switch (match (c->buffer->out_info[idx])) |
613 | 0 | { |
614 | 0 | case MATCH: |
615 | 0 | { |
616 | 0 | advance_glyph_data (); |
617 | 0 | return true; |
618 | 0 | } |
619 | 0 | case NOT_MATCH: |
620 | 0 | { |
621 | 0 | if (unsafe_from) |
622 | 0 | *unsafe_from = hb_max (1u, idx) - 1u; |
623 | 0 | return false; |
624 | 0 | } |
625 | 0 | case SKIP: |
626 | 0 | continue; |
627 | 0 | } |
628 | 0 | } |
629 | 0 | if (unsafe_from) |
630 | 0 | *unsafe_from = 0; |
631 | 0 | return false; |
632 | 0 | } |
633 | | |
634 | | HB_ALWAYS_INLINE |
635 | | hb_codepoint_t |
636 | | get_glyph_data () |
637 | 0 | { |
638 | 0 | if (match_glyph_data16) return *match_glyph_data16; |
639 | | #ifndef HB_NO_BEYOND_64K |
640 | | else |
641 | | if (match_glyph_data24) return *match_glyph_data24; |
642 | | #endif |
643 | 0 | return 0; |
644 | 0 | } |
645 | | HB_ALWAYS_INLINE |
646 | | void |
647 | | advance_glyph_data () |
648 | 0 | { |
649 | 0 | if (match_glyph_data16) match_glyph_data16++; |
650 | | #ifndef HB_NO_BEYOND_64K |
651 | | else |
652 | | if (match_glyph_data24) match_glyph_data24++; |
653 | | #endif |
654 | 0 | } |
655 | | |
656 | | unsigned int idx; |
657 | | protected: |
658 | | context_t *c; |
659 | | matcher_t matcher; |
660 | | const HBUINT16 *match_glyph_data16; |
661 | | #ifndef HB_NO_BEYOND_64K |
662 | | const HBUINT24 *match_glyph_data24; |
663 | | #endif |
664 | | |
665 | | unsigned int end; |
666 | | }; |
667 | | |
668 | | struct hb_ot_apply_context_t : |
669 | | hb_dispatch_context_t<hb_ot_apply_context_t, bool, HB_DEBUG_APPLY> |
670 | | { |
671 | 0 | const char *get_name () { return "APPLY"; } |
672 | | typedef return_t (*recurse_func_t) (hb_ot_apply_context_t *c, unsigned int lookup_index); |
673 | | template <typename T> |
674 | 0 | return_t dispatch (const T &obj) { return obj.apply (this); } Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
675 | 0 | static return_t default_return_value () { return false; } |
676 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
677 | | return_t recurse (unsigned int sub_lookup_index) |
678 | 0 | { |
679 | 0 | if (unlikely (nesting_level_left == 0 || !recurse_func || buffer->max_ops-- <= 0)) |
680 | 0 | { |
681 | 0 | buffer->shaping_failed = true; |
682 | 0 | return default_return_value (); |
683 | 0 | } |
684 | | |
685 | 0 | nesting_level_left--; |
686 | 0 | bool ret = recurse_func (this, sub_lookup_index); |
687 | 0 | nesting_level_left++; |
688 | 0 | return ret; |
689 | 0 | } |
690 | | |
691 | | skipping_iterator_t<hb_ot_apply_context_t> iter_input, iter_context; |
692 | | |
693 | | unsigned int table_index; /* GSUB/GPOS */ |
694 | | hb_font_t *font; |
695 | | hb_face_t *face; |
696 | | hb_buffer_t *buffer; |
697 | | hb_sanitize_context_t sanitizer; |
698 | | recurse_func_t recurse_func = nullptr; |
699 | | const GDEF &gdef; |
700 | | const GDEF::accelerator_t &gdef_accel; |
701 | | const hb_ot_layout_lookup_accelerator_t *lookup_accel = nullptr; |
702 | | const ItemVariationStore &var_store; |
703 | | hb_scalar_cache_t *var_store_cache; |
704 | | hb_set_digest_t digest; |
705 | | |
706 | | hb_direction_t direction; |
707 | | hb_mask_t lookup_mask = 1; |
708 | | unsigned int lookup_index = (unsigned) -1; |
709 | | unsigned int lookup_props = 0; |
710 | | unsigned int nesting_level_left = HB_MAX_NESTING_LEVEL; |
711 | | |
712 | | bool has_glyph_classes; |
713 | | bool auto_zwnj = true; |
714 | | bool auto_zwj = true; |
715 | | bool per_syllable = false; |
716 | | bool random = false; |
717 | | unsigned new_syllables = (unsigned) -1; |
718 | | |
719 | | signed last_base = -1; // GPOS uses |
720 | | unsigned last_base_until = 0; // GPOS uses |
721 | | |
722 | | hb_ot_apply_context_t (unsigned int table_index_, |
723 | | hb_font_t *font_, |
724 | | hb_buffer_t *buffer_, |
725 | | hb_blob_t *table_blob_, |
726 | | hb_scalar_cache_t *var_store_cache_ = nullptr) : |
727 | 402k | table_index (table_index_), |
728 | 402k | font (font_), face (font->face), buffer (buffer_), |
729 | 402k | sanitizer (table_blob_), |
730 | | gdef ( |
731 | | #ifndef HB_NO_OT_LAYOUT |
732 | 402k | *face->table.GDEF->table |
733 | | #else |
734 | | Null (GDEF) |
735 | | #endif |
736 | | ), |
737 | | gdef_accel ( |
738 | | #ifndef HB_NO_OT_LAYOUT |
739 | 402k | *face->table.GDEF |
740 | | #else |
741 | | Null (GDEF::accelerator_t) |
742 | | #endif |
743 | | ), |
744 | 402k | var_store (gdef.get_var_store ()), |
745 | 402k | var_store_cache (var_store_cache_), |
746 | 402k | direction (buffer_->props.direction), |
747 | 402k | has_glyph_classes (gdef.has_glyph_classes ()) |
748 | 402k | { |
749 | 402k | init_iters (); |
750 | 402k | buffer->collect_codepoints (digest); |
751 | 402k | } |
752 | | |
753 | | void init_iters () |
754 | 402k | { |
755 | 402k | iter_input.init (this, false); |
756 | 402k | iter_context.init (this, true); |
757 | 402k | } |
758 | | |
759 | 315 | void set_lookup_mask (hb_mask_t mask, bool init = true) { lookup_mask = mask; last_base = -1; last_base_until = 0; if (init) init_iters (); } |
760 | 315 | void set_auto_zwj (bool auto_zwj_, bool init = true) { auto_zwj = auto_zwj_; if (init) init_iters (); } |
761 | 315 | void set_auto_zwnj (bool auto_zwnj_, bool init = true) { auto_zwnj = auto_zwnj_; if (init) init_iters (); } |
762 | 315 | void set_per_syllable (bool per_syllable_, bool init = true) { per_syllable = per_syllable_; if (init) init_iters (); } |
763 | 315 | void set_random (bool random_) { random = random_; } |
764 | 402k | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
765 | 315 | void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; } |
766 | 315 | void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; init_iters (); } |
767 | | |
768 | | uint32_t random_number () |
769 | 0 | { |
770 | | /* http://www.cplusplus.com/reference/random/minstd_rand/ */ |
771 | 0 | buffer->random_state = buffer->random_state * 48271 % 2147483647; |
772 | 0 | return buffer->random_state; |
773 | 0 | } |
774 | | |
775 | | bool match_properties_mark (hb_codepoint_t glyph, |
776 | | unsigned int glyph_props, |
777 | | unsigned int match_props) const |
778 | 0 | { |
779 | | /* If using mark filtering sets, the high short of |
780 | | * match_props has the set index. |
781 | | */ |
782 | 0 | if (match_props & LookupFlag::UseMarkFilteringSet) |
783 | 0 | return gdef_accel.mark_set_covers (match_props >> 16, glyph); |
784 | | |
785 | | /* The second byte of match_props has the meaning |
786 | | * "ignore marks of attachment type different than |
787 | | * the attachment type specified." |
788 | | */ |
789 | 0 | if (match_props & LookupFlag::MarkAttachmentType) |
790 | 0 | return (match_props & LookupFlag::MarkAttachmentType) == (glyph_props & LookupFlag::MarkAttachmentType); |
791 | | |
792 | 0 | return true; |
793 | 0 | } |
794 | | |
795 | | #ifndef HB_OPTIMIZE_SIZE |
796 | | HB_ALWAYS_INLINE |
797 | | #endif |
798 | | bool check_glyph_property (const hb_glyph_info_t *info, |
799 | | unsigned int match_props) const |
800 | 57 | { |
801 | 57 | unsigned int glyph_props = _hb_glyph_info_get_glyph_props (info); |
802 | | |
803 | | /* Not covered, if, for example, glyph class is ligature and |
804 | | * match_props includes LookupFlags::IgnoreLigatures |
805 | | */ |
806 | 57 | if (glyph_props & match_props & LookupFlag::IgnoreFlags) |
807 | 0 | return false; |
808 | | |
809 | 57 | if (unlikely (glyph_props & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) |
810 | 0 | return match_properties_mark (info->codepoint, glyph_props, match_props); |
811 | | |
812 | 57 | return true; |
813 | 57 | } |
814 | | |
815 | | void _set_glyph_class (hb_codepoint_t glyph_index, |
816 | | unsigned int class_guess = 0, |
817 | | bool ligature = false, |
818 | | bool component = false) |
819 | 0 | { |
820 | 0 | digest.add (glyph_index); |
821 | |
|
822 | 0 | if (new_syllables != (unsigned) -1) |
823 | 0 | buffer->cur().syllable() = new_syllables; |
824 | |
|
825 | 0 | unsigned int props = _hb_glyph_info_get_glyph_props (&buffer->cur()); |
826 | 0 | props |= HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED; |
827 | 0 | if (ligature) |
828 | 0 | { |
829 | 0 | props |= HB_OT_LAYOUT_GLYPH_PROPS_LIGATED; |
830 | | /* In the only place that the MULTIPLIED bit is used, Uniscribe |
831 | | * seems to only care about the "last" transformation between |
832 | | * Ligature and Multiple substitutions. Ie. if you ligate, expand, |
833 | | * and ligate again, it forgives the multiplication and acts as |
834 | | * if only ligation happened. As such, clear MULTIPLIED bit. |
835 | | */ |
836 | 0 | props &= ~HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED; |
837 | 0 | } |
838 | 0 | if (component) |
839 | 0 | props |= HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED; |
840 | 0 | if (likely (has_glyph_classes)) |
841 | 0 | { |
842 | 0 | props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE; |
843 | 0 | _hb_glyph_info_set_glyph_props (&buffer->cur(), props | gdef_accel.get_glyph_props (glyph_index)); |
844 | 0 | } |
845 | 0 | else if (class_guess) |
846 | 0 | { |
847 | 0 | props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE; |
848 | 0 | _hb_glyph_info_set_glyph_props (&buffer->cur(), props | class_guess); |
849 | 0 | } |
850 | 0 | else |
851 | 0 | _hb_glyph_info_set_glyph_props (&buffer->cur(), props); |
852 | 0 | } |
853 | | |
854 | | void replace_glyph (hb_codepoint_t glyph_index) |
855 | 0 | { |
856 | 0 | _set_glyph_class (glyph_index); |
857 | 0 | (void) buffer->replace_glyph (glyph_index); |
858 | 0 | } |
859 | | void replace_glyph_inplace (hb_codepoint_t glyph_index) |
860 | 0 | { |
861 | 0 | _set_glyph_class (glyph_index); |
862 | 0 | buffer->cur().codepoint = glyph_index; |
863 | 0 | } |
864 | | void replace_glyph_with_ligature (hb_codepoint_t glyph_index, |
865 | | unsigned int class_guess) |
866 | 0 | { |
867 | 0 | _set_glyph_class (glyph_index, class_guess, true); |
868 | 0 | (void) buffer->replace_glyph (glyph_index); |
869 | 0 | } |
870 | | void output_glyph_for_component (hb_codepoint_t glyph_index, |
871 | | unsigned int class_guess) |
872 | 0 | { |
873 | 0 | _set_glyph_class (glyph_index, class_guess, false, true); |
874 | 0 | (void) buffer->output_glyph (glyph_index); |
875 | 0 | } |
876 | | }; |
877 | | |
878 | | enum class hb_ot_lookup_cache_op_t |
879 | | { |
880 | | CREATE, |
881 | | ENTER, |
882 | | LEAVE, |
883 | | DESTROY, |
884 | | }; |
885 | | |
886 | | struct hb_accelerate_subtables_context_t : |
887 | | hb_dispatch_context_t<hb_accelerate_subtables_context_t> |
888 | | { |
889 | | template <typename Type> |
890 | | static inline bool apply_to (const void *obj, hb_ot_apply_context_t *c) |
891 | 57 | { |
892 | 57 | const Type *typed_obj = (const Type *) obj; |
893 | 57 | return typed_obj->apply (c); |
894 | 57 | } Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::SinglePosFormat1>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::SinglePosFormat2>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::CursivePosFormat1>(void const*, OT::hb_ot_apply_context_t*) bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Line | Count | Source | 891 | 57 | { | 892 | 57 | const Type *typed_obj = (const Type *) obj; | 893 | 57 | return typed_obj->apply (c); | 894 | 57 | } |
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ContextFormat3>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ChainContextFormat3>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(void const*, OT::hb_ot_apply_context_t*) |
895 | | |
896 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
897 | | template <typename T> |
898 | | static inline auto apply_cached_ (const T *obj, hb_ot_apply_context_t *c, hb_priority<1>) HB_RETURN (bool, obj->apply_cached (c) ) |
899 | | template <typename T> |
900 | | static inline auto apply_cached_ (const T *obj, hb_ot_apply_context_t *c, hb_priority<0>) HB_RETURN (bool, obj->apply (c) ) |
901 | | template <typename Type> |
902 | | static inline bool apply_cached_to (const void *obj, hb_ot_apply_context_t *c) |
903 | 0 | { |
904 | 0 | const Type *typed_obj = (const Type *) obj; |
905 | 0 | return apply_cached_ (typed_obj, c, hb_prioritize); |
906 | 0 | } Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::SinglePosFormat1>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::SinglePosFormat2>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::CursivePosFormat1>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ContextFormat3>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ChainContextFormat3>(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*) Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(void const*, OT::hb_ot_apply_context_t*) |
907 | | |
908 | | template <typename T> |
909 | | static inline auto cache_func_ (void *p, |
910 | | hb_ot_lookup_cache_op_t op, |
911 | | hb_priority<1>) HB_RETURN (void *, T::cache_func (p, op) ) |
912 | | template <typename T=void> |
913 | | static inline void * cache_func_ (void *p, |
914 | | hb_ot_lookup_cache_op_t op HB_UNUSED, |
915 | 0 | hb_priority<0>) { return (void *) false; } Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::SinglePosFormat1>(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::SinglePosFormat2>(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::CursivePosFormat1>(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::ContextFormat3>(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::ChainContextFormat3>(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(void*, OT::hb_ot_lookup_cache_op_t, hb_priority<0u>) |
916 | | template <typename Type> |
917 | | static inline void * cache_func_to (void *p, |
918 | | hb_ot_lookup_cache_op_t op) |
919 | 92 | { |
920 | 92 | return cache_func_<Type> (p, op, hb_prioritize); |
921 | 92 | } Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::SinglePosFormat1>(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::SinglePosFormat2>(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::CursivePosFormat1>(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ContextFormat3>(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Line | Count | Source | 919 | 92 | { | 920 | 92 | return cache_func_<Type> (p, op, hb_prioritize); | 921 | 92 | } |
Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ChainContextFormat3>(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(void*, OT::hb_ot_lookup_cache_op_t) Unexecuted instantiation: void* OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(void*, OT::hb_ot_lookup_cache_op_t) |
922 | | #endif |
923 | | |
924 | | typedef bool (*hb_apply_func_t) (const void *obj, hb_ot_apply_context_t *c); |
925 | | typedef void * (*hb_cache_func_t) (void *p, hb_ot_lookup_cache_op_t op); |
926 | | |
927 | | struct hb_applicable_t |
928 | | { |
929 | | friend struct hb_accelerate_subtables_context_t; |
930 | | friend struct hb_ot_layout_lookup_accelerator_t; |
931 | | |
932 | | template <typename T> |
933 | | void init (const T &obj_, |
934 | | hb_apply_func_t apply_func_ |
935 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
936 | | , hb_apply_func_t apply_cached_func_ |
937 | | , hb_cache_func_t cache_func_ |
938 | | #endif |
939 | | ) |
940 | 400 | { |
941 | 400 | obj = &obj_; |
942 | 400 | apply_func = apply_func_; |
943 | 400 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
944 | 400 | apply_cached_func = apply_cached_func_; |
945 | 400 | cache_func = cache_func_; |
946 | 400 | #endif |
947 | 400 | digest.init (); |
948 | 400 | obj_.get_coverage ().collect_coverage (&digest); |
949 | 400 | } Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Line | Count | Source | 940 | 147 | { | 941 | 147 | obj = &obj_; | 942 | 147 | apply_func = apply_func_; | 943 | 147 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 944 | 147 | apply_cached_func = apply_cached_func_; | 945 | 147 | cache_func = cache_func_; | 946 | 147 | #endif | 947 | 147 | digest.init (); | 948 | 147 | obj_.get_coverage ().collect_coverage (&digest); | 949 | 147 | } |
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Line | Count | Source | 940 | 39 | { | 941 | 39 | obj = &obj_; | 942 | 39 | apply_func = apply_func_; | 943 | 39 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 944 | 39 | apply_cached_func = apply_cached_func_; | 945 | 39 | cache_func = cache_func_; | 946 | 39 | #endif | 947 | 39 | digest.init (); | 948 | 39 | obj_.get_coverage ().collect_coverage (&digest); | 949 | 39 | } |
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Line | Count | Source | 940 | 42 | { | 941 | 42 | obj = &obj_; | 942 | 42 | apply_func = apply_func_; | 943 | 42 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 944 | 42 | apply_cached_func = apply_cached_func_; | 945 | 42 | cache_func = cache_func_; | 946 | 42 | #endif | 947 | 42 | digest.init (); | 948 | 42 | obj_.get_coverage ().collect_coverage (&digest); | 949 | 42 | } |
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ContextFormat3>(OT::ContextFormat3 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Line | Count | Source | 940 | 118 | { | 941 | 118 | obj = &obj_; | 942 | 118 | apply_func = apply_func_; | 943 | 118 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 944 | 118 | apply_cached_func = apply_cached_func_; | 945 | 118 | cache_func = cache_func_; | 946 | 118 | #endif | 947 | 118 | digest.init (); | 948 | 118 | obj_.get_coverage ().collect_coverage (&digest); | 949 | 118 | } |
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Line | Count | Source | 940 | 9 | { | 941 | 9 | obj = &obj_; | 942 | 9 | apply_func = apply_func_; | 943 | 9 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 944 | 9 | apply_cached_func = apply_cached_func_; | 945 | 9 | cache_func = cache_func_; | 946 | 9 | #endif | 947 | 9 | digest.init (); | 948 | 9 | obj_.get_coverage ().collect_coverage (&digest); | 949 | 9 | } |
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) Line | Count | Source | 940 | 45 | { | 941 | 45 | obj = &obj_; | 942 | 45 | apply_func = apply_func_; | 943 | 45 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 944 | 45 | apply_cached_func = apply_cached_func_; | 945 | 45 | cache_func = cache_func_; | 946 | 45 | #endif | 947 | 45 | digest.init (); | 948 | 45 | obj_.get_coverage ().collect_coverage (&digest); | 949 | 45 | } |
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*), bool (*)(void const*, OT::hb_ot_apply_context_t*), void* (*)(void*, OT::hb_ot_lookup_cache_op_t)) |
950 | | |
951 | | bool apply (hb_ot_apply_context_t *c) const |
952 | 342 | { |
953 | 342 | return digest.may_have (c->buffer->cur().codepoint) && apply_func (obj, c); |
954 | 342 | } |
955 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
956 | | bool apply_cached (hb_ot_apply_context_t *c) const |
957 | 0 | { |
958 | 0 | return digest.may_have (c->buffer->cur().codepoint) && apply_cached_func (obj, c); |
959 | 0 | } |
960 | | bool cache_enter (hb_ot_apply_context_t *c) const |
961 | 0 | { |
962 | 0 | return (bool) cache_func (c, hb_ot_lookup_cache_op_t::ENTER); |
963 | 0 | } |
964 | | void cache_leave (hb_ot_apply_context_t *c) const |
965 | 0 | { |
966 | 0 | cache_func (c, hb_ot_lookup_cache_op_t::LEAVE); |
967 | 0 | } |
968 | | #endif |
969 | | |
970 | | private: |
971 | | const void *obj; |
972 | | hb_apply_func_t apply_func; |
973 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
974 | | hb_apply_func_t apply_cached_func; |
975 | | hb_cache_func_t cache_func; |
976 | | #endif |
977 | | hb_set_digest_t digest; |
978 | | }; |
979 | | |
980 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
981 | | template <typename T> |
982 | | auto cache_cost (const T &obj, hb_priority<1>) HB_AUTO_RETURN ( obj.cache_cost () ) |
983 | | template <typename T> |
984 | | auto cache_cost (const T &obj, hb_priority<0>) HB_AUTO_RETURN ( 0u ) |
985 | | #endif |
986 | | |
987 | | /* Dispatch interface. */ |
988 | | template <typename T> |
989 | | return_t dispatch (const T &obj) |
990 | 400 | { |
991 | 400 | hb_applicable_t *entry = &array[i++]; |
992 | | |
993 | 400 | entry->init (obj, |
994 | 400 | apply_to<T> |
995 | 400 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
996 | 400 | , apply_cached_to<T> |
997 | 400 | , cache_func_to<T> |
998 | 400 | #endif |
999 | 400 | ); |
1000 | | |
1001 | 400 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
1002 | | /* Cache handling |
1003 | | * |
1004 | | * We allow one subtable from each lookup to use a cache. The assumption |
1005 | | * being that multiple subtables of the same lookup cannot use a cache |
1006 | | * because the resources they would use will collide. As such, we ask |
1007 | | * each subtable to tell us how much it costs (which a cache would avoid), |
1008 | | * and we allocate the cache opportunity to the costliest subtable. |
1009 | | */ |
1010 | 400 | unsigned cost = cache_cost (obj, hb_prioritize); |
1011 | 400 | if (cost > cache_user_cost) |
1012 | 91 | { |
1013 | 91 | cache_user_idx = i - 1; |
1014 | 91 | cache_user_cost = cost; |
1015 | 91 | } |
1016 | 400 | #endif |
1017 | | |
1018 | 400 | return hb_empty_t (); |
1019 | 400 | } Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Line | Count | Source | 990 | 147 | { | 991 | 147 | hb_applicable_t *entry = &array[i++]; | 992 | | | 993 | 147 | entry->init (obj, | 994 | 147 | apply_to<T> | 995 | 147 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 996 | 147 | , apply_cached_to<T> | 997 | 147 | , cache_func_to<T> | 998 | 147 | #endif | 999 | 147 | ); | 1000 | | | 1001 | 147 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 1002 | | /* Cache handling | 1003 | | * | 1004 | | * We allow one subtable from each lookup to use a cache. The assumption | 1005 | | * being that multiple subtables of the same lookup cannot use a cache | 1006 | | * because the resources they would use will collide. As such, we ask | 1007 | | * each subtable to tell us how much it costs (which a cache would avoid), | 1008 | | * and we allocate the cache opportunity to the costliest subtable. | 1009 | | */ | 1010 | 147 | unsigned cost = cache_cost (obj, hb_prioritize); | 1011 | 147 | if (cost > cache_user_cost) | 1012 | 0 | { | 1013 | 0 | cache_user_idx = i - 1; | 1014 | 0 | cache_user_cost = cost; | 1015 | 0 | } | 1016 | 147 | #endif | 1017 | | | 1018 | 147 | return hb_empty_t (); | 1019 | 147 | } |
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Line | Count | Source | 990 | 39 | { | 991 | 39 | hb_applicable_t *entry = &array[i++]; | 992 | | | 993 | 39 | entry->init (obj, | 994 | 39 | apply_to<T> | 995 | 39 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 996 | 39 | , apply_cached_to<T> | 997 | 39 | , cache_func_to<T> | 998 | 39 | #endif | 999 | 39 | ); | 1000 | | | 1001 | 39 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 1002 | | /* Cache handling | 1003 | | * | 1004 | | * We allow one subtable from each lookup to use a cache. The assumption | 1005 | | * being that multiple subtables of the same lookup cannot use a cache | 1006 | | * because the resources they would use will collide. As such, we ask | 1007 | | * each subtable to tell us how much it costs (which a cache would avoid), | 1008 | | * and we allocate the cache opportunity to the costliest subtable. | 1009 | | */ | 1010 | 39 | unsigned cost = cache_cost (obj, hb_prioritize); | 1011 | 39 | if (cost > cache_user_cost) | 1012 | 0 | { | 1013 | 0 | cache_user_idx = i - 1; | 1014 | 0 | cache_user_cost = cost; | 1015 | 0 | } | 1016 | 39 | #endif | 1017 | | | 1018 | 39 | return hb_empty_t (); | 1019 | 39 | } |
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Line | Count | Source | 990 | 42 | { | 991 | 42 | hb_applicable_t *entry = &array[i++]; | 992 | | | 993 | 42 | entry->init (obj, | 994 | 42 | apply_to<T> | 995 | 42 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 996 | 42 | , apply_cached_to<T> | 997 | 42 | , cache_func_to<T> | 998 | 42 | #endif | 999 | 42 | ); | 1000 | | | 1001 | 42 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 1002 | | /* Cache handling | 1003 | | * | 1004 | | * We allow one subtable from each lookup to use a cache. The assumption | 1005 | | * being that multiple subtables of the same lookup cannot use a cache | 1006 | | * because the resources they would use will collide. As such, we ask | 1007 | | * each subtable to tell us how much it costs (which a cache would avoid), | 1008 | | * and we allocate the cache opportunity to the costliest subtable. | 1009 | | */ | 1010 | 42 | unsigned cost = cache_cost (obj, hb_prioritize); | 1011 | 42 | if (cost > cache_user_cost) | 1012 | 0 | { | 1013 | 0 | cache_user_idx = i - 1; | 1014 | 0 | cache_user_cost = cost; | 1015 | 0 | } | 1016 | 42 | #endif | 1017 | | | 1018 | 42 | return hb_empty_t (); | 1019 | 42 | } |
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Line | Count | Source | 990 | 118 | { | 991 | 118 | hb_applicable_t *entry = &array[i++]; | 992 | | | 993 | 118 | entry->init (obj, | 994 | 118 | apply_to<T> | 995 | 118 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 996 | 118 | , apply_cached_to<T> | 997 | 118 | , cache_func_to<T> | 998 | 118 | #endif | 999 | 118 | ); | 1000 | | | 1001 | 118 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 1002 | | /* Cache handling | 1003 | | * | 1004 | | * We allow one subtable from each lookup to use a cache. The assumption | 1005 | | * being that multiple subtables of the same lookup cannot use a cache | 1006 | | * because the resources they would use will collide. As such, we ask | 1007 | | * each subtable to tell us how much it costs (which a cache would avoid), | 1008 | | * and we allocate the cache opportunity to the costliest subtable. | 1009 | | */ | 1010 | 118 | unsigned cost = cache_cost (obj, hb_prioritize); | 1011 | 118 | if (cost > cache_user_cost) | 1012 | 46 | { | 1013 | 46 | cache_user_idx = i - 1; | 1014 | 46 | cache_user_cost = cost; | 1015 | 46 | } | 1016 | 118 | #endif | 1017 | | | 1018 | 118 | return hb_empty_t (); | 1019 | 118 | } |
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Line | Count | Source | 990 | 9 | { | 991 | 9 | hb_applicable_t *entry = &array[i++]; | 992 | | | 993 | 9 | entry->init (obj, | 994 | 9 | apply_to<T> | 995 | 9 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 996 | 9 | , apply_cached_to<T> | 997 | 9 | , cache_func_to<T> | 998 | 9 | #endif | 999 | 9 | ); | 1000 | | | 1001 | 9 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 1002 | | /* Cache handling | 1003 | | * | 1004 | | * We allow one subtable from each lookup to use a cache. The assumption | 1005 | | * being that multiple subtables of the same lookup cannot use a cache | 1006 | | * because the resources they would use will collide. As such, we ask | 1007 | | * each subtable to tell us how much it costs (which a cache would avoid), | 1008 | | * and we allocate the cache opportunity to the costliest subtable. | 1009 | | */ | 1010 | 9 | unsigned cost = cache_cost (obj, hb_prioritize); | 1011 | 9 | if (cost > cache_user_cost) | 1012 | 0 | { | 1013 | 0 | cache_user_idx = i - 1; | 1014 | 0 | cache_user_cost = cost; | 1015 | 0 | } | 1016 | 9 | #endif | 1017 | | | 1018 | 9 | return hb_empty_t (); | 1019 | 9 | } |
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Line | Count | Source | 990 | 45 | { | 991 | 45 | hb_applicable_t *entry = &array[i++]; | 992 | | | 993 | 45 | entry->init (obj, | 994 | 45 | apply_to<T> | 995 | 45 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 996 | 45 | , apply_cached_to<T> | 997 | 45 | , cache_func_to<T> | 998 | 45 | #endif | 999 | 45 | ); | 1000 | | | 1001 | 45 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 1002 | | /* Cache handling | 1003 | | * | 1004 | | * We allow one subtable from each lookup to use a cache. The assumption | 1005 | | * being that multiple subtables of the same lookup cannot use a cache | 1006 | | * because the resources they would use will collide. As such, we ask | 1007 | | * each subtable to tell us how much it costs (which a cache would avoid), | 1008 | | * and we allocate the cache opportunity to the costliest subtable. | 1009 | | */ | 1010 | 45 | unsigned cost = cache_cost (obj, hb_prioritize); | 1011 | 45 | if (cost > cache_user_cost) | 1012 | 45 | { | 1013 | 45 | cache_user_idx = i - 1; | 1014 | 45 | cache_user_cost = cost; | 1015 | 45 | } | 1016 | 45 | #endif | 1017 | | | 1018 | 45 | return hb_empty_t (); | 1019 | 45 | } |
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
1020 | 220 | static return_t default_return_value () { return hb_empty_t (); } |
1021 | | |
1022 | | hb_accelerate_subtables_context_t (hb_applicable_t *array_) : |
1023 | 220 | array (array_) {} |
1024 | | |
1025 | | hb_applicable_t *array; |
1026 | | unsigned i = 0; |
1027 | | |
1028 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
1029 | | unsigned cache_user_idx = (unsigned) -1; |
1030 | | unsigned cache_user_cost = 0; |
1031 | | #endif |
1032 | | }; |
1033 | | |
1034 | | |
1035 | | typedef bool (*intersects_func_t) (const hb_set_t *glyphs, unsigned value, const void *data, void *cache); |
1036 | | typedef void (*intersected_glyphs_func_t) (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, void *cache); |
1037 | | typedef void (*collect_glyphs_func_t) (hb_set_t *glyphs, unsigned value, const void *data); |
1038 | | typedef bool (*match_func_t) (hb_glyph_info_t &info, unsigned value, const void *data); |
1039 | | |
1040 | | struct ContextClosureFuncs |
1041 | | { |
1042 | | intersects_func_t intersects; |
1043 | | intersected_glyphs_func_t intersected_glyphs; |
1044 | | }; |
1045 | | struct ContextCollectGlyphsFuncs |
1046 | | { |
1047 | | collect_glyphs_func_t collect; |
1048 | | }; |
1049 | | struct ContextApplyFuncs |
1050 | | { |
1051 | | match_func_t match; |
1052 | | }; |
1053 | | struct ChainContextApplyFuncs |
1054 | | { |
1055 | | match_func_t match[3]; |
1056 | | }; |
1057 | | |
1058 | | |
1059 | | static inline bool intersects_glyph (const hb_set_t *glyphs, unsigned value, const void *data HB_UNUSED, void *cache HB_UNUSED) |
1060 | 0 | { |
1061 | 0 | return glyphs->has (value); |
1062 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-aat-layout.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-layout.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*) |
1063 | | static inline bool intersects_class (const hb_set_t *glyphs, unsigned value, const void *data, void *cache) |
1064 | 0 | { |
1065 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1066 | 0 | hb_map_t *map = (hb_map_t *) cache; |
1067 | |
|
1068 | 0 | hb_codepoint_t *cached_v; |
1069 | 0 | if (map->has (value, &cached_v)) |
1070 | 0 | return *cached_v; |
1071 | | |
1072 | 0 | bool v = class_def.intersects_class (glyphs, value); |
1073 | 0 | map->set (value, v); |
1074 | |
|
1075 | 0 | return v; |
1076 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-aat-layout.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-layout.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*) |
1077 | | static inline bool intersects_coverage (const hb_set_t *glyphs, unsigned value, const void *data, void *cache HB_UNUSED) |
1078 | 0 | { |
1079 | 0 | Offset16To<Coverage> coverage; |
1080 | 0 | coverage = value; |
1081 | 0 | return (data+coverage).intersects (glyphs); |
1082 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-aat-layout.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-layout.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*) |
1083 | | |
1084 | | |
1085 | | static inline void intersected_glyph (const hb_set_t *glyphs HB_UNUSED, const void *data, unsigned value, hb_set_t *intersected_glyphs, HB_UNUSED void *cache) |
1086 | 0 | { |
1087 | 0 | unsigned g = reinterpret_cast<const HBUINT16 *>(data)[value]; |
1088 | 0 | intersected_glyphs->add (g); |
1089 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-aat-layout.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-layout.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) |
1090 | | |
1091 | | using intersected_class_cache_t = hb_hashmap_t<unsigned, hb_set_t>; |
1092 | | |
1093 | | static inline void intersected_class_glyphs (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, void *cache) |
1094 | 0 | { |
1095 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1096 | |
|
1097 | 0 | intersected_class_cache_t *map = (intersected_class_cache_t *) cache; |
1098 | |
|
1099 | 0 | hb_set_t *cached_v; |
1100 | 0 | if (map->has (value, &cached_v)) |
1101 | 0 | { |
1102 | 0 | intersected_glyphs->union_ (*cached_v); |
1103 | 0 | return; |
1104 | 0 | } |
1105 | | |
1106 | 0 | hb_set_t v; |
1107 | 0 | class_def.intersected_class_glyphs (glyphs, value, &v); |
1108 | |
|
1109 | 0 | intersected_glyphs->union_ (v); |
1110 | |
|
1111 | 0 | map->set (value, std::move (v)); |
1112 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-aat-layout.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-layout.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) |
1113 | | |
1114 | | static inline void intersected_coverage_glyphs (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, HB_UNUSED void *cache) |
1115 | 0 | { |
1116 | 0 | Offset16To<Coverage> coverage; |
1117 | 0 | coverage = value; |
1118 | 0 | (data+coverage).intersect_set (*glyphs, *intersected_glyphs); |
1119 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-aat-layout.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-layout.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*) |
1120 | | |
1121 | | |
1122 | | template <typename HBUINT> |
1123 | | static inline bool array_is_subset_of (const hb_set_t *glyphs, |
1124 | | unsigned int count, |
1125 | | const HBUINT values[], |
1126 | | intersects_func_t intersects_func, |
1127 | | const void *intersects_data, |
1128 | | void *cache) |
1129 | 0 | { |
1130 | 0 | for (const auto &_ : + hb_iter (values, count)) |
1131 | 0 | if (!intersects_func (glyphs, _, intersects_data, cache)) return false; |
1132 | 0 | return true; |
1133 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*) Unexecuted instantiation: hb-aat-layout.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*) Unexecuted instantiation: hb-ot-layout.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*) |
1134 | | |
1135 | | |
1136 | | static inline void collect_glyph (hb_set_t *glyphs, unsigned value, const void *data HB_UNUSED) |
1137 | 0 | { |
1138 | 0 | glyphs->add (value); |
1139 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*) |
1140 | | static inline void collect_class (hb_set_t *glyphs, unsigned value, const void *data) |
1141 | 0 | { |
1142 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1143 | 0 | class_def.collect_class (glyphs, value); |
1144 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::collect_class(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::collect_class(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::collect_class(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::collect_class(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::collect_class(hb_set_t*, unsigned int, void const*) |
1145 | | static inline void collect_coverage (hb_set_t *glyphs, unsigned value, const void *data) |
1146 | 0 | { |
1147 | 0 | Offset16To<Coverage> coverage; |
1148 | 0 | coverage = value; |
1149 | 0 | (data+coverage).collect_coverage (glyphs); |
1150 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*) |
1151 | | template <typename HBUINT> |
1152 | | static inline void collect_array (hb_collect_glyphs_context_t *c HB_UNUSED, |
1153 | | hb_set_t *glyphs, |
1154 | | unsigned int count, |
1155 | | const HBUINT values[], |
1156 | | collect_glyphs_func_t collect_func, |
1157 | | const void *collect_data) |
1158 | 0 | { |
1159 | 0 | return |
1160 | 0 | + hb_iter (values, count) |
1161 | 0 | | hb_apply ([&] (const HBUINT &_) { collect_func (glyphs, _, collect_data); }) |
1162 | 0 | ; |
1163 | 0 | } Unexecuted instantiation: hb-ot-face.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*) Unexecuted instantiation: hb-aat-layout.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*) Unexecuted instantiation: hb-ot-layout.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*) |
1164 | | |
1165 | | |
1166 | | static inline bool match_always (hb_glyph_info_t &info HB_UNUSED, unsigned value HB_UNUSED, const void *data HB_UNUSED) |
1167 | 0 | { |
1168 | 0 | return true; |
1169 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*) |
1170 | | static inline bool match_glyph (hb_glyph_info_t &info, unsigned value, const void *data HB_UNUSED) |
1171 | 0 | { |
1172 | 0 | return info.codepoint == value; |
1173 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*) |
1174 | | static inline bool match_class (hb_glyph_info_t &info, unsigned value, const void *data) |
1175 | 0 | { |
1176 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1177 | 0 | return class_def.get_class (info.codepoint) == value; |
1178 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*) |
1179 | | static inline bool match_class_cached (hb_glyph_info_t &info, unsigned value, const void *data) |
1180 | 0 | { |
1181 | 0 | unsigned klass = info.syllable(); |
1182 | 0 | if (klass < 255) |
1183 | 0 | return klass == value; |
1184 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1185 | 0 | klass = class_def.get_class (info.codepoint); |
1186 | 0 | if (likely (klass < 255)) |
1187 | 0 | info.syllable() = klass; |
1188 | 0 | return klass == value; |
1189 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*) |
1190 | | static inline bool match_class_cached1 (hb_glyph_info_t &info, unsigned value, const void *data) |
1191 | 0 | { |
1192 | 0 | unsigned klass = info.syllable() & 0x0F; |
1193 | 0 | if (klass < 15) |
1194 | 0 | return klass == value; |
1195 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1196 | 0 | klass = class_def.get_class (info.codepoint); |
1197 | 0 | if (likely (klass < 15)) |
1198 | 0 | info.syllable() = (info.syllable() & 0xF0) | klass; |
1199 | 0 | return klass == value; |
1200 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*) |
1201 | | static inline bool match_class_cached2 (hb_glyph_info_t &info, unsigned value, const void *data) |
1202 | 0 | { |
1203 | 0 | unsigned klass = (info.syllable() & 0xF0) >> 4; |
1204 | 0 | if (klass < 15) |
1205 | 0 | return klass == value; |
1206 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1207 | 0 | klass = class_def.get_class (info.codepoint); |
1208 | 0 | if (likely (klass < 15)) |
1209 | 0 | info.syllable() = (info.syllable() & 0x0F) | (klass << 4); |
1210 | 0 | return klass == value; |
1211 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*) |
1212 | | static inline bool match_coverage (hb_glyph_info_t &info, unsigned value, const void *data) |
1213 | 0 | { |
1214 | 0 | Offset16To<Coverage> coverage; |
1215 | 0 | coverage = value; |
1216 | 0 | return (data+coverage).get_coverage (info.codepoint) != NOT_COVERED; |
1217 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-aat-layout.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-layout.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*) |
1218 | | |
1219 | | template <typename HBUINT> |
1220 | | static inline bool would_match_input (hb_would_apply_context_t *c, |
1221 | | unsigned int count, /* Including the first glyph (not matched) */ |
1222 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1223 | | match_func_t match_func, |
1224 | | const void *match_data) |
1225 | 0 | { |
1226 | 0 | if (count != c->len) |
1227 | 0 | return false; |
1228 | | |
1229 | 0 | for (unsigned int i = 1; i < count; i++) |
1230 | 0 | { |
1231 | 0 | hb_glyph_info_t info; |
1232 | 0 | info.codepoint = c->glyphs[i]; |
1233 | 0 | if (likely (!match_func (info, input[i - 1], match_data))) |
1234 | 0 | return false; |
1235 | 0 | } |
1236 | | |
1237 | 0 | return true; |
1238 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*) Unexecuted instantiation: hb-aat-layout.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*) Unexecuted instantiation: hb-ot-layout.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*) |
1239 | | template <typename HBUINT> |
1240 | | #ifndef HB_OPTIMIZE_SIZE |
1241 | | HB_ALWAYS_INLINE |
1242 | | #endif |
1243 | | static bool match_input (hb_ot_apply_context_t *c, |
1244 | | unsigned int count, /* Including the first glyph (not matched) */ |
1245 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1246 | | match_func_t match_func, |
1247 | | const void *match_data, |
1248 | | unsigned int *end_position, |
1249 | | unsigned int *match_positions, |
1250 | | unsigned int *p_total_component_count = nullptr) |
1251 | 0 | { |
1252 | 0 | TRACE_APPLY (nullptr); |
1253 | |
|
1254 | 0 | if (unlikely (count > HB_MAX_CONTEXT_LENGTH)) return_trace (false); |
1255 | | |
1256 | 0 | hb_buffer_t *buffer = c->buffer; |
1257 | |
|
1258 | 0 | auto &skippy_iter = c->iter_input; |
1259 | 0 | skippy_iter.reset (buffer->idx); |
1260 | 0 | skippy_iter.set_match_func (match_func, match_data); |
1261 | 0 | skippy_iter.set_glyph_data (input); |
1262 | | |
1263 | | /* |
1264 | | * This is perhaps the trickiest part of OpenType... Remarks: |
1265 | | * |
1266 | | * - If all components of the ligature were marks, we call this a mark ligature. |
1267 | | * |
1268 | | * - If there is no GDEF, and the ligature is NOT a mark ligature, we categorize |
1269 | | * it as a ligature glyph. |
1270 | | * |
1271 | | * - Ligatures cannot be formed across glyphs attached to different components |
1272 | | * of previous ligatures. Eg. the sequence is LAM,SHADDA,LAM,FATHA,HEH, and |
1273 | | * LAM,LAM,HEH form a ligature, leaving SHADDA,FATHA next to eachother. |
1274 | | * However, it would be wrong to ligate that SHADDA,FATHA sequence. |
1275 | | * There are a couple of exceptions to this: |
1276 | | * |
1277 | | * o If a ligature tries ligating with marks that belong to it itself, go ahead, |
1278 | | * assuming that the font designer knows what they are doing (otherwise it can |
1279 | | * break Indic stuff when a matra wants to ligate with a conjunct, |
1280 | | * |
1281 | | * o If two marks want to ligate and they belong to different components of the |
1282 | | * same ligature glyph, and said ligature glyph is to be ignored according to |
1283 | | * mark-filtering rules, then allow. |
1284 | | * https://github.com/harfbuzz/harfbuzz/issues/545 |
1285 | | */ |
1286 | |
|
1287 | 0 | unsigned int total_component_count = 0; |
1288 | |
|
1289 | 0 | unsigned int first_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); |
1290 | 0 | unsigned int first_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); |
1291 | |
|
1292 | 0 | enum { |
1293 | 0 | LIGBASE_NOT_CHECKED, |
1294 | 0 | LIGBASE_MAY_NOT_SKIP, |
1295 | 0 | LIGBASE_MAY_SKIP |
1296 | 0 | } ligbase = LIGBASE_NOT_CHECKED; |
1297 | |
|
1298 | 0 | for (unsigned int i = 1; i < count; i++) |
1299 | 0 | { |
1300 | 0 | unsigned unsafe_to; |
1301 | 0 | if (!skippy_iter.next (&unsafe_to)) |
1302 | 0 | { |
1303 | 0 | *end_position = unsafe_to; |
1304 | 0 | return_trace (false); |
1305 | 0 | } |
1306 | | |
1307 | 0 | match_positions[i] = skippy_iter.idx; |
1308 | |
|
1309 | 0 | unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[skippy_iter.idx]); |
1310 | 0 | unsigned int this_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx]); |
1311 | |
|
1312 | 0 | if (first_lig_id && first_lig_comp) |
1313 | 0 | { |
1314 | | /* If first component was attached to a previous ligature component, |
1315 | | * all subsequent components should be attached to the same ligature |
1316 | | * component, otherwise we shouldn't ligate them... */ |
1317 | 0 | if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp) |
1318 | 0 | { |
1319 | | /* ...unless, we are attached to a base ligature and that base |
1320 | | * ligature is ignorable. */ |
1321 | 0 | if (ligbase == LIGBASE_NOT_CHECKED) |
1322 | 0 | { |
1323 | 0 | bool found = false; |
1324 | 0 | const auto *out = buffer->out_info; |
1325 | 0 | unsigned int j = buffer->out_len; |
1326 | 0 | while (j && _hb_glyph_info_get_lig_id (&out[j - 1]) == first_lig_id) |
1327 | 0 | { |
1328 | 0 | if (_hb_glyph_info_get_lig_comp (&out[j - 1]) == 0) |
1329 | 0 | { |
1330 | 0 | j--; |
1331 | 0 | found = true; |
1332 | 0 | break; |
1333 | 0 | } |
1334 | 0 | j--; |
1335 | 0 | } |
1336 | |
|
1337 | 0 | if (found && skippy_iter.may_skip (out[j]) == matcher_t::SKIP_YES) |
1338 | 0 | ligbase = LIGBASE_MAY_SKIP; |
1339 | 0 | else |
1340 | 0 | ligbase = LIGBASE_MAY_NOT_SKIP; |
1341 | 0 | } |
1342 | |
|
1343 | 0 | if (ligbase == LIGBASE_MAY_NOT_SKIP) |
1344 | 0 | return_trace (false); |
1345 | 0 | } |
1346 | 0 | } |
1347 | 0 | else |
1348 | 0 | { |
1349 | | /* If first component was NOT attached to a previous ligature component, |
1350 | | * all subsequent components should also NOT be attached to any ligature |
1351 | | * component, unless they are attached to the first component itself! */ |
1352 | 0 | if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id)) |
1353 | 0 | return_trace (false); |
1354 | 0 | } |
1355 | | |
1356 | 0 | total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[skippy_iter.idx]); |
1357 | 0 | } |
1358 | | |
1359 | 0 | *end_position = skippy_iter.idx + 1; |
1360 | |
|
1361 | 0 | if (p_total_component_count) |
1362 | 0 | { |
1363 | 0 | total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur()); |
1364 | 0 | *p_total_component_count = total_component_count; |
1365 | 0 | } |
1366 | |
|
1367 | 0 | match_positions[0] = buffer->idx; |
1368 | |
|
1369 | 0 | return_trace (true); |
1370 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-ot-face.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-ot-layout.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-ot-layout.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*, unsigned int*) |
1371 | | static inline bool ligate_input (hb_ot_apply_context_t *c, |
1372 | | unsigned int count, /* Including the first glyph */ |
1373 | | const unsigned int *match_positions, /* Including the first glyph */ |
1374 | | unsigned int match_end, |
1375 | | hb_codepoint_t lig_glyph, |
1376 | | unsigned int total_component_count) |
1377 | 0 | { |
1378 | 0 | TRACE_APPLY (nullptr); |
1379 | |
|
1380 | 0 | hb_buffer_t *buffer = c->buffer; |
1381 | |
|
1382 | 0 | buffer->merge_clusters (buffer->idx, match_end); |
1383 | | |
1384 | | /* - If a base and one or more marks ligate, consider that as a base, NOT |
1385 | | * ligature, such that all following marks can still attach to it. |
1386 | | * https://github.com/harfbuzz/harfbuzz/issues/1109 |
1387 | | * |
1388 | | * - If all components of the ligature were marks, we call this a mark ligature. |
1389 | | * If it *is* a mark ligature, we don't allocate a new ligature id, and leave |
1390 | | * the ligature to keep its old ligature id. This will allow it to attach to |
1391 | | * a base ligature in GPOS. Eg. if the sequence is: LAM,LAM,SHADDA,FATHA,HEH, |
1392 | | * and LAM,LAM,HEH for a ligature, they will leave SHADDA and FATHA with a |
1393 | | * ligature id and component value of 2. Then if SHADDA,FATHA form a ligature |
1394 | | * later, we don't want them to lose their ligature id/component, otherwise |
1395 | | * GPOS will fail to correctly position the mark ligature on top of the |
1396 | | * LAM,LAM,HEH ligature. See: |
1397 | | * https://bugzilla.gnome.org/show_bug.cgi?id=676343 |
1398 | | * |
1399 | | * - If a ligature is formed of components that some of which are also ligatures |
1400 | | * themselves, and those ligature components had marks attached to *their* |
1401 | | * components, we have to attach the marks to the new ligature component |
1402 | | * positions! Now *that*'s tricky! And these marks may be following the |
1403 | | * last component of the whole sequence, so we should loop forward looking |
1404 | | * for them and update them. |
1405 | | * |
1406 | | * Eg. the sequence is LAM,LAM,SHADDA,FATHA,HEH, and the font first forms a |
1407 | | * 'calt' ligature of LAM,HEH, leaving the SHADDA and FATHA with a ligature |
1408 | | * id and component == 1. Now, during 'liga', the LAM and the LAM-HEH ligature |
1409 | | * form a LAM-LAM-HEH ligature. We need to reassign the SHADDA and FATHA to |
1410 | | * the new ligature with a component value of 2. |
1411 | | * |
1412 | | * This in fact happened to a font... See: |
1413 | | * https://bugzilla.gnome.org/show_bug.cgi?id=437633 |
1414 | | */ |
1415 | |
|
1416 | 0 | bool is_base_ligature = _hb_glyph_info_is_base_glyph (&buffer->info[match_positions[0]]); |
1417 | 0 | bool is_mark_ligature = _hb_glyph_info_is_mark (&buffer->info[match_positions[0]]); |
1418 | 0 | for (unsigned int i = 1; i < count; i++) |
1419 | 0 | if (!_hb_glyph_info_is_mark (&buffer->info[match_positions[i]])) |
1420 | 0 | { |
1421 | 0 | is_base_ligature = false; |
1422 | 0 | is_mark_ligature = false; |
1423 | 0 | break; |
1424 | 0 | } |
1425 | 0 | bool is_ligature = !is_base_ligature && !is_mark_ligature; |
1426 | |
|
1427 | 0 | unsigned int klass = is_ligature ? HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE : 0; |
1428 | 0 | unsigned int lig_id = is_ligature ? _hb_allocate_lig_id (buffer) : 0; |
1429 | 0 | unsigned int last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); |
1430 | 0 | unsigned int last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur()); |
1431 | 0 | unsigned int components_so_far = last_num_components; |
1432 | |
|
1433 | 0 | if (is_ligature) |
1434 | 0 | { |
1435 | 0 | _hb_glyph_info_set_lig_props_for_ligature (&buffer->cur(), lig_id, total_component_count); |
1436 | 0 | if (_hb_glyph_info_get_general_category (&buffer->cur()) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) |
1437 | 0 | { |
1438 | 0 | _hb_glyph_info_set_general_category (&buffer->cur(), HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER); |
1439 | 0 | } |
1440 | 0 | } |
1441 | 0 | c->replace_glyph_with_ligature (lig_glyph, klass); |
1442 | |
|
1443 | 0 | for (unsigned int i = 1; i < count; i++) |
1444 | 0 | { |
1445 | 0 | while (buffer->idx < match_positions[i] && buffer->successful) |
1446 | 0 | { |
1447 | 0 | if (is_ligature) |
1448 | 0 | { |
1449 | 0 | unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); |
1450 | 0 | if (this_comp == 0) |
1451 | 0 | this_comp = last_num_components; |
1452 | 0 | assert (components_so_far >= last_num_components); |
1453 | 0 | unsigned int new_lig_comp = components_so_far - last_num_components + |
1454 | 0 | hb_min (this_comp, last_num_components); |
1455 | 0 | _hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, new_lig_comp); |
1456 | 0 | } |
1457 | 0 | (void) buffer->next_glyph (); |
1458 | 0 | } |
1459 | | |
1460 | 0 | last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); |
1461 | 0 | last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur()); |
1462 | 0 | components_so_far += last_num_components; |
1463 | | |
1464 | | /* Skip the base glyph */ |
1465 | 0 | buffer->idx++; |
1466 | 0 | } |
1467 | | |
1468 | 0 | if (!is_mark_ligature && last_lig_id) |
1469 | 0 | { |
1470 | | /* Re-adjust components for any marks following. */ |
1471 | 0 | for (unsigned i = buffer->idx; i < buffer->len; ++i) |
1472 | 0 | { |
1473 | 0 | if (last_lig_id != _hb_glyph_info_get_lig_id (&buffer->info[i])) break; |
1474 | | |
1475 | 0 | unsigned this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]); |
1476 | 0 | if (!this_comp) break; |
1477 | | |
1478 | 0 | assert (components_so_far >= last_num_components); |
1479 | 0 | unsigned new_lig_comp = components_so_far - last_num_components + |
1480 | 0 | hb_min (this_comp, last_num_components); |
1481 | 0 | _hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig_comp); |
1482 | 0 | } |
1483 | 0 | } |
1484 | 0 | return_trace (true); |
1485 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int const*, unsigned int, unsigned int, unsigned int) Unexecuted instantiation: hb-aat-layout.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int const*, unsigned int, unsigned int, unsigned int) Unexecuted instantiation: hb-ot-layout.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int const*, unsigned int, unsigned int, unsigned int) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int const*, unsigned int, unsigned int, unsigned int) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int const*, unsigned int, unsigned int, unsigned int) |
1486 | | |
1487 | | template <typename HBUINT> |
1488 | | #ifndef HB_OPTIMIZE_SIZE |
1489 | | HB_ALWAYS_INLINE |
1490 | | #endif |
1491 | | static bool match_backtrack (hb_ot_apply_context_t *c, |
1492 | | unsigned int count, |
1493 | | const HBUINT backtrack[], |
1494 | | match_func_t match_func, |
1495 | | const void *match_data, |
1496 | | unsigned int *match_start) |
1497 | 0 | { |
1498 | 0 | TRACE_APPLY (nullptr); |
1499 | |
|
1500 | 0 | auto &skippy_iter = c->iter_context; |
1501 | 0 | skippy_iter.reset (c->buffer->backtrack_len ()); |
1502 | 0 | skippy_iter.set_match_func (match_func, match_data); |
1503 | 0 | skippy_iter.set_glyph_data (backtrack); |
1504 | |
|
1505 | 0 | for (unsigned int i = 0; i < count; i++) |
1506 | 0 | { |
1507 | 0 | unsigned unsafe_from; |
1508 | 0 | if (!skippy_iter.prev (&unsafe_from)) |
1509 | 0 | { |
1510 | 0 | *match_start = unsafe_from; |
1511 | 0 | return_trace (false); |
1512 | 0 | } |
1513 | 0 | } |
1514 | | |
1515 | 0 | *match_start = skippy_iter.idx; |
1516 | 0 | return_trace (true); |
1517 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*) Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*) Unexecuted instantiation: hb-ot-layout.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*) |
1518 | | |
1519 | | template <typename HBUINT> |
1520 | | #ifndef HB_OPTIMIZE_SIZE |
1521 | | HB_ALWAYS_INLINE |
1522 | | #endif |
1523 | | static bool match_lookahead (hb_ot_apply_context_t *c, |
1524 | | unsigned int count, |
1525 | | const HBUINT lookahead[], |
1526 | | match_func_t match_func, |
1527 | | const void *match_data, |
1528 | | unsigned int start_index, |
1529 | | unsigned int *end_index) |
1530 | 0 | { |
1531 | 0 | TRACE_APPLY (nullptr); |
1532 | |
|
1533 | 0 | auto &skippy_iter = c->iter_context; |
1534 | 0 | assert (start_index >= 1); |
1535 | 0 | skippy_iter.reset (start_index - 1); |
1536 | 0 | skippy_iter.set_match_func (match_func, match_data); |
1537 | 0 | skippy_iter.set_glyph_data (lookahead); |
1538 | |
|
1539 | 0 | for (unsigned int i = 0; i < count; i++) |
1540 | 0 | { |
1541 | 0 | unsigned unsafe_to; |
1542 | 0 | if (!skippy_iter.next (&unsafe_to)) |
1543 | 0 | { |
1544 | 0 | *end_index = unsafe_to; |
1545 | 0 | return_trace (false); |
1546 | 0 | } |
1547 | 0 | } |
1548 | | |
1549 | 0 | *end_index = skippy_iter.idx + 1; |
1550 | 0 | return_trace (true); |
1551 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*) Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*) Unexecuted instantiation: hb-ot-layout.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*) |
1552 | | |
1553 | | |
1554 | | |
1555 | | struct LookupRecord |
1556 | | { |
1557 | | bool serialize (hb_serialize_context_t *c, |
1558 | | const hb_map_t *lookup_map) const |
1559 | 0 | { |
1560 | 0 | TRACE_SERIALIZE (this); |
1561 | 0 | auto *out = c->embed (*this); |
1562 | 0 | if (unlikely (!out)) return_trace (false); |
1563 | 0 |
|
1564 | 0 | return_trace (c->check_assign (out->lookupListIndex, lookup_map->get (lookupListIndex), HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
1565 | 0 | } |
1566 | | |
1567 | | bool sanitize (hb_sanitize_context_t *c) const |
1568 | 0 | { |
1569 | 0 | TRACE_SANITIZE (this); |
1570 | 0 | return_trace (c->check_struct (this)); |
1571 | 0 | } |
1572 | | |
1573 | | HBUINT16 sequenceIndex; /* Index into current glyph |
1574 | | * sequence--first glyph = 0 */ |
1575 | | HBUINT16 lookupListIndex; /* Lookup to apply to that |
1576 | | * position--zero--based */ |
1577 | | public: |
1578 | | DEFINE_SIZE_STATIC (4); |
1579 | | }; |
1580 | | |
1581 | | static unsigned serialize_lookuprecord_array (hb_serialize_context_t *c, |
1582 | | const hb_array_t<const LookupRecord> lookupRecords, |
1583 | | const hb_map_t *lookup_map) |
1584 | 0 | { |
1585 | 0 | unsigned count = 0; |
1586 | 0 | for (const LookupRecord& r : lookupRecords) |
1587 | 0 | { |
1588 | 0 | if (!lookup_map->has (r.lookupListIndex)) |
1589 | 0 | continue; |
1590 | 0 |
|
1591 | 0 | if (!r.serialize (c, lookup_map)) |
1592 | 0 | return 0; |
1593 | 0 |
|
1594 | 0 | count++; |
1595 | 0 | } |
1596 | 0 | return count; |
1597 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*) Unexecuted instantiation: hb-aat-layout.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*) Unexecuted instantiation: hb-ot-layout.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*) |
1598 | | |
1599 | | enum ContextFormat { SimpleContext = 1, ClassBasedContext = 2, CoverageBasedContext = 3 }; |
1600 | | |
1601 | | template <typename HBUINT> |
1602 | | static void context_closure_recurse_lookups (hb_closure_context_t *c, |
1603 | | unsigned inputCount, const HBUINT input[], |
1604 | | unsigned lookupCount, |
1605 | | const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */, |
1606 | | unsigned value, |
1607 | | ContextFormat context_format, |
1608 | | const void *data, |
1609 | | intersected_glyphs_func_t intersected_glyphs_func, |
1610 | | void *cache) |
1611 | 0 | { |
1612 | 0 | hb_set_t covered_seq_indicies; |
1613 | 0 | hb_set_t pos_glyphs; |
1614 | 0 | for (unsigned int i = 0; i < lookupCount; i++) |
1615 | 0 | { |
1616 | 0 | unsigned seqIndex = lookupRecord[i].sequenceIndex; |
1617 | 0 | if (seqIndex >= inputCount) continue; |
1618 | | |
1619 | 0 | bool has_pos_glyphs = false; |
1620 | |
|
1621 | 0 | if (!covered_seq_indicies.has (seqIndex)) |
1622 | 0 | { |
1623 | 0 | has_pos_glyphs = true; |
1624 | 0 | pos_glyphs.clear (); |
1625 | 0 | if (seqIndex == 0) |
1626 | 0 | { |
1627 | 0 | switch (context_format) { |
1628 | 0 | case ContextFormat::SimpleContext: |
1629 | 0 | pos_glyphs.add (value); |
1630 | 0 | break; |
1631 | 0 | case ContextFormat::ClassBasedContext: |
1632 | 0 | intersected_glyphs_func (&c->parent_active_glyphs (), data, value, &pos_glyphs, cache); |
1633 | 0 | break; |
1634 | 0 | case ContextFormat::CoverageBasedContext: |
1635 | 0 | pos_glyphs.set (c->parent_active_glyphs ()); |
1636 | 0 | break; |
1637 | 0 | } |
1638 | 0 | } |
1639 | 0 | else |
1640 | 0 | { |
1641 | 0 | const void *input_data = input; |
1642 | 0 | unsigned input_value = seqIndex - 1; |
1643 | 0 | if (context_format != ContextFormat::SimpleContext) |
1644 | 0 | { |
1645 | 0 | input_data = data; |
1646 | 0 | input_value = input[seqIndex - 1]; |
1647 | 0 | } |
1648 | |
|
1649 | 0 | intersected_glyphs_func (c->glyphs, input_data, input_value, &pos_glyphs, cache); |
1650 | 0 | } |
1651 | 0 | } |
1652 | | |
1653 | 0 | covered_seq_indicies.add (seqIndex); |
1654 | 0 | hb_set_t *cur_active_glyphs = c->push_cur_active_glyphs (); |
1655 | 0 | if (unlikely (!cur_active_glyphs)) |
1656 | 0 | return; |
1657 | 0 | if (has_pos_glyphs) { |
1658 | 0 | *cur_active_glyphs = std::move (pos_glyphs); |
1659 | 0 | } else { |
1660 | 0 | *cur_active_glyphs = *c->glyphs; |
1661 | 0 | } |
1662 | |
|
1663 | 0 | unsigned endIndex = inputCount; |
1664 | 0 | if (context_format == ContextFormat::CoverageBasedContext) |
1665 | 0 | endIndex += 1; |
1666 | |
|
1667 | 0 | c->recurse (lookupRecord[i].lookupListIndex, &covered_seq_indicies, seqIndex, endIndex); |
1668 | |
|
1669 | 0 | c->pop_cur_done_glyphs (); |
1670 | 0 | } |
1671 | 0 | } Unexecuted instantiation: hb-ot-face.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*) Unexecuted instantiation: hb-aat-layout.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*) Unexecuted instantiation: hb-ot-layout.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*) |
1672 | | |
1673 | | template <typename context_t> |
1674 | | static inline void recurse_lookups (context_t *c, |
1675 | | unsigned int lookupCount, |
1676 | | const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */) |
1677 | 0 | { |
1678 | 0 | for (unsigned int i = 0; i < lookupCount; i++) |
1679 | 0 | c->recurse (lookupRecord[i].lookupListIndex); |
1680 | 0 | } Unexecuted instantiation: hb-ot-face.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-ot-face.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-aat-layout.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-aat-layout.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-ot-layout.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-ot-layout.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*) |
1681 | | |
1682 | | static inline void apply_lookup (hb_ot_apply_context_t *c, |
1683 | | unsigned int count, /* Including the first glyph */ |
1684 | | unsigned int *match_positions, /* Including the first glyph */ |
1685 | | unsigned int lookupCount, |
1686 | | const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */ |
1687 | | unsigned int match_end) |
1688 | 0 | { |
1689 | 0 | hb_buffer_t *buffer = c->buffer; |
1690 | 0 | int end; |
1691 | |
|
1692 | 0 | unsigned int *match_positions_input = match_positions; |
1693 | 0 | unsigned int match_positions_count = count; |
1694 | | |
1695 | | /* All positions are distance from beginning of *output* buffer. |
1696 | | * Adjust. */ |
1697 | 0 | { |
1698 | 0 | unsigned int bl = buffer->backtrack_len (); |
1699 | 0 | end = bl + match_end - buffer->idx; |
1700 | |
|
1701 | 0 | int delta = bl - buffer->idx; |
1702 | | /* Convert positions to new indexing. */ |
1703 | 0 | for (unsigned int j = 0; j < count; j++) |
1704 | 0 | match_positions[j] += delta; |
1705 | 0 | } |
1706 | |
|
1707 | 0 | for (unsigned int i = 0; i < lookupCount && buffer->successful; i++) |
1708 | 0 | { |
1709 | 0 | unsigned int idx = lookupRecord[i].sequenceIndex; |
1710 | 0 | if (idx >= count) |
1711 | 0 | continue; |
1712 | | |
1713 | 0 | unsigned int orig_len = buffer->backtrack_len () + buffer->lookahead_len (); |
1714 | | |
1715 | | /* This can happen if earlier recursed lookups deleted many entries. */ |
1716 | 0 | if (unlikely (match_positions[idx] >= orig_len)) |
1717 | 0 | continue; |
1718 | | |
1719 | 0 | if (unlikely (!buffer->move_to (match_positions[idx]))) |
1720 | 0 | break; |
1721 | | |
1722 | 0 | if (unlikely (buffer->max_ops <= 0)) |
1723 | 0 | break; |
1724 | | |
1725 | 0 | if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ()) |
1726 | 0 | { |
1727 | 0 | if (buffer->have_output) |
1728 | 0 | c->buffer->sync_so_far (); |
1729 | 0 | c->buffer->message (c->font, |
1730 | 0 | "recursing to lookup %u at %u", |
1731 | 0 | (unsigned) lookupRecord[i].lookupListIndex, |
1732 | 0 | buffer->idx); |
1733 | 0 | } |
1734 | |
|
1735 | 0 | if (!c->recurse (lookupRecord[i].lookupListIndex)) |
1736 | 0 | continue; |
1737 | | |
1738 | 0 | if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ()) |
1739 | 0 | { |
1740 | 0 | if (buffer->have_output) |
1741 | 0 | c->buffer->sync_so_far (); |
1742 | 0 | c->buffer->message (c->font, |
1743 | 0 | "recursed to lookup %u", |
1744 | 0 | (unsigned) lookupRecord[i].lookupListIndex); |
1745 | 0 | } |
1746 | |
|
1747 | 0 | unsigned int new_len = buffer->backtrack_len () + buffer->lookahead_len (); |
1748 | 0 | int delta = new_len - orig_len; |
1749 | |
|
1750 | 0 | if (!delta) |
1751 | 0 | continue; |
1752 | | |
1753 | | /* Recursed lookup changed buffer len. Adjust. |
1754 | | * |
1755 | | * TODO: |
1756 | | * |
1757 | | * Right now, if buffer length increased by n, we assume n new glyphs |
1758 | | * were added right after the current position, and if buffer length |
1759 | | * was decreased by n, we assume n match positions after the current |
1760 | | * one where removed. The former (buffer length increased) case is |
1761 | | * fine, but the decrease case can be improved in at least two ways, |
1762 | | * both of which are significant: |
1763 | | * |
1764 | | * - If recursed-to lookup is MultipleSubst and buffer length |
1765 | | * decreased, then it's current match position that was deleted, |
1766 | | * NOT the one after it. |
1767 | | * |
1768 | | * - If buffer length was decreased by n, it does not necessarily |
1769 | | * mean that n match positions where removed, as there recursed-to |
1770 | | * lookup might had a different LookupFlag. Here's a constructed |
1771 | | * case of that: |
1772 | | * https://github.com/harfbuzz/harfbuzz/discussions/3538 |
1773 | | * |
1774 | | * It should be possible to construct tests for both of these cases. |
1775 | | */ |
1776 | | |
1777 | 0 | end += delta; |
1778 | 0 | if (end < int (match_positions[idx])) |
1779 | 0 | { |
1780 | | /* End might end up being smaller than match_positions[idx] if the recursed |
1781 | | * lookup ended up removing many items. |
1782 | | * Just never rewind end beyond start of current position, since that is |
1783 | | * not possible in the recursed lookup. Also adjust delta as such. |
1784 | | * |
1785 | | * https://bugs.chromium.org/p/chromium/issues/detail?id=659496 |
1786 | | * https://github.com/harfbuzz/harfbuzz/issues/1611 |
1787 | | */ |
1788 | 0 | delta += match_positions[idx] - end; |
1789 | 0 | end = match_positions[idx]; |
1790 | 0 | } |
1791 | |
|
1792 | 0 | unsigned int next = idx + 1; /* next now is the position after the recursed lookup. */ |
1793 | |
|
1794 | 0 | if (delta > 0) |
1795 | 0 | { |
1796 | 0 | if (unlikely (delta + count > HB_MAX_CONTEXT_LENGTH)) |
1797 | 0 | break; |
1798 | 0 | if (unlikely (delta + count > match_positions_count)) |
1799 | 0 | { |
1800 | 0 | unsigned new_match_positions_count = hb_max (delta + count, hb_max(match_positions_count, 4u) * 1.5); |
1801 | 0 | if (match_positions == match_positions_input) |
1802 | 0 | { |
1803 | 0 | match_positions = (unsigned int *) hb_malloc (new_match_positions_count * sizeof (match_positions[0])); |
1804 | 0 | if (unlikely (!match_positions)) |
1805 | 0 | break; |
1806 | 0 | memcpy (match_positions, match_positions_input, count * sizeof (match_positions[0])); |
1807 | 0 | match_positions_count = new_match_positions_count; |
1808 | 0 | } |
1809 | 0 | else |
1810 | 0 | { |
1811 | 0 | unsigned int *new_match_positions = (unsigned int *) hb_realloc (match_positions, new_match_positions_count * sizeof (match_positions[0])); |
1812 | 0 | if (unlikely (!new_match_positions)) |
1813 | 0 | break; |
1814 | 0 | match_positions = new_match_positions; |
1815 | 0 | match_positions_count = new_match_positions_count; |
1816 | 0 | } |
1817 | 0 | } |
1818 | |
|
1819 | 0 | } |
1820 | 0 | else |
1821 | 0 | { |
1822 | | /* NOTE: delta is non-positive. */ |
1823 | 0 | delta = hb_max (delta, (int) next - (int) count); |
1824 | 0 | next -= delta; |
1825 | 0 | } |
1826 | | |
1827 | | /* Shift! */ |
1828 | 0 | memmove (match_positions + next + delta, match_positions + next, |
1829 | 0 | (count - next) * sizeof (match_positions[0])); |
1830 | 0 | next += delta; |
1831 | 0 | count += delta; |
1832 | | |
1833 | | /* Fill in new entries. */ |
1834 | 0 | for (unsigned int j = idx + 1; j < next; j++) |
1835 | 0 | match_positions[j] = match_positions[j - 1] + 1; |
1836 | | |
1837 | | /* And fixup the rest. */ |
1838 | 0 | for (; next < count; next++) |
1839 | 0 | match_positions[next] += delta; |
1840 | 0 | } |
1841 | |
|
1842 | 0 | if (match_positions != match_positions_input) |
1843 | 0 | hb_free (match_positions); |
1844 | |
|
1845 | 0 | assert (end >= 0); |
1846 | 0 | (void) buffer->move_to (end); |
1847 | 0 | } Unexecuted instantiation: hb-ot-face.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int*, unsigned int, OT::LookupRecord const*, unsigned int) Unexecuted instantiation: hb-aat-layout.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int*, unsigned int, OT::LookupRecord const*, unsigned int) Unexecuted instantiation: hb-ot-layout.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int*, unsigned int, OT::LookupRecord const*, unsigned int) Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int*, unsigned int, OT::LookupRecord const*, unsigned int) Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int*, unsigned int, OT::LookupRecord const*, unsigned int) |
1848 | | |
1849 | | |
1850 | | |
1851 | | /* Contextual lookups */ |
1852 | | |
1853 | | struct ContextClosureLookupContext |
1854 | | { |
1855 | | ContextClosureFuncs funcs; |
1856 | | ContextFormat context_format; |
1857 | | const void *intersects_data; |
1858 | | void *intersects_cache; |
1859 | | void *intersected_glyphs_cache; |
1860 | | }; |
1861 | | |
1862 | | struct ContextCollectGlyphsLookupContext |
1863 | | { |
1864 | | ContextCollectGlyphsFuncs funcs; |
1865 | | const void *collect_data; |
1866 | | }; |
1867 | | |
1868 | | struct ContextApplyLookupContext |
1869 | | { |
1870 | | ContextApplyFuncs funcs; |
1871 | | const void *match_data; |
1872 | | }; |
1873 | | |
1874 | | template <typename HBUINT> |
1875 | | static inline bool context_intersects (const hb_set_t *glyphs, |
1876 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1877 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1878 | | ContextClosureLookupContext &lookup_context) |
1879 | 0 | { |
1880 | 0 | return array_is_subset_of (glyphs, |
1881 | 0 | inputCount ? inputCount - 1 : 0, input, |
1882 | 0 | lookup_context.funcs.intersects, |
1883 | 0 | lookup_context.intersects_data, |
1884 | 0 | lookup_context.intersects_cache); |
1885 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-aat-layout.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-ot-layout.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&) |
1886 | | |
1887 | | template <typename HBUINT> |
1888 | | static inline void context_closure_lookup (hb_closure_context_t *c, |
1889 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1890 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1891 | | unsigned int lookupCount, |
1892 | | const LookupRecord lookupRecord[], |
1893 | | unsigned value, /* Index of first glyph in Coverage or Class value in ClassDef table */ |
1894 | | ContextClosureLookupContext &lookup_context) |
1895 | 0 | { |
1896 | 0 | if (context_intersects (c->glyphs, |
1897 | 0 | inputCount, input, |
1898 | 0 | lookup_context)) |
1899 | 0 | context_closure_recurse_lookups (c, |
1900 | 0 | inputCount, input, |
1901 | 0 | lookupCount, lookupRecord, |
1902 | 0 | value, |
1903 | 0 | lookup_context.context_format, |
1904 | 0 | lookup_context.intersects_data, |
1905 | 0 | lookup_context.funcs.intersected_glyphs, |
1906 | 0 | lookup_context.intersected_glyphs_cache); |
1907 | 0 | } Unexecuted instantiation: hb-ot-face.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-aat-layout.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-ot-layout.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&) |
1908 | | |
1909 | | template <typename HBUINT> |
1910 | | static inline void context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c, |
1911 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1912 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1913 | | unsigned int lookupCount, |
1914 | | const LookupRecord lookupRecord[], |
1915 | | ContextCollectGlyphsLookupContext &lookup_context) |
1916 | 0 | { |
1917 | 0 | collect_array (c, c->input, |
1918 | 0 | inputCount ? inputCount - 1 : 0, input, |
1919 | 0 | lookup_context.funcs.collect, lookup_context.collect_data); |
1920 | 0 | recurse_lookups (c, |
1921 | 0 | lookupCount, lookupRecord); |
1922 | 0 | } Unexecuted instantiation: hb-ot-face.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-aat-layout.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-ot-layout.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&) |
1923 | | |
1924 | | template <typename HBUINT> |
1925 | | static inline bool context_would_apply_lookup (hb_would_apply_context_t *c, |
1926 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1927 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1928 | | unsigned int lookupCount HB_UNUSED, |
1929 | | const LookupRecord lookupRecord[] HB_UNUSED, |
1930 | | const ContextApplyLookupContext &lookup_context) |
1931 | 0 | { |
1932 | 0 | return would_match_input (c, |
1933 | 0 | inputCount, input, |
1934 | 0 | lookup_context.funcs.match, lookup_context.match_data); |
1935 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-aat-layout.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-layout.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) |
1936 | | |
1937 | | template <typename HBUINT> |
1938 | | HB_ALWAYS_INLINE |
1939 | | static bool context_apply_lookup (hb_ot_apply_context_t *c, |
1940 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1941 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1942 | | unsigned int lookupCount, |
1943 | | const LookupRecord lookupRecord[], |
1944 | | const ContextApplyLookupContext &lookup_context) |
1945 | 0 | { |
1946 | 0 | if (unlikely (inputCount > HB_MAX_CONTEXT_LENGTH)) return false; |
1947 | 0 | unsigned match_positions_stack[4]; |
1948 | 0 | unsigned *match_positions = match_positions_stack; |
1949 | 0 | if (unlikely (inputCount > ARRAY_LENGTH (match_positions_stack))) |
1950 | 0 | { |
1951 | 0 | match_positions = (unsigned *) hb_malloc (hb_max (inputCount, 1u) * sizeof (match_positions[0])); |
1952 | 0 | if (unlikely (!match_positions)) |
1953 | 0 | return false; |
1954 | 0 | } |
1955 | | |
1956 | 0 | unsigned match_end = 0; |
1957 | 0 | bool ret = false; |
1958 | 0 | if (match_input (c, |
1959 | 0 | inputCount, input, |
1960 | 0 | lookup_context.funcs.match, lookup_context.match_data, |
1961 | 0 | &match_end, match_positions)) |
1962 | 0 | { |
1963 | 0 | c->buffer->unsafe_to_break (c->buffer->idx, match_end); |
1964 | 0 | apply_lookup (c, |
1965 | 0 | inputCount, match_positions, |
1966 | 0 | lookupCount, lookupRecord, |
1967 | 0 | match_end); |
1968 | 0 | ret = true; |
1969 | 0 | } |
1970 | 0 | else |
1971 | 0 | { |
1972 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, match_end); |
1973 | 0 | ret = false; |
1974 | 0 | } |
1975 | |
|
1976 | 0 | if (unlikely (match_positions != match_positions_stack)) |
1977 | 0 | hb_free (match_positions); |
1978 | |
|
1979 | 0 | return ret; |
1980 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-aat-layout.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-layout.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&) |
1981 | | |
1982 | | template <typename Types> |
1983 | | struct Rule |
1984 | | { |
1985 | | template <typename T> |
1986 | | friend struct RuleSet; |
1987 | | |
1988 | | bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const |
1989 | 0 | { |
1990 | 0 | return context_intersects (glyphs, |
1991 | 0 | inputCount, inputZ.arrayZ, |
1992 | 0 | lookup_context); |
1993 | 0 | } |
1994 | | |
1995 | | void closure (hb_closure_context_t *c, unsigned value, ContextClosureLookupContext &lookup_context) const |
1996 | 0 | { |
1997 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
1998 | | |
1999 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2000 | 0 | (inputZ.as_array ((inputCount ? inputCount - 1 : 0))); |
2001 | 0 | context_closure_lookup (c, |
2002 | 0 | inputCount, inputZ.arrayZ, |
2003 | 0 | lookupCount, lookupRecord.arrayZ, |
2004 | 0 | value, lookup_context); |
2005 | 0 | } |
2006 | | |
2007 | | void closure_lookups (hb_closure_lookups_context_t *c, |
2008 | | ContextClosureLookupContext &lookup_context) const |
2009 | 0 | { |
2010 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
2011 | 0 | if (!intersects (c->glyphs, lookup_context)) return; |
2012 | 0 |
|
2013 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2014 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
2015 | 0 | recurse_lookups (c, lookupCount, lookupRecord.arrayZ); |
2016 | 0 | } |
2017 | | |
2018 | | void collect_glyphs (hb_collect_glyphs_context_t *c, |
2019 | | ContextCollectGlyphsLookupContext &lookup_context) const |
2020 | 0 | { |
2021 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2022 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
2023 | 0 | context_collect_glyphs_lookup (c, |
2024 | 0 | inputCount, inputZ.arrayZ, |
2025 | 0 | lookupCount, lookupRecord.arrayZ, |
2026 | 0 | lookup_context); |
2027 | 0 | } |
2028 | | |
2029 | | bool would_apply (hb_would_apply_context_t *c, |
2030 | | const ContextApplyLookupContext &lookup_context) const |
2031 | 0 | { |
2032 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2033 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
2034 | 0 | return context_would_apply_lookup (c, |
2035 | 0 | inputCount, inputZ.arrayZ, |
2036 | 0 | lookupCount, lookupRecord.arrayZ, |
2037 | 0 | lookup_context); |
2038 | 0 | } |
2039 | | |
2040 | | bool apply (hb_ot_apply_context_t *c, |
2041 | | const ContextApplyLookupContext &lookup_context) const |
2042 | 0 | { |
2043 | 0 | TRACE_APPLY (this); |
2044 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2045 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
2046 | 0 | return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context)); |
2047 | 0 | } |
2048 | | |
2049 | | bool serialize (hb_serialize_context_t *c, |
2050 | | const hb_map_t *input_mapping, /* old->new glyphid or class mapping */ |
2051 | | const hb_map_t *lookup_map) const |
2052 | 0 | { |
2053 | 0 | TRACE_SERIALIZE (this); |
2054 | 0 | auto *out = c->start_embed (this); |
2055 | 0 | if (unlikely (!c->extend_min (out))) return_trace (false); |
2056 | 0 |
|
2057 | 0 | out->inputCount = inputCount; |
2058 | 0 | const auto input = inputZ.as_array (inputCount - 1); |
2059 | 0 | for (const auto org : input) |
2060 | 0 | { |
2061 | 0 | HBUINT16 d; |
2062 | 0 | d = input_mapping->get (org); |
2063 | 0 | c->copy (d); |
2064 | 0 | } |
2065 | 0 |
|
2066 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2067 | 0 | (inputZ.as_array ((inputCount ? inputCount - 1 : 0))); |
2068 | 0 |
|
2069 | 0 | unsigned count = serialize_lookuprecord_array (c, lookupRecord.as_array (lookupCount), lookup_map); |
2070 | 0 | return_trace (c->check_assign (out->lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
2071 | 0 | } |
2072 | | |
2073 | | bool subset (hb_subset_context_t *c, |
2074 | | const hb_map_t *lookup_map, |
2075 | | const hb_map_t *klass_map = nullptr) const |
2076 | 0 | { |
2077 | 0 | TRACE_SUBSET (this); |
2078 | 0 | if (unlikely (!inputCount)) return_trace (false); |
2079 | 0 | const auto input = inputZ.as_array (inputCount - 1); |
2080 | 0 |
|
2081 | 0 | const hb_map_t *mapping = klass_map == nullptr ? c->plan->glyph_map : klass_map; |
2082 | 0 | if (!hb_all (input, mapping)) return_trace (false); |
2083 | 0 | return_trace (serialize (c->serializer, mapping, lookup_map)); |
2084 | 0 | } |
2085 | | |
2086 | | public: |
2087 | | bool sanitize (hb_sanitize_context_t *c) const |
2088 | 0 | { |
2089 | 0 | TRACE_SANITIZE (this); |
2090 | 0 | return_trace (c->check_struct (this) && |
2091 | 0 | hb_barrier () && |
2092 | 0 | c->check_range (inputZ.arrayZ, |
2093 | 0 | inputZ.item_size * (inputCount ? inputCount - 1 : 0) + |
2094 | 0 | LookupRecord::static_size * lookupCount)); |
2095 | 0 | } |
2096 | | |
2097 | | protected: |
2098 | | HBUINT16 inputCount; /* Total number of glyphs in input |
2099 | | * glyph sequence--includes the first |
2100 | | * glyph */ |
2101 | | HBUINT16 lookupCount; /* Number of LookupRecords */ |
2102 | | UnsizedArrayOf<typename Types::HBUINT> |
2103 | | inputZ; /* Array of match inputs--start with |
2104 | | * second glyph */ |
2105 | | /*UnsizedArrayOf<LookupRecord> |
2106 | | lookupRecordX;*/ /* Array of LookupRecords--in |
2107 | | * design order */ |
2108 | | public: |
2109 | | DEFINE_SIZE_ARRAY (4, inputZ); |
2110 | | }; |
2111 | | |
2112 | | template <typename Types> |
2113 | | struct RuleSet |
2114 | | { |
2115 | | using Rule = OT::Rule<Types>; |
2116 | | |
2117 | | bool intersects (const hb_set_t *glyphs, |
2118 | | ContextClosureLookupContext &lookup_context) const |
2119 | 0 | { |
2120 | 0 | return |
2121 | 0 | + hb_iter (rule) |
2122 | 0 | | hb_map (hb_add (this)) |
2123 | 0 | | hb_map ([&] (const Rule &_) { return _.intersects (glyphs, lookup_context); }) |
2124 | 0 | | hb_any |
2125 | 0 | ; |
2126 | 0 | } |
2127 | | |
2128 | | void closure (hb_closure_context_t *c, unsigned value, |
2129 | | ContextClosureLookupContext &lookup_context) const |
2130 | 0 | { |
2131 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
2132 | | |
2133 | 0 | return |
2134 | 0 | + hb_iter (rule) |
2135 | 0 | | hb_map (hb_add (this)) |
2136 | 0 | | hb_apply ([&] (const Rule &_) { _.closure (c, value, lookup_context); }) |
2137 | 0 | ; |
2138 | 0 | } |
2139 | | |
2140 | | void closure_lookups (hb_closure_lookups_context_t *c, |
2141 | | ContextClosureLookupContext &lookup_context) const |
2142 | 0 | { |
2143 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
2144 | 0 | + hb_iter (rule) |
2145 | 0 | | hb_map (hb_add (this)) |
2146 | 0 | | hb_apply ([&] (const Rule &_) { _.closure_lookups (c, lookup_context); }) |
2147 | 0 | ; |
2148 | 0 | } |
2149 | | |
2150 | | void collect_glyphs (hb_collect_glyphs_context_t *c, |
2151 | | ContextCollectGlyphsLookupContext &lookup_context) const |
2152 | 0 | { |
2153 | 0 | return |
2154 | 0 | + hb_iter (rule) |
2155 | 0 | | hb_map (hb_add (this)) |
2156 | 0 | | hb_apply ([&] (const Rule &_) { _.collect_glyphs (c, lookup_context); }) |
2157 | 0 | ; |
2158 | 0 | } |
2159 | | |
2160 | | bool would_apply (hb_would_apply_context_t *c, |
2161 | | const ContextApplyLookupContext &lookup_context) const |
2162 | 0 | { |
2163 | 0 | return |
2164 | 0 | + hb_iter (rule) |
2165 | 0 | | hb_map (hb_add (this)) |
2166 | 0 | | hb_map ([&] (const Rule &_) { return _.would_apply (c, lookup_context); }) |
2167 | 0 | | hb_any |
2168 | 0 | ; |
2169 | 0 | } |
2170 | | |
2171 | | bool apply (hb_ot_apply_context_t *c, |
2172 | | const ContextApplyLookupContext &lookup_context) const |
2173 | 0 | { |
2174 | 0 | TRACE_APPLY (this); |
2175 | |
|
2176 | 0 | unsigned num_rules = rule.len; |
2177 | |
|
2178 | 0 | #ifndef HB_NO_OT_RULESETS_FAST_PATH |
2179 | 0 | if (HB_OPTIMIZE_SIZE_VAL || num_rules <= 4) |
2180 | 0 | #endif |
2181 | 0 | { |
2182 | 0 | slow: |
2183 | 0 | return_trace ( |
2184 | 0 | + hb_iter (rule) |
2185 | 0 | | hb_map (hb_add (this)) |
2186 | 0 | | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); }) |
2187 | 0 | | hb_any |
2188 | 0 | ) |
2189 | 0 | ; |
2190 | 0 | } |
2191 | | |
2192 | | /* This version is optimized for speed by matching the first & second |
2193 | | * components of the rule here, instead of calling into the matching code. |
2194 | | * |
2195 | | * Replicated from LigatureSet::apply(). */ |
2196 | | |
2197 | 0 | auto &skippy_iter = c->iter_input; |
2198 | 0 | skippy_iter.reset (c->buffer->idx); |
2199 | 0 | skippy_iter.set_match_func (match_always, nullptr); |
2200 | 0 | skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); |
2201 | 0 | unsigned unsafe_to = (unsigned) -1, unsafe_to1 = 0, unsafe_to2 = 0; |
2202 | 0 | hb_glyph_info_t *first = nullptr, *second = nullptr; |
2203 | 0 | bool matched = skippy_iter.next (); |
2204 | 0 | if (likely (matched)) |
2205 | 0 | { |
2206 | 0 | first = &c->buffer->info[skippy_iter.idx]; |
2207 | 0 | unsafe_to = skippy_iter.idx + 1; |
2208 | |
|
2209 | 0 | if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx])) |
2210 | 0 | { |
2211 | | /* Can't use the fast path if eg. the next char is a default-ignorable |
2212 | | * or other skippable. */ |
2213 | 0 | goto slow; |
2214 | 0 | } |
2215 | 0 | } |
2216 | 0 | else |
2217 | 0 | { |
2218 | | /* Failed to match a next glyph. Only try applying rules that have |
2219 | | * no further input. */ |
2220 | 0 | return_trace ( |
2221 | 0 | + hb_iter (rule) |
2222 | 0 | | hb_map (hb_add (this)) |
2223 | 0 | | hb_filter ([&] (const Rule &_) { return _.inputCount <= 1; }) |
2224 | 0 | | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); }) |
2225 | 0 | | hb_any |
2226 | 0 | ) |
2227 | 0 | ; |
2228 | 0 | } |
2229 | 0 | matched = skippy_iter.next (); |
2230 | 0 | if (likely (matched && !skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))) |
2231 | 0 | { |
2232 | 0 | second = &c->buffer->info[skippy_iter.idx]; |
2233 | 0 | unsafe_to2 = skippy_iter.idx + 1; |
2234 | 0 | } |
2235 | |
|
2236 | 0 | auto match_input = lookup_context.funcs.match; |
2237 | 0 | auto *input_data = lookup_context.match_data; |
2238 | 0 | for (unsigned int i = 0; i < num_rules; i++) |
2239 | 0 | { |
2240 | 0 | const auto &r = this+rule.arrayZ[i]; |
2241 | |
|
2242 | 0 | const auto &input = r.inputZ; |
2243 | |
|
2244 | 0 | if (r.inputCount <= 1 || |
2245 | 0 | (!match_input || |
2246 | 0 | match_input (*first, input.arrayZ[0], input_data))) |
2247 | 0 | { |
2248 | 0 | if (!second || |
2249 | 0 | (r.inputCount <= 2 || |
2250 | 0 | (!match_input || |
2251 | 0 | match_input (*second, input.arrayZ[1], input_data))) |
2252 | 0 | ) |
2253 | 0 | { |
2254 | 0 | if (r.apply (c, lookup_context)) |
2255 | 0 | { |
2256 | 0 | if (unsafe_to != (unsigned) -1) |
2257 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); |
2258 | 0 | return_trace (true); |
2259 | 0 | } |
2260 | 0 | } |
2261 | 0 | else |
2262 | 0 | unsafe_to = unsafe_to2; |
2263 | 0 | } |
2264 | 0 | else |
2265 | 0 | { |
2266 | 0 | if (unsafe_to == (unsigned) -1) |
2267 | 0 | unsafe_to = unsafe_to1; |
2268 | 0 | } |
2269 | 0 | } |
2270 | 0 | if (likely (unsafe_to != (unsigned) -1)) |
2271 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); |
2272 | |
|
2273 | 0 | return_trace (false); |
2274 | 0 | } |
2275 | | |
2276 | | bool subset (hb_subset_context_t *c, |
2277 | | const hb_map_t *lookup_map, |
2278 | | const hb_map_t *klass_map = nullptr) const |
2279 | 0 | { |
2280 | 0 | TRACE_SUBSET (this); |
2281 | 0 |
|
2282 | 0 | auto snap = c->serializer->snapshot (); |
2283 | 0 | auto *out = c->serializer->start_embed (*this); |
2284 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
2285 | 0 |
|
2286 | 0 | for (const Offset16To<Rule>& _ : rule) |
2287 | 0 | { |
2288 | 0 | if (!_) continue; |
2289 | 0 | auto o_snap = c->serializer->snapshot (); |
2290 | 0 | auto *o = out->rule.serialize_append (c->serializer); |
2291 | 0 | if (unlikely (!o)) continue; |
2292 | 0 |
|
2293 | 0 | if (!o->serialize_subset (c, _, this, lookup_map, klass_map)) |
2294 | 0 | { |
2295 | 0 | out->rule.pop (); |
2296 | 0 | c->serializer->revert (o_snap); |
2297 | 0 | } |
2298 | 0 | } |
2299 | 0 |
|
2300 | 0 | bool ret = bool (out->rule); |
2301 | 0 | if (!ret) c->serializer->revert (snap); |
2302 | 0 |
|
2303 | 0 | return_trace (ret); |
2304 | 0 | } |
2305 | | |
2306 | | bool sanitize (hb_sanitize_context_t *c) const |
2307 | 0 | { |
2308 | 0 | TRACE_SANITIZE (this); |
2309 | 0 | return_trace (rule.sanitize (c, this)); |
2310 | 0 | } |
2311 | | |
2312 | | protected: |
2313 | | Array16OfOffset16To<Rule> |
2314 | | rule; /* Array of Rule tables |
2315 | | * ordered by preference */ |
2316 | | public: |
2317 | | DEFINE_SIZE_ARRAY (2, rule); |
2318 | | }; |
2319 | | |
2320 | | |
2321 | | template <typename Types> |
2322 | | struct ContextFormat1_4 |
2323 | | { |
2324 | | using RuleSet = OT::RuleSet<Types>; |
2325 | | |
2326 | | bool intersects (const hb_set_t *glyphs) const |
2327 | 0 | { |
2328 | 0 | struct ContextClosureLookupContext lookup_context = { |
2329 | 0 | {intersects_glyph, intersected_glyph}, |
2330 | 0 | ContextFormat::SimpleContext, |
2331 | 0 | nullptr |
2332 | 0 | }; |
2333 | 0 |
|
2334 | 0 | return |
2335 | 0 | + hb_zip (this+coverage, ruleSet) |
2336 | 0 | | hb_filter (*glyphs, hb_first) |
2337 | 0 | | hb_map (hb_second) |
2338 | 0 | | hb_map (hb_add (this)) |
2339 | 0 | | hb_map ([&] (const RuleSet &_) { return _.intersects (glyphs, lookup_context); }) |
2340 | 0 | | hb_any |
2341 | 0 | ; |
2342 | 0 | } |
2343 | | |
2344 | | bool may_have_non_1to1 () const |
2345 | 0 | { return true; } |
2346 | | |
2347 | | void closure (hb_closure_context_t *c) const |
2348 | 0 | { |
2349 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
2350 | 0 | if (unlikely (!cur_active_glyphs)) return; |
2351 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), *cur_active_glyphs); |
2352 | |
|
2353 | 0 | struct ContextClosureLookupContext lookup_context = { |
2354 | 0 | {intersects_glyph, intersected_glyph}, |
2355 | 0 | ContextFormat::SimpleContext, |
2356 | 0 | nullptr |
2357 | 0 | }; |
2358 | |
|
2359 | 0 | + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len)) |
2360 | 0 | | hb_filter ([&] (hb_codepoint_t _) { |
2361 | 0 | return c->previous_parent_active_glyphs ().has (_); |
2362 | 0 | }, hb_first) |
2363 | 0 | | hb_map ([&](const hb_pair_t<hb_codepoint_t, unsigned> _) { return hb_pair_t<unsigned, const RuleSet&> (_.first, this+ruleSet[_.second]); }) |
2364 | 0 | | hb_apply ([&] (const hb_pair_t<unsigned, const RuleSet&>& _) { _.second.closure (c, _.first, lookup_context); }) |
2365 | 0 | ; |
2366 | |
|
2367 | 0 | c->pop_cur_done_glyphs (); |
2368 | 0 | } |
2369 | | |
2370 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
2371 | 0 | { |
2372 | 0 | struct ContextClosureLookupContext lookup_context = { |
2373 | 0 | {intersects_glyph, nullptr}, |
2374 | 0 | ContextFormat::SimpleContext, |
2375 | 0 | nullptr |
2376 | 0 | }; |
2377 | 0 |
|
2378 | 0 | + hb_zip (this+coverage, ruleSet) |
2379 | 0 | | hb_filter (*c->glyphs, hb_first) |
2380 | 0 | | hb_map (hb_second) |
2381 | 0 | | hb_map (hb_add (this)) |
2382 | 0 | | hb_apply ([&] (const RuleSet &_) { _.closure_lookups (c, lookup_context); }) |
2383 | 0 | ; |
2384 | 0 | } |
2385 | | |
2386 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
2387 | | |
2388 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
2389 | 0 | { |
2390 | 0 | (this+coverage).collect_coverage (c->input); |
2391 | |
|
2392 | 0 | struct ContextCollectGlyphsLookupContext lookup_context = { |
2393 | 0 | {collect_glyph}, |
2394 | 0 | nullptr |
2395 | 0 | }; |
2396 | |
|
2397 | 0 | + hb_iter (ruleSet) |
2398 | 0 | | hb_map (hb_add (this)) |
2399 | 0 | | hb_apply ([&] (const RuleSet &_) { _.collect_glyphs (c, lookup_context); }) |
2400 | 0 | ; |
2401 | 0 | } |
2402 | | |
2403 | | bool would_apply (hb_would_apply_context_t *c) const |
2404 | 0 | { |
2405 | 0 | const RuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyphs[0])]; |
2406 | 0 | struct ContextApplyLookupContext lookup_context = { |
2407 | 0 | {match_glyph}, |
2408 | 0 | nullptr |
2409 | 0 | }; |
2410 | 0 | return rule_set.would_apply (c, lookup_context); |
2411 | 0 | } |
2412 | | |
2413 | 0 | const Coverage &get_coverage () const { return this+coverage; } |
2414 | | |
2415 | | bool apply (hb_ot_apply_context_t *c) const |
2416 | 0 | { |
2417 | 0 | TRACE_APPLY (this); |
2418 | 0 | unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); |
2419 | 0 | if (likely (index == NOT_COVERED)) |
2420 | 0 | return_trace (false); |
2421 | | |
2422 | 0 | const RuleSet &rule_set = this+ruleSet[index]; |
2423 | 0 | struct ContextApplyLookupContext lookup_context = { |
2424 | 0 | {match_glyph}, |
2425 | 0 | nullptr |
2426 | 0 | }; |
2427 | 0 | return_trace (rule_set.apply (c, lookup_context)); |
2428 | 0 | } |
2429 | | |
2430 | | bool subset (hb_subset_context_t *c) const |
2431 | 0 | { |
2432 | 0 | TRACE_SUBSET (this); |
2433 | 0 | const hb_set_t &glyphset = *c->plan->glyphset_gsub (); |
2434 | 0 | const hb_map_t &glyph_map = *c->plan->glyph_map; |
2435 | 0 |
|
2436 | 0 | auto *out = c->serializer->start_embed (*this); |
2437 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
2438 | 0 | out->format = format; |
2439 | 0 |
|
2440 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
2441 | 0 | hb_sorted_vector_t<hb_codepoint_t> new_coverage; |
2442 | 0 | + hb_zip (this+coverage, ruleSet) |
2443 | 0 | | hb_filter (glyphset, hb_first) |
2444 | 0 | | hb_filter (subset_offset_array (c, out->ruleSet, this, lookup_map), hb_second) |
2445 | 0 | | hb_map (hb_first) |
2446 | 0 | | hb_map (glyph_map) |
2447 | 0 | | hb_sink (new_coverage) |
2448 | 0 | ; |
2449 | 0 |
|
2450 | 0 | out->coverage.serialize_serialize (c->serializer, new_coverage.iter ()); |
2451 | 0 | return_trace (bool (new_coverage)); |
2452 | 0 | } |
2453 | | |
2454 | | bool sanitize (hb_sanitize_context_t *c) const |
2455 | 0 | { |
2456 | 0 | TRACE_SANITIZE (this); |
2457 | 0 | return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); |
2458 | 0 | } |
2459 | | |
2460 | | protected: |
2461 | | HBUINT16 format; /* Format identifier--format = 1 */ |
2462 | | typename Types::template OffsetTo<Coverage> |
2463 | | coverage; /* Offset to Coverage table--from |
2464 | | * beginning of table */ |
2465 | | Array16Of<typename Types::template OffsetTo<RuleSet>> |
2466 | | ruleSet; /* Array of RuleSet tables |
2467 | | * ordered by Coverage Index */ |
2468 | | public: |
2469 | | DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ruleSet); |
2470 | | }; |
2471 | | |
2472 | | |
2473 | | template <typename Types> |
2474 | | struct ContextFormat2_5 |
2475 | | { |
2476 | | using RuleSet = OT::RuleSet<SmallTypes>; |
2477 | | |
2478 | | bool intersects (const hb_set_t *glyphs) const |
2479 | 0 | { |
2480 | 0 | if (!(this+coverage).intersects (glyphs)) |
2481 | 0 | return false; |
2482 | 0 |
|
2483 | 0 | const ClassDef &class_def = this+classDef; |
2484 | 0 |
|
2485 | 0 | hb_map_t cache; |
2486 | 0 | struct ContextClosureLookupContext lookup_context = { |
2487 | 0 | {intersects_class, nullptr}, |
2488 | 0 | ContextFormat::ClassBasedContext, |
2489 | 0 | &class_def, |
2490 | 0 | &cache |
2491 | 0 | }; |
2492 | 0 |
|
2493 | 0 | hb_set_t retained_coverage_glyphs; |
2494 | 0 | (this+coverage).intersect_set (*glyphs, retained_coverage_glyphs); |
2495 | 0 |
|
2496 | 0 | hb_set_t coverage_glyph_classes; |
2497 | 0 | class_def.intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); |
2498 | 0 |
|
2499 | 0 |
|
2500 | 0 | return |
2501 | 0 | + hb_iter (ruleSet) |
2502 | 0 | | hb_map (hb_add (this)) |
2503 | 0 | | hb_enumerate |
2504 | 0 | | hb_map ([&] (const hb_pair_t<unsigned, const RuleSet &> p) |
2505 | 0 | { return class_def.intersects_class (glyphs, p.first) && |
2506 | 0 | coverage_glyph_classes.has (p.first) && |
2507 | 0 | p.second.intersects (glyphs, lookup_context); }) |
2508 | 0 | | hb_any |
2509 | 0 | ; |
2510 | 0 | } |
2511 | | |
2512 | | bool may_have_non_1to1 () const |
2513 | 0 | { return true; } |
2514 | | |
2515 | | void closure (hb_closure_context_t *c) const |
2516 | 0 | { |
2517 | 0 | if (!(this+coverage).intersects (c->glyphs)) |
2518 | 0 | return; |
2519 | | |
2520 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
2521 | 0 | if (unlikely (!cur_active_glyphs)) return; |
2522 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
2523 | 0 | *cur_active_glyphs); |
2524 | |
|
2525 | 0 | const ClassDef &class_def = this+classDef; |
2526 | |
|
2527 | 0 | hb_map_t cache; |
2528 | 0 | intersected_class_cache_t intersected_cache; |
2529 | 0 | struct ContextClosureLookupContext lookup_context = { |
2530 | 0 | {intersects_class, intersected_class_glyphs}, |
2531 | 0 | ContextFormat::ClassBasedContext, |
2532 | 0 | &class_def, |
2533 | 0 | &cache, |
2534 | 0 | &intersected_cache |
2535 | 0 | }; |
2536 | |
|
2537 | 0 | + hb_enumerate (ruleSet) |
2538 | 0 | | hb_filter ([&] (unsigned _) |
2539 | 0 | { return class_def.intersects_class (&c->parent_active_glyphs (), _); }, |
2540 | 0 | hb_first) |
2541 | 0 | | hb_apply ([&] (const hb_pair_t<unsigned, const typename Types::template OffsetTo<RuleSet>&> _) |
2542 | 0 | { |
2543 | 0 | const RuleSet& rule_set = this+_.second; |
2544 | 0 | rule_set.closure (c, _.first, lookup_context); |
2545 | 0 | }) |
2546 | 0 | ; |
2547 | |
|
2548 | 0 | c->pop_cur_done_glyphs (); |
2549 | 0 | } |
2550 | | |
2551 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
2552 | 0 | { |
2553 | 0 | if (!(this+coverage).intersects (c->glyphs)) |
2554 | 0 | return; |
2555 | 0 |
|
2556 | 0 | const ClassDef &class_def = this+classDef; |
2557 | 0 |
|
2558 | 0 | hb_map_t cache; |
2559 | 0 | struct ContextClosureLookupContext lookup_context = { |
2560 | 0 | {intersects_class, nullptr}, |
2561 | 0 | ContextFormat::ClassBasedContext, |
2562 | 0 | &class_def, |
2563 | 0 | &cache |
2564 | 0 | }; |
2565 | 0 |
|
2566 | 0 | + hb_iter (ruleSet) |
2567 | 0 | | hb_map (hb_add (this)) |
2568 | 0 | | hb_enumerate |
2569 | 0 | | hb_filter ([&] (const hb_pair_t<unsigned, const RuleSet &> p) |
2570 | 0 | { return class_def.intersects_class (c->glyphs, p.first); }) |
2571 | 0 | | hb_map (hb_second) |
2572 | 0 | | hb_apply ([&] (const RuleSet & _) |
2573 | 0 | { _.closure_lookups (c, lookup_context); }); |
2574 | 0 | } |
2575 | | |
2576 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
2577 | | |
2578 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
2579 | 0 | { |
2580 | 0 | (this+coverage).collect_coverage (c->input); |
2581 | |
|
2582 | 0 | const ClassDef &class_def = this+classDef; |
2583 | 0 | struct ContextCollectGlyphsLookupContext lookup_context = { |
2584 | 0 | {collect_class}, |
2585 | 0 | &class_def |
2586 | 0 | }; |
2587 | |
|
2588 | 0 | + hb_iter (ruleSet) |
2589 | 0 | | hb_map (hb_add (this)) |
2590 | 0 | | hb_apply ([&] (const RuleSet &_) { _.collect_glyphs (c, lookup_context); }) |
2591 | 0 | ; |
2592 | 0 | } |
2593 | | |
2594 | | bool would_apply (hb_would_apply_context_t *c) const |
2595 | 0 | { |
2596 | 0 | const ClassDef &class_def = this+classDef; |
2597 | 0 | unsigned int index = class_def.get_class (c->glyphs[0]); |
2598 | 0 | const RuleSet &rule_set = this+ruleSet[index]; |
2599 | 0 | struct ContextApplyLookupContext lookup_context = { |
2600 | 0 | {match_class}, |
2601 | 0 | &class_def |
2602 | 0 | }; |
2603 | 0 | return rule_set.would_apply (c, lookup_context); |
2604 | 0 | } |
2605 | | |
2606 | 0 | const Coverage &get_coverage () const { return this+coverage; } |
2607 | | |
2608 | | unsigned cache_cost () const |
2609 | 0 | { |
2610 | 0 | unsigned c = (this+classDef).cost () * ruleSet.len; |
2611 | 0 | return c >= 4 ? c : 0; |
2612 | 0 | } |
2613 | | static void * cache_func (void *p, hb_ot_lookup_cache_op_t op) |
2614 | 0 | { |
2615 | 0 | switch (op) |
2616 | 0 | { |
2617 | 0 | case hb_ot_lookup_cache_op_t::CREATE: |
2618 | 0 | return (void *) true; |
2619 | 0 | case hb_ot_lookup_cache_op_t::ENTER: |
2620 | 0 | { |
2621 | 0 | hb_ot_apply_context_t *c = (hb_ot_apply_context_t *) p; |
2622 | 0 | if (!HB_BUFFER_TRY_ALLOCATE_VAR (c->buffer, syllable)) |
2623 | 0 | return (void *) false; |
2624 | 0 | auto &info = c->buffer->info; |
2625 | 0 | unsigned count = c->buffer->len; |
2626 | 0 | for (unsigned i = 0; i < count; i++) |
2627 | 0 | info[i].syllable() = 255; |
2628 | 0 | c->new_syllables = 255; |
2629 | 0 | return (void *) true; |
2630 | 0 | } |
2631 | 0 | case hb_ot_lookup_cache_op_t::LEAVE: |
2632 | 0 | { |
2633 | 0 | hb_ot_apply_context_t *c = (hb_ot_apply_context_t *) p; |
2634 | 0 | c->new_syllables = (unsigned) -1; |
2635 | 0 | HB_BUFFER_DEALLOCATE_VAR (c->buffer, syllable); |
2636 | 0 | return nullptr; |
2637 | 0 | } |
2638 | 0 | case hb_ot_lookup_cache_op_t::DESTROY: |
2639 | 0 | return nullptr; |
2640 | 0 | } |
2641 | 0 | return nullptr; |
2642 | 0 | } |
2643 | | |
2644 | 0 | bool apply_cached (hb_ot_apply_context_t *c) const { return _apply (c, true); } |
2645 | 0 | bool apply (hb_ot_apply_context_t *c) const { return _apply (c, false); } |
2646 | | bool _apply (hb_ot_apply_context_t *c, bool cached) const |
2647 | 0 | { |
2648 | 0 | TRACE_APPLY (this); |
2649 | 0 | unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); |
2650 | 0 | if (index == NOT_COVERED) return_trace (false); |
2651 | | |
2652 | 0 | const ClassDef &class_def = this+classDef; |
2653 | |
|
2654 | 0 | struct ContextApplyLookupContext lookup_context = { |
2655 | 0 | {cached ? match_class_cached : match_class}, |
2656 | 0 | &class_def |
2657 | 0 | }; |
2658 | |
|
2659 | 0 | if (cached && c->buffer->cur().syllable() < 255) |
2660 | 0 | index = c->buffer->cur().syllable (); |
2661 | 0 | else |
2662 | 0 | index = class_def.get_class (c->buffer->cur().codepoint); |
2663 | 0 | const RuleSet &rule_set = this+ruleSet[index]; |
2664 | 0 | return_trace (rule_set.apply (c, lookup_context)); |
2665 | 0 | } |
2666 | | |
2667 | | bool subset (hb_subset_context_t *c) const |
2668 | 0 | { |
2669 | 0 | TRACE_SUBSET (this); |
2670 | 0 | auto *out = c->serializer->start_embed (*this); |
2671 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
2672 | 0 | out->format = format; |
2673 | 0 | if (unlikely (!out->coverage.serialize_subset (c, coverage, this))) |
2674 | 0 | return_trace (false); |
2675 | 0 |
|
2676 | 0 | hb_map_t klass_map; |
2677 | 0 | out->classDef.serialize_subset (c, classDef, this, &klass_map); |
2678 | 0 |
|
2679 | 0 | const hb_set_t* glyphset = c->plan->glyphset_gsub (); |
2680 | 0 | hb_set_t retained_coverage_glyphs; |
2681 | 0 | (this+coverage).intersect_set (*glyphset, retained_coverage_glyphs); |
2682 | 0 |
|
2683 | 0 | hb_set_t coverage_glyph_classes; |
2684 | 0 | (this+classDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); |
2685 | 0 |
|
2686 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
2687 | 0 | bool ret = true; |
2688 | 0 | int non_zero_index = -1, index = 0; |
2689 | 0 | auto snapshot = c->serializer->snapshot(); |
2690 | 0 | for (const auto& _ : + hb_enumerate (ruleSet) |
2691 | 0 | | hb_filter (klass_map, hb_first)) |
2692 | 0 | { |
2693 | 0 | auto *o = out->ruleSet.serialize_append (c->serializer); |
2694 | 0 | if (unlikely (!o)) |
2695 | 0 | { |
2696 | 0 | ret = false; |
2697 | 0 | break; |
2698 | 0 | } |
2699 | 0 |
|
2700 | 0 | if (coverage_glyph_classes.has (_.first) && |
2701 | 0 | o->serialize_subset (c, _.second, this, lookup_map, &klass_map)) { |
2702 | 0 | non_zero_index = index; |
2703 | 0 | snapshot = c->serializer->snapshot(); |
2704 | 0 | } |
2705 | 0 |
|
2706 | 0 | index++; |
2707 | 0 | } |
2708 | 0 |
|
2709 | 0 | if (!ret || non_zero_index == -1) return_trace (false); |
2710 | 0 |
|
2711 | 0 | //prune empty trailing ruleSets |
2712 | 0 | --index; |
2713 | 0 | while (index > non_zero_index) |
2714 | 0 | { |
2715 | 0 | out->ruleSet.pop (); |
2716 | 0 | index--; |
2717 | 0 | } |
2718 | 0 | c->serializer->revert (snapshot); |
2719 | 0 |
|
2720 | 0 | return_trace (bool (out->ruleSet)); |
2721 | 0 | } |
2722 | | |
2723 | | bool sanitize (hb_sanitize_context_t *c) const |
2724 | 0 | { |
2725 | 0 | TRACE_SANITIZE (this); |
2726 | 0 | return_trace (coverage.sanitize (c, this) && classDef.sanitize (c, this) && ruleSet.sanitize (c, this)); |
2727 | 0 | } |
2728 | | |
2729 | | protected: |
2730 | | HBUINT16 format; /* Format identifier--format = 2 */ |
2731 | | typename Types::template OffsetTo<Coverage> |
2732 | | coverage; /* Offset to Coverage table--from |
2733 | | * beginning of table */ |
2734 | | typename Types::template OffsetTo<ClassDef> |
2735 | | classDef; /* Offset to glyph ClassDef table--from |
2736 | | * beginning of table */ |
2737 | | Array16Of<typename Types::template OffsetTo<RuleSet>> |
2738 | | ruleSet; /* Array of RuleSet tables |
2739 | | * ordered by class */ |
2740 | | public: |
2741 | | DEFINE_SIZE_ARRAY (4 + 2 * Types::size, ruleSet); |
2742 | | }; |
2743 | | |
2744 | | |
2745 | | struct ContextFormat3 |
2746 | | { |
2747 | | using RuleSet = OT::RuleSet<SmallTypes>; |
2748 | | |
2749 | | bool intersects (const hb_set_t *glyphs) const |
2750 | 0 | { |
2751 | 0 | if (!(this+coverageZ[0]).intersects (glyphs)) |
2752 | 0 | return false; |
2753 | 0 |
|
2754 | 0 | struct ContextClosureLookupContext lookup_context = { |
2755 | 0 | {intersects_coverage, nullptr}, |
2756 | 0 | ContextFormat::CoverageBasedContext, |
2757 | 0 | this |
2758 | 0 | }; |
2759 | 0 | return context_intersects (glyphs, |
2760 | 0 | glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), |
2761 | 0 | lookup_context); |
2762 | 0 | } |
2763 | | |
2764 | | bool may_have_non_1to1 () const |
2765 | 0 | { return true; } |
2766 | | |
2767 | | void closure (hb_closure_context_t *c) const |
2768 | 0 | { |
2769 | 0 | if (!(this+coverageZ[0]).intersects (c->glyphs)) |
2770 | 0 | return; |
2771 | | |
2772 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
2773 | 0 | if (unlikely (!cur_active_glyphs)) return; |
2774 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
2775 | 0 | *cur_active_glyphs); |
2776 | |
|
2777 | 0 | const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); |
2778 | 0 | struct ContextClosureLookupContext lookup_context = { |
2779 | 0 | {intersects_coverage, intersected_coverage_glyphs}, |
2780 | 0 | ContextFormat::CoverageBasedContext, |
2781 | 0 | this |
2782 | 0 | }; |
2783 | 0 | context_closure_lookup (c, |
2784 | 0 | glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), |
2785 | 0 | lookupCount, lookupRecord, |
2786 | 0 | 0, lookup_context); |
2787 | |
|
2788 | 0 | c->pop_cur_done_glyphs (); |
2789 | 0 | } |
2790 | | |
2791 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
2792 | 0 | { |
2793 | 0 | if (!intersects (c->glyphs)) |
2794 | 0 | return; |
2795 | 0 | const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); |
2796 | 0 | recurse_lookups (c, lookupCount, lookupRecord); |
2797 | 0 | } |
2798 | | |
2799 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
2800 | | |
2801 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
2802 | 0 | { |
2803 | 0 | (this+coverageZ[0]).collect_coverage (c->input); |
2804 | |
|
2805 | 0 | const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); |
2806 | 0 | struct ContextCollectGlyphsLookupContext lookup_context = { |
2807 | 0 | {collect_coverage}, |
2808 | 0 | this |
2809 | 0 | }; |
2810 | |
|
2811 | 0 | context_collect_glyphs_lookup (c, |
2812 | 0 | glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), |
2813 | 0 | lookupCount, lookupRecord, |
2814 | 0 | lookup_context); |
2815 | 0 | } |
2816 | | |
2817 | | bool would_apply (hb_would_apply_context_t *c) const |
2818 | 0 | { |
2819 | 0 | const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); |
2820 | 0 | struct ContextApplyLookupContext lookup_context = { |
2821 | 0 | {match_coverage}, |
2822 | 0 | this |
2823 | 0 | }; |
2824 | 0 | return context_would_apply_lookup (c, |
2825 | 0 | glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), |
2826 | 0 | lookupCount, lookupRecord, |
2827 | 0 | lookup_context); |
2828 | 0 | } |
2829 | | |
2830 | 0 | const Coverage &get_coverage () const { return this+coverageZ[0]; } |
2831 | | |
2832 | | bool apply (hb_ot_apply_context_t *c) const |
2833 | 0 | { |
2834 | 0 | TRACE_APPLY (this); |
2835 | 0 | unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint); |
2836 | 0 | if (index == NOT_COVERED) return_trace (false); |
2837 | | |
2838 | 0 | const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); |
2839 | 0 | struct ContextApplyLookupContext lookup_context = { |
2840 | 0 | {match_coverage}, |
2841 | 0 | this |
2842 | 0 | }; |
2843 | 0 | return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context)); |
2844 | 0 | } |
2845 | | |
2846 | | bool subset (hb_subset_context_t *c) const |
2847 | 0 | { |
2848 | 0 | TRACE_SUBSET (this); |
2849 | 0 | auto *out = c->serializer->start_embed (this); |
2850 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
2851 | 0 |
|
2852 | 0 | out->format = format; |
2853 | 0 | out->glyphCount = glyphCount; |
2854 | 0 |
|
2855 | 0 | auto coverages = coverageZ.as_array (glyphCount); |
2856 | 0 |
|
2857 | 0 | for (const Offset16To<Coverage>& offset : coverages) |
2858 | 0 | { |
2859 | 0 | /* TODO(subset) This looks like should not be necessary to write this way. */ |
2860 | 0 | auto *o = c->serializer->allocate_size<Offset16To<Coverage>> (Offset16To<Coverage>::static_size); |
2861 | 0 | if (unlikely (!o)) return_trace (false); |
2862 | 0 | if (!o->serialize_subset (c, offset, this)) return_trace (false); |
2863 | 0 | } |
2864 | 0 |
|
2865 | 0 | const auto& lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> (coverageZ.as_array (glyphCount)); |
2866 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
2867 | 0 |
|
2868 | 0 |
|
2869 | 0 | unsigned count = serialize_lookuprecord_array (c->serializer, lookupRecord.as_array (lookupCount), lookup_map); |
2870 | 0 | return_trace (c->serializer->check_assign (out->lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
2871 | 0 | } |
2872 | | |
2873 | | bool sanitize (hb_sanitize_context_t *c) const |
2874 | 0 | { |
2875 | 0 | TRACE_SANITIZE (this); |
2876 | 0 | if (unlikely (!c->check_struct (this))) return_trace (false); |
2877 | 0 | hb_barrier (); |
2878 | 0 | unsigned int count = glyphCount; |
2879 | 0 | if (unlikely (!count)) return_trace (false); /* We want to access coverageZ[0] freely. */ |
2880 | 0 | if (unlikely (!c->check_array (coverageZ.arrayZ, count))) return_trace (false); |
2881 | 0 | for (unsigned int i = 0; i < count; i++) |
2882 | 0 | if (unlikely (!coverageZ[i].sanitize (c, this))) return_trace (false); |
2883 | 0 | const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); |
2884 | 0 | return_trace (likely (c->check_array (lookupRecord, lookupCount))); |
2885 | 0 | } |
2886 | | |
2887 | | protected: |
2888 | | HBUINT16 format; /* Format identifier--format = 3 */ |
2889 | | HBUINT16 glyphCount; /* Number of glyphs in the input glyph |
2890 | | * sequence */ |
2891 | | HBUINT16 lookupCount; /* Number of LookupRecords */ |
2892 | | UnsizedArrayOf<Offset16To<Coverage>> |
2893 | | coverageZ; /* Array of offsets to Coverage |
2894 | | * table in glyph sequence order */ |
2895 | | /*UnsizedArrayOf<LookupRecord> |
2896 | | lookupRecordX;*/ /* Array of LookupRecords--in |
2897 | | * design order */ |
2898 | | public: |
2899 | | DEFINE_SIZE_ARRAY (6, coverageZ); |
2900 | | }; |
2901 | | |
2902 | | struct Context |
2903 | | { |
2904 | | template <typename context_t, typename ...Ts> |
2905 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
2906 | 0 | { |
2907 | 0 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); |
2908 | 0 | TRACE_DISPATCH (this, u.format); |
2909 | 0 | switch (u.format) { |
2910 | 0 | case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); |
2911 | 0 | case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); |
2912 | 0 | case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...)); |
2913 | | #ifndef HB_NO_BEYOND_64K |
2914 | | case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...)); |
2915 | | case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...)); |
2916 | | #endif |
2917 | 0 | default:return_trace (c->default_return_value ()); |
2918 | 0 | } |
2919 | 0 | } Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Context::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::Context::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Context::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Context::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const Unexecuted instantiation: hb_subset_context_t::return_t OT::Context::dispatch<hb_subset_context_t>(hb_subset_context_t*) const Unexecuted instantiation: hb_sanitize_context_t::return_t OT::Context::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::Context::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::Context::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::Context::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::Context::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::Context::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::Context::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::Context::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const |
2920 | | |
2921 | | protected: |
2922 | | union { |
2923 | | HBUINT16 format; /* Format identifier */ |
2924 | | ContextFormat1_4<SmallTypes> format1; |
2925 | | ContextFormat2_5<SmallTypes> format2; |
2926 | | ContextFormat3 format3; |
2927 | | #ifndef HB_NO_BEYOND_64K |
2928 | | ContextFormat1_4<MediumTypes> format4; |
2929 | | ContextFormat2_5<MediumTypes> format5; |
2930 | | #endif |
2931 | | } u; |
2932 | | }; |
2933 | | |
2934 | | |
2935 | | /* Chaining Contextual lookups */ |
2936 | | |
2937 | | struct ChainContextClosureLookupContext |
2938 | | { |
2939 | | ContextClosureFuncs funcs; |
2940 | | ContextFormat context_format; |
2941 | | const void *intersects_data[3]; |
2942 | | void *intersects_cache[3]; |
2943 | | void *intersected_glyphs_cache; |
2944 | | }; |
2945 | | |
2946 | | struct ChainContextCollectGlyphsLookupContext |
2947 | | { |
2948 | | ContextCollectGlyphsFuncs funcs; |
2949 | | const void *collect_data[3]; |
2950 | | }; |
2951 | | |
2952 | | struct ChainContextApplyLookupContext |
2953 | | { |
2954 | | ChainContextApplyFuncs funcs; |
2955 | | const void *match_data[3]; |
2956 | | }; |
2957 | | |
2958 | | template <typename HBUINT> |
2959 | | static inline bool chain_context_intersects (const hb_set_t *glyphs, |
2960 | | unsigned int backtrackCount, |
2961 | | const HBUINT backtrack[], |
2962 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
2963 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
2964 | | unsigned int lookaheadCount, |
2965 | | const HBUINT lookahead[], |
2966 | | ChainContextClosureLookupContext &lookup_context) |
2967 | 0 | { |
2968 | 0 | return array_is_subset_of (glyphs, |
2969 | 0 | backtrackCount, backtrack, |
2970 | 0 | lookup_context.funcs.intersects, |
2971 | 0 | lookup_context.intersects_data[0], |
2972 | 0 | lookup_context.intersects_cache[0]) |
2973 | 0 | && array_is_subset_of (glyphs, |
2974 | 0 | inputCount ? inputCount - 1 : 0, input, |
2975 | 0 | lookup_context.funcs.intersects, |
2976 | 0 | lookup_context.intersects_data[1], |
2977 | 0 | lookup_context.intersects_cache[1]) |
2978 | 0 | && array_is_subset_of (glyphs, |
2979 | 0 | lookaheadCount, lookahead, |
2980 | 0 | lookup_context.funcs.intersects, |
2981 | 0 | lookup_context.intersects_data[2], |
2982 | 0 | lookup_context.intersects_cache[2]); |
2983 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-aat-layout.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-ot-layout.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&) |
2984 | | |
2985 | | template <typename HBUINT> |
2986 | | static inline void chain_context_closure_lookup (hb_closure_context_t *c, |
2987 | | unsigned int backtrackCount, |
2988 | | const HBUINT backtrack[], |
2989 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
2990 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
2991 | | unsigned int lookaheadCount, |
2992 | | const HBUINT lookahead[], |
2993 | | unsigned int lookupCount, |
2994 | | const LookupRecord lookupRecord[], |
2995 | | unsigned value, |
2996 | | ChainContextClosureLookupContext &lookup_context) |
2997 | 0 | { |
2998 | 0 | if (chain_context_intersects (c->glyphs, |
2999 | 0 | backtrackCount, backtrack, |
3000 | 0 | inputCount, input, |
3001 | 0 | lookaheadCount, lookahead, |
3002 | 0 | lookup_context)) |
3003 | 0 | context_closure_recurse_lookups (c, |
3004 | 0 | inputCount, input, |
3005 | 0 | lookupCount, lookupRecord, |
3006 | 0 | value, |
3007 | 0 | lookup_context.context_format, |
3008 | 0 | lookup_context.intersects_data[1], |
3009 | 0 | lookup_context.funcs.intersected_glyphs, |
3010 | 0 | lookup_context.intersected_glyphs_cache); |
3011 | 0 | } Unexecuted instantiation: hb-ot-face.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-aat-layout.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-ot-layout.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&) |
3012 | | |
3013 | | template <typename HBUINT> |
3014 | | static inline void chain_context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c, |
3015 | | unsigned int backtrackCount, |
3016 | | const HBUINT backtrack[], |
3017 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
3018 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
3019 | | unsigned int lookaheadCount, |
3020 | | const HBUINT lookahead[], |
3021 | | unsigned int lookupCount, |
3022 | | const LookupRecord lookupRecord[], |
3023 | | ChainContextCollectGlyphsLookupContext &lookup_context) |
3024 | 0 | { |
3025 | 0 | collect_array (c, c->before, |
3026 | 0 | backtrackCount, backtrack, |
3027 | 0 | lookup_context.funcs.collect, lookup_context.collect_data[0]); |
3028 | 0 | collect_array (c, c->input, |
3029 | 0 | inputCount ? inputCount - 1 : 0, input, |
3030 | 0 | lookup_context.funcs.collect, lookup_context.collect_data[1]); |
3031 | 0 | collect_array (c, c->after, |
3032 | 0 | lookaheadCount, lookahead, |
3033 | 0 | lookup_context.funcs.collect, lookup_context.collect_data[2]); |
3034 | 0 | recurse_lookups (c, |
3035 | 0 | lookupCount, lookupRecord); |
3036 | 0 | } Unexecuted instantiation: hb-ot-face.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-aat-layout.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-ot-layout.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&) |
3037 | | |
3038 | | template <typename HBUINT> |
3039 | | static inline bool chain_context_would_apply_lookup (hb_would_apply_context_t *c, |
3040 | | unsigned int backtrackCount, |
3041 | | const HBUINT backtrack[] HB_UNUSED, |
3042 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
3043 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
3044 | | unsigned int lookaheadCount, |
3045 | | const HBUINT lookahead[] HB_UNUSED, |
3046 | | unsigned int lookupCount HB_UNUSED, |
3047 | | const LookupRecord lookupRecord[] HB_UNUSED, |
3048 | | const ChainContextApplyLookupContext &lookup_context) |
3049 | 0 | { |
3050 | 0 | return (c->zero_context ? !backtrackCount && !lookaheadCount : true) |
3051 | 0 | && would_match_input (c, |
3052 | 0 | inputCount, input, |
3053 | 0 | lookup_context.funcs.match[1], lookup_context.match_data[1]); |
3054 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-aat-layout.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-layout.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) |
3055 | | |
3056 | | template <typename HBUINT> |
3057 | | HB_ALWAYS_INLINE |
3058 | | static bool chain_context_apply_lookup (hb_ot_apply_context_t *c, |
3059 | | unsigned int backtrackCount, |
3060 | | const HBUINT backtrack[], |
3061 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
3062 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
3063 | | unsigned int lookaheadCount, |
3064 | | const HBUINT lookahead[], |
3065 | | unsigned int lookupCount, |
3066 | | const LookupRecord lookupRecord[], |
3067 | | const ChainContextApplyLookupContext &lookup_context) |
3068 | 0 | { |
3069 | 0 | if (unlikely (inputCount > HB_MAX_CONTEXT_LENGTH)) return false; |
3070 | 0 | unsigned match_positions_stack[4]; |
3071 | 0 | unsigned *match_positions = match_positions_stack; |
3072 | 0 | if (unlikely (inputCount > ARRAY_LENGTH (match_positions_stack))) |
3073 | 0 | { |
3074 | 0 | match_positions = (unsigned *) hb_malloc (hb_max (inputCount, 1u) * sizeof (match_positions[0])); |
3075 | 0 | if (unlikely (!match_positions)) |
3076 | 0 | return false; |
3077 | 0 | } |
3078 | | |
3079 | 0 | unsigned start_index = c->buffer->out_len; |
3080 | 0 | unsigned end_index = c->buffer->idx; |
3081 | 0 | unsigned match_end = 0; |
3082 | 0 | bool ret = true; |
3083 | 0 | if (!(match_input (c, |
3084 | 0 | inputCount, input, |
3085 | 0 | lookup_context.funcs.match[1], lookup_context.match_data[1], |
3086 | 0 | &match_end, match_positions) && (end_index = match_end) |
3087 | 0 | && match_lookahead (c, |
3088 | 0 | lookaheadCount, lookahead, |
3089 | 0 | lookup_context.funcs.match[2], lookup_context.match_data[2], |
3090 | 0 | match_end, &end_index))) |
3091 | 0 | { |
3092 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, end_index); |
3093 | 0 | ret = false; |
3094 | 0 | goto done; |
3095 | 0 | } |
3096 | | |
3097 | 0 | if (!match_backtrack (c, |
3098 | 0 | backtrackCount, backtrack, |
3099 | 0 | lookup_context.funcs.match[0], lookup_context.match_data[0], |
3100 | 0 | &start_index)) |
3101 | 0 | { |
3102 | 0 | c->buffer->unsafe_to_concat_from_outbuffer (start_index, end_index); |
3103 | 0 | ret = false; |
3104 | 0 | goto done; |
3105 | 0 | } |
3106 | | |
3107 | 0 | c->buffer->unsafe_to_break_from_outbuffer (start_index, end_index); |
3108 | 0 | apply_lookup (c, |
3109 | 0 | inputCount, match_positions, |
3110 | 0 | lookupCount, lookupRecord, |
3111 | 0 | match_end); |
3112 | 0 | done: |
3113 | |
|
3114 | 0 | if (unlikely (match_positions != match_positions_stack)) |
3115 | 0 | hb_free (match_positions); |
3116 | |
|
3117 | 0 | return ret; |
3118 | 0 | } Unexecuted instantiation: hb-ot-face.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-aat-layout.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-layout.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&) |
3119 | | |
3120 | | template <typename Types> |
3121 | | struct ChainRule |
3122 | | { |
3123 | | template <typename T> |
3124 | | friend struct ChainRuleSet; |
3125 | | |
3126 | | bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const |
3127 | 0 | { |
3128 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3129 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3130 | 0 | return chain_context_intersects (glyphs, |
3131 | 0 | backtrack.len, backtrack.arrayZ, |
3132 | 0 | input.lenP1, input.arrayZ, |
3133 | 0 | lookahead.len, lookahead.arrayZ, |
3134 | 0 | lookup_context); |
3135 | 0 | } |
3136 | | |
3137 | | void closure (hb_closure_context_t *c, unsigned value, |
3138 | | ChainContextClosureLookupContext &lookup_context) const |
3139 | 0 | { |
3140 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3141 | | |
3142 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3143 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3144 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3145 | 0 | chain_context_closure_lookup (c, |
3146 | 0 | backtrack.len, backtrack.arrayZ, |
3147 | 0 | input.lenP1, input.arrayZ, |
3148 | 0 | lookahead.len, lookahead.arrayZ, |
3149 | 0 | lookup.len, lookup.arrayZ, |
3150 | 0 | value, |
3151 | 0 | lookup_context); |
3152 | 0 | } |
3153 | | |
3154 | | void closure_lookups (hb_closure_lookups_context_t *c, |
3155 | | ChainContextClosureLookupContext &lookup_context) const |
3156 | 0 | { |
3157 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3158 | 0 | if (!intersects (c->glyphs, lookup_context)) return; |
3159 | 0 |
|
3160 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3161 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3162 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3163 | 0 | recurse_lookups (c, lookup.len, lookup.arrayZ); |
3164 | 0 | } |
3165 | | |
3166 | | void collect_glyphs (hb_collect_glyphs_context_t *c, |
3167 | | ChainContextCollectGlyphsLookupContext &lookup_context) const |
3168 | 0 | { |
3169 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3170 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3171 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3172 | 0 | chain_context_collect_glyphs_lookup (c, |
3173 | 0 | backtrack.len, backtrack.arrayZ, |
3174 | 0 | input.lenP1, input.arrayZ, |
3175 | 0 | lookahead.len, lookahead.arrayZ, |
3176 | 0 | lookup.len, lookup.arrayZ, |
3177 | 0 | lookup_context); |
3178 | 0 | } |
3179 | | |
3180 | | bool would_apply (hb_would_apply_context_t *c, |
3181 | | const ChainContextApplyLookupContext &lookup_context) const |
3182 | 0 | { |
3183 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3184 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3185 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3186 | 0 | return chain_context_would_apply_lookup (c, |
3187 | 0 | backtrack.len, backtrack.arrayZ, |
3188 | 0 | input.lenP1, input.arrayZ, |
3189 | 0 | lookahead.len, lookahead.arrayZ, lookup.len, |
3190 | 0 | lookup.arrayZ, lookup_context); |
3191 | 0 | } |
3192 | | |
3193 | | bool apply (hb_ot_apply_context_t *c, |
3194 | | const ChainContextApplyLookupContext &lookup_context) const |
3195 | 0 | { |
3196 | 0 | TRACE_APPLY (this); |
3197 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3198 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3199 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3200 | 0 | return_trace (chain_context_apply_lookup (c, |
3201 | 0 | backtrack.len, backtrack.arrayZ, |
3202 | 0 | input.lenP1, input.arrayZ, |
3203 | 0 | lookahead.len, lookahead.arrayZ, lookup.len, |
3204 | 0 | lookup.arrayZ, lookup_context)); |
3205 | 0 | } |
3206 | | |
3207 | | template<typename Iterator, |
3208 | | hb_requires (hb_is_iterator (Iterator))> |
3209 | | void serialize_array (hb_serialize_context_t *c, |
3210 | | HBUINT16 len, |
3211 | | Iterator it) const |
3212 | 0 | { |
3213 | 0 | c->copy (len); |
3214 | 0 | for (const auto g : it) |
3215 | 0 | c->copy ((HBUINT16) g); |
3216 | 0 | } |
3217 | | |
3218 | | bool serialize (hb_serialize_context_t *c, |
3219 | | const hb_map_t *lookup_map, |
3220 | | const hb_map_t *backtrack_map, |
3221 | | const hb_map_t *input_map = nullptr, |
3222 | | const hb_map_t *lookahead_map = nullptr) const |
3223 | 0 | { |
3224 | 0 | TRACE_SERIALIZE (this); |
3225 | 0 |
|
3226 | 0 | const hb_map_t *mapping = backtrack_map; |
3227 | 0 | serialize_array (c, backtrack.len, + backtrack.iter () |
3228 | 0 | | hb_map (mapping)); |
3229 | 0 |
|
3230 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3231 | 0 | if (input_map) mapping = input_map; |
3232 | 0 | serialize_array (c, input.lenP1, + input.iter () |
3233 | 0 | | hb_map (mapping)); |
3234 | 0 |
|
3235 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3236 | 0 | if (lookahead_map) mapping = lookahead_map; |
3237 | 0 | serialize_array (c, lookahead.len, + lookahead.iter () |
3238 | 0 | | hb_map (mapping)); |
3239 | 0 |
|
3240 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3241 | 0 |
|
3242 | 0 | HBUINT16* lookupCount = c->embed (&(lookup.len)); |
3243 | 0 | if (!lookupCount) return_trace (false); |
3244 | 0 |
|
3245 | 0 | unsigned count = serialize_lookuprecord_array (c, lookup.as_array (), lookup_map); |
3246 | 0 | return_trace (c->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
3247 | 0 | } |
3248 | | |
3249 | | bool subset (hb_subset_context_t *c, |
3250 | | const hb_map_t *lookup_map, |
3251 | | const hb_map_t *backtrack_map = nullptr, |
3252 | | const hb_map_t *input_map = nullptr, |
3253 | | const hb_map_t *lookahead_map = nullptr) const |
3254 | 0 | { |
3255 | 0 | TRACE_SUBSET (this); |
3256 | 0 |
|
3257 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3258 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3259 | 0 |
|
3260 | 0 | if (!backtrack_map) |
3261 | 0 | { |
3262 | 0 | const hb_set_t &glyphset = *c->plan->glyphset_gsub (); |
3263 | 0 | if (!hb_all (backtrack, glyphset) || |
3264 | 0 | !hb_all (input, glyphset) || |
3265 | 0 | !hb_all (lookahead, glyphset)) |
3266 | 0 | return_trace (false); |
3267 | 0 |
|
3268 | 0 | serialize (c->serializer, lookup_map, c->plan->glyph_map); |
3269 | 0 | } |
3270 | 0 | else |
3271 | 0 | { |
3272 | 0 | if (!hb_all (backtrack, backtrack_map) || |
3273 | 0 | !hb_all (input, input_map) || |
3274 | 0 | !hb_all (lookahead, lookahead_map)) |
3275 | 0 | return_trace (false); |
3276 | 0 |
|
3277 | 0 | serialize (c->serializer, lookup_map, backtrack_map, input_map, lookahead_map); |
3278 | 0 | } |
3279 | 0 |
|
3280 | 0 | return_trace (true); |
3281 | 0 | } |
3282 | | |
3283 | | bool sanitize (hb_sanitize_context_t *c) const |
3284 | 422 | { |
3285 | 422 | TRACE_SANITIZE (this); |
3286 | | /* Hyper-optimized sanitized because this is really hot. */ |
3287 | 422 | if (unlikely (!backtrack.len.sanitize (c))) return_trace (false); |
3288 | 422 | hb_barrier (); |
3289 | 422 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3290 | 422 | if (unlikely (!input.lenP1.sanitize (c))) return_trace (false); |
3291 | 422 | hb_barrier (); |
3292 | 422 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3293 | 422 | if (unlikely (!lookahead.len.sanitize (c))) return_trace (false); |
3294 | 422 | hb_barrier (); |
3295 | 422 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3296 | 422 | return_trace (likely (lookup.sanitize (c))); |
3297 | 422 | } |
3298 | | |
3299 | | protected: |
3300 | | Array16Of<typename Types::HBUINT> |
3301 | | backtrack; /* Array of backtracking values |
3302 | | * (to be matched before the input |
3303 | | * sequence) */ |
3304 | | HeadlessArray16Of<typename Types::HBUINT> |
3305 | | inputX; /* Array of input values (start with |
3306 | | * second glyph) */ |
3307 | | Array16Of<typename Types::HBUINT> |
3308 | | lookaheadX; /* Array of lookahead values's (to be |
3309 | | * matched after the input sequence) */ |
3310 | | Array16Of<LookupRecord> |
3311 | | lookupX; /* Array of LookupRecords--in |
3312 | | * design order) */ |
3313 | | public: |
3314 | | DEFINE_SIZE_MIN (8); |
3315 | | }; |
3316 | | |
3317 | | template <typename Types> |
3318 | | struct ChainRuleSet |
3319 | | { |
3320 | | using ChainRule = OT::ChainRule<Types>; |
3321 | | |
3322 | | bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const |
3323 | 0 | { |
3324 | 0 | return |
3325 | 0 | + hb_iter (rule) |
3326 | 0 | | hb_map (hb_add (this)) |
3327 | 0 | | hb_map ([&] (const ChainRule &_) { return _.intersects (glyphs, lookup_context); }) |
3328 | 0 | | hb_any |
3329 | 0 | ; |
3330 | 0 | } |
3331 | | void closure (hb_closure_context_t *c, unsigned value, ChainContextClosureLookupContext &lookup_context) const |
3332 | 0 | { |
3333 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3334 | | |
3335 | 0 | return |
3336 | 0 | + hb_iter (rule) |
3337 | 0 | | hb_map (hb_add (this)) |
3338 | 0 | | hb_apply ([&] (const ChainRule &_) { _.closure (c, value, lookup_context); }) |
3339 | 0 | ; |
3340 | 0 | } |
3341 | | |
3342 | | void closure_lookups (hb_closure_lookups_context_t *c, |
3343 | | ChainContextClosureLookupContext &lookup_context) const |
3344 | 0 | { |
3345 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3346 | 0 |
|
3347 | 0 | + hb_iter (rule) |
3348 | 0 | | hb_map (hb_add (this)) |
3349 | 0 | | hb_apply ([&] (const ChainRule &_) { _.closure_lookups (c, lookup_context); }) |
3350 | 0 | ; |
3351 | 0 | } |
3352 | | |
3353 | | void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const |
3354 | 0 | { |
3355 | 0 | return |
3356 | 0 | + hb_iter (rule) |
3357 | 0 | | hb_map (hb_add (this)) |
3358 | 0 | | hb_apply ([&] (const ChainRule &_) { _.collect_glyphs (c, lookup_context); }) |
3359 | 0 | ; |
3360 | 0 | } |
3361 | | |
3362 | | bool would_apply (hb_would_apply_context_t *c, |
3363 | | const ChainContextApplyLookupContext &lookup_context) const |
3364 | 0 | { |
3365 | 0 | return |
3366 | 0 | + hb_iter (rule) |
3367 | 0 | | hb_map (hb_add (this)) |
3368 | 0 | | hb_map ([&] (const ChainRule &_) { return _.would_apply (c, lookup_context); }) |
3369 | 0 | | hb_any |
3370 | 0 | ; |
3371 | 0 | } |
3372 | | |
3373 | | bool apply (hb_ot_apply_context_t *c, |
3374 | | const ChainContextApplyLookupContext &lookup_context) const |
3375 | 0 | { |
3376 | 0 | TRACE_APPLY (this); |
3377 | |
|
3378 | 0 | unsigned num_rules = rule.len; |
3379 | |
|
3380 | 0 | #ifndef HB_NO_OT_RULESETS_FAST_PATH |
3381 | 0 | if (HB_OPTIMIZE_SIZE_VAL || num_rules <= 4) |
3382 | 0 | #endif |
3383 | 0 | { |
3384 | 0 | slow: |
3385 | 0 | return_trace ( |
3386 | 0 | + hb_iter (rule) |
3387 | 0 | | hb_map (hb_add (this)) |
3388 | 0 | | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) |
3389 | 0 | | hb_any |
3390 | 0 | ) |
3391 | 0 | ; |
3392 | 0 | } |
3393 | | |
3394 | | /* This version is optimized for speed by matching the first & second |
3395 | | * components of the rule here, instead of calling into the matching code. |
3396 | | * |
3397 | | * Replicated from LigatureSet::apply(). */ |
3398 | | |
3399 | | /* If the input skippy has non-auto joiners behavior (as in Indic shapers), |
3400 | | * skip this fast path, as we don't distinguish between input & lookahead |
3401 | | * matching in the fast path. |
3402 | | * |
3403 | | * https://github.com/harfbuzz/harfbuzz/issues/4813 |
3404 | | */ |
3405 | 0 | if (!c->auto_zwnj || !c->auto_zwj) |
3406 | 0 | goto slow; |
3407 | | |
3408 | 0 | auto &skippy_iter = c->iter_input; |
3409 | 0 | skippy_iter.reset (c->buffer->idx); |
3410 | 0 | skippy_iter.set_match_func (match_always, nullptr); |
3411 | 0 | skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); |
3412 | 0 | unsigned unsafe_to = (unsigned) -1, unsafe_to1 = 0, unsafe_to2 = 0; |
3413 | 0 | hb_glyph_info_t *first = nullptr, *second = nullptr; |
3414 | 0 | bool matched = skippy_iter.next (); |
3415 | 0 | if (likely (matched)) |
3416 | 0 | { |
3417 | 0 | first = &c->buffer->info[skippy_iter.idx]; |
3418 | 0 | unsafe_to1 = skippy_iter.idx + 1; |
3419 | |
|
3420 | 0 | if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx])) |
3421 | 0 | { |
3422 | | /* Can't use the fast path if eg. the next char is a default-ignorable |
3423 | | * or other skippable. */ |
3424 | 0 | goto slow; |
3425 | 0 | } |
3426 | 0 | } |
3427 | 0 | else |
3428 | 0 | { |
3429 | | /* Failed to match a next glyph. Only try applying rules that have |
3430 | | * no further input and lookahead. */ |
3431 | 0 | return_trace ( |
3432 | 0 | + hb_iter (rule) |
3433 | 0 | | hb_map (hb_add (this)) |
3434 | 0 | | hb_filter ([&] (const ChainRule &_) |
3435 | 0 | { |
3436 | 0 | const auto &input = StructAfter<decltype (_.inputX)> (_.backtrack); |
3437 | 0 | const auto &lookahead = StructAfter<decltype (_.lookaheadX)> (input); |
3438 | 0 | return input.lenP1 <= 1 && lookahead.len == 0; |
3439 | 0 | }) |
3440 | 0 | | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) |
3441 | 0 | | hb_any |
3442 | 0 | ) |
3443 | 0 | ; |
3444 | 0 | } |
3445 | 0 | matched = skippy_iter.next (); |
3446 | 0 | if (likely (matched && !skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))) |
3447 | 0 | { |
3448 | 0 | second = &c->buffer->info[skippy_iter.idx]; |
3449 | 0 | unsafe_to2 = skippy_iter.idx + 1; |
3450 | 0 | } |
3451 | |
|
3452 | 0 | auto match_input = lookup_context.funcs.match[1]; |
3453 | 0 | auto match_lookahead = lookup_context.funcs.match[2]; |
3454 | 0 | auto *input_data = lookup_context.match_data[1]; |
3455 | 0 | auto *lookahead_data = lookup_context.match_data[2]; |
3456 | 0 | for (unsigned int i = 0; i < num_rules; i++) |
3457 | 0 | { |
3458 | 0 | const auto &r = this+rule.arrayZ[i]; |
3459 | |
|
3460 | 0 | const auto &input = StructAfter<decltype (r.inputX)> (r.backtrack); |
3461 | 0 | const auto &lookahead = StructAfter<decltype (r.lookaheadX)> (input); |
3462 | |
|
3463 | 0 | unsigned lenP1 = hb_max ((unsigned) input.lenP1, 1u); |
3464 | 0 | if (lenP1 > 1 ? |
3465 | 0 | (!match_input || |
3466 | 0 | match_input (*first, input.arrayZ[0], input_data)) |
3467 | 0 | : |
3468 | 0 | (!lookahead.len || !match_lookahead || |
3469 | 0 | match_lookahead (*first, lookahead.arrayZ[0], lookahead_data))) |
3470 | 0 | { |
3471 | 0 | if (!second || |
3472 | 0 | (lenP1 > 2 ? |
3473 | 0 | (!match_input || |
3474 | 0 | match_input (*second, input.arrayZ[1], input_data)) |
3475 | 0 | : |
3476 | 0 | (lookahead.len <= 2 - lenP1 || !match_lookahead || |
3477 | 0 | match_lookahead (*second, lookahead.arrayZ[2 - lenP1], lookahead_data)))) |
3478 | 0 | { |
3479 | 0 | if (r.apply (c, lookup_context)) |
3480 | 0 | { |
3481 | 0 | if (unsafe_to != (unsigned) -1) |
3482 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); |
3483 | 0 | return_trace (true); |
3484 | 0 | } |
3485 | 0 | } |
3486 | 0 | else |
3487 | 0 | unsafe_to = unsafe_to2; |
3488 | 0 | } |
3489 | 0 | else |
3490 | 0 | { |
3491 | 0 | if (unsafe_to == (unsigned) -1) |
3492 | 0 | unsafe_to = unsafe_to1; |
3493 | 0 | } |
3494 | 0 | } |
3495 | 0 | if (likely (unsafe_to != (unsigned) -1)) |
3496 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); |
3497 | |
|
3498 | 0 | return_trace (false); |
3499 | 0 | } |
3500 | | |
3501 | | bool subset (hb_subset_context_t *c, |
3502 | | const hb_map_t *lookup_map, |
3503 | | const hb_map_t *backtrack_klass_map = nullptr, |
3504 | | const hb_map_t *input_klass_map = nullptr, |
3505 | | const hb_map_t *lookahead_klass_map = nullptr) const |
3506 | 0 | { |
3507 | 0 | TRACE_SUBSET (this); |
3508 | 0 |
|
3509 | 0 | auto snap = c->serializer->snapshot (); |
3510 | 0 | auto *out = c->serializer->start_embed (*this); |
3511 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
3512 | 0 |
|
3513 | 0 | for (const Offset16To<ChainRule>& _ : rule) |
3514 | 0 | { |
3515 | 0 | if (!_) continue; |
3516 | 0 | auto o_snap = c->serializer->snapshot (); |
3517 | 0 | auto *o = out->rule.serialize_append (c->serializer); |
3518 | 0 | if (unlikely (!o)) continue; |
3519 | 0 |
|
3520 | 0 | if (!o->serialize_subset (c, _, this, |
3521 | 0 | lookup_map, |
3522 | 0 | backtrack_klass_map, |
3523 | 0 | input_klass_map, |
3524 | 0 | lookahead_klass_map)) |
3525 | 0 | { |
3526 | 0 | out->rule.pop (); |
3527 | 0 | c->serializer->revert (o_snap); |
3528 | 0 | } |
3529 | 0 | } |
3530 | 0 |
|
3531 | 0 | bool ret = bool (out->rule); |
3532 | 0 | if (!ret) c->serializer->revert (snap); |
3533 | 0 |
|
3534 | 0 | return_trace (ret); |
3535 | 0 | } |
3536 | | |
3537 | | bool sanitize (hb_sanitize_context_t *c) const |
3538 | 226 | { |
3539 | 226 | TRACE_SANITIZE (this); |
3540 | 226 | return_trace (rule.sanitize (c, this)); |
3541 | 226 | } |
3542 | | |
3543 | | protected: |
3544 | | Array16OfOffset16To<ChainRule> |
3545 | | rule; /* Array of ChainRule tables |
3546 | | * ordered by preference */ |
3547 | | public: |
3548 | | DEFINE_SIZE_ARRAY (2, rule); |
3549 | | }; |
3550 | | |
3551 | | template <typename Types> |
3552 | | struct ChainContextFormat1_4 |
3553 | | { |
3554 | | using ChainRuleSet = OT::ChainRuleSet<Types>; |
3555 | | |
3556 | | bool intersects (const hb_set_t *glyphs) const |
3557 | 0 | { |
3558 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3559 | 0 | {intersects_glyph, intersected_glyph}, |
3560 | 0 | ContextFormat::SimpleContext, |
3561 | 0 | {nullptr, nullptr, nullptr} |
3562 | 0 | }; |
3563 | 0 |
|
3564 | 0 | return |
3565 | 0 | + hb_zip (this+coverage, ruleSet) |
3566 | 0 | | hb_filter (*glyphs, hb_first) |
3567 | 0 | | hb_map (hb_second) |
3568 | 0 | | hb_map (hb_add (this)) |
3569 | 0 | | hb_map ([&] (const ChainRuleSet &_) { return _.intersects (glyphs, lookup_context); }) |
3570 | 0 | | hb_any |
3571 | 0 | ; |
3572 | 0 | } |
3573 | | |
3574 | | bool may_have_non_1to1 () const |
3575 | 0 | { return true; } |
3576 | | |
3577 | | void closure (hb_closure_context_t *c) const |
3578 | 0 | { |
3579 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
3580 | 0 | if (unlikely (!cur_active_glyphs)) return; |
3581 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
3582 | 0 | *cur_active_glyphs); |
3583 | |
|
3584 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3585 | 0 | {intersects_glyph, intersected_glyph}, |
3586 | 0 | ContextFormat::SimpleContext, |
3587 | 0 | {nullptr, nullptr, nullptr} |
3588 | 0 | }; |
3589 | |
|
3590 | 0 | + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len)) |
3591 | 0 | | hb_filter ([&] (hb_codepoint_t _) { |
3592 | 0 | return c->previous_parent_active_glyphs ().has (_); |
3593 | 0 | }, hb_first) |
3594 | 0 | | hb_map ([&](const hb_pair_t<hb_codepoint_t, unsigned> _) { return hb_pair_t<unsigned, const ChainRuleSet&> (_.first, this+ruleSet[_.second]); }) |
3595 | 0 | | hb_apply ([&] (const hb_pair_t<unsigned, const ChainRuleSet&>& _) { _.second.closure (c, _.first, lookup_context); }) |
3596 | 0 | ; |
3597 | |
|
3598 | 0 | c->pop_cur_done_glyphs (); |
3599 | 0 | } |
3600 | | |
3601 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
3602 | 0 | { |
3603 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3604 | 0 | {intersects_glyph, nullptr}, |
3605 | 0 | ContextFormat::SimpleContext, |
3606 | 0 | {nullptr, nullptr, nullptr} |
3607 | 0 | }; |
3608 | 0 |
|
3609 | 0 | + hb_zip (this+coverage, ruleSet) |
3610 | 0 | | hb_filter (*c->glyphs, hb_first) |
3611 | 0 | | hb_map (hb_second) |
3612 | 0 | | hb_map (hb_add (this)) |
3613 | 0 | | hb_apply ([&] (const ChainRuleSet &_) { _.closure_lookups (c, lookup_context); }) |
3614 | 0 | ; |
3615 | 0 | } |
3616 | | |
3617 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
3618 | | |
3619 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
3620 | 0 | { |
3621 | 0 | (this+coverage).collect_coverage (c->input); |
3622 | |
|
3623 | 0 | struct ChainContextCollectGlyphsLookupContext lookup_context = { |
3624 | 0 | {collect_glyph}, |
3625 | 0 | {nullptr, nullptr, nullptr} |
3626 | 0 | }; |
3627 | |
|
3628 | 0 | + hb_iter (ruleSet) |
3629 | 0 | | hb_map (hb_add (this)) |
3630 | 0 | | hb_apply ([&] (const ChainRuleSet &_) { _.collect_glyphs (c, lookup_context); }) |
3631 | 0 | ; |
3632 | 0 | } |
3633 | | |
3634 | | bool would_apply (hb_would_apply_context_t *c) const |
3635 | 0 | { |
3636 | 0 | const ChainRuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyphs[0])]; |
3637 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3638 | 0 | {{match_glyph, match_glyph, match_glyph}}, |
3639 | 0 | {nullptr, nullptr, nullptr} |
3640 | 0 | }; |
3641 | 0 | return rule_set.would_apply (c, lookup_context); |
3642 | 0 | } |
3643 | | |
3644 | 0 | const Coverage &get_coverage () const { return this+coverage; } |
3645 | | |
3646 | | bool apply (hb_ot_apply_context_t *c) const |
3647 | 0 | { |
3648 | 0 | TRACE_APPLY (this); |
3649 | 0 | unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); |
3650 | 0 | if (index == NOT_COVERED) return_trace (false); |
3651 | | |
3652 | 0 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
3653 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3654 | 0 | {{match_glyph, match_glyph, match_glyph}}, |
3655 | 0 | {nullptr, nullptr, nullptr} |
3656 | 0 | }; |
3657 | 0 | return_trace (rule_set.apply (c, lookup_context)); |
3658 | 0 | } |
3659 | | |
3660 | | bool subset (hb_subset_context_t *c) const |
3661 | 0 | { |
3662 | 0 | TRACE_SUBSET (this); |
3663 | 0 | const hb_set_t &glyphset = *c->plan->glyphset_gsub (); |
3664 | 0 | const hb_map_t &glyph_map = *c->plan->glyph_map; |
3665 | 0 |
|
3666 | 0 | auto *out = c->serializer->start_embed (*this); |
3667 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
3668 | 0 | out->format = format; |
3669 | 0 |
|
3670 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
3671 | 0 | hb_sorted_vector_t<hb_codepoint_t> new_coverage; |
3672 | 0 | + hb_zip (this+coverage, ruleSet) |
3673 | 0 | | hb_filter (glyphset, hb_first) |
3674 | 0 | | hb_filter (subset_offset_array (c, out->ruleSet, this, lookup_map), hb_second) |
3675 | 0 | | hb_map (hb_first) |
3676 | 0 | | hb_map (glyph_map) |
3677 | 0 | | hb_sink (new_coverage) |
3678 | 0 | ; |
3679 | 0 |
|
3680 | 0 | out->coverage.serialize_serialize (c->serializer, new_coverage.iter ()); |
3681 | 0 | return_trace (bool (new_coverage)); |
3682 | 0 | } |
3683 | | |
3684 | | bool sanitize (hb_sanitize_context_t *c) const |
3685 | 0 | { |
3686 | 0 | TRACE_SANITIZE (this); |
3687 | 0 | return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); |
3688 | 0 | } |
3689 | | |
3690 | | protected: |
3691 | | HBUINT16 format; /* Format identifier--format = 1 */ |
3692 | | typename Types::template OffsetTo<Coverage> |
3693 | | coverage; /* Offset to Coverage table--from |
3694 | | * beginning of table */ |
3695 | | Array16Of<typename Types::template OffsetTo<ChainRuleSet>> |
3696 | | ruleSet; /* Array of ChainRuleSet tables |
3697 | | * ordered by Coverage Index */ |
3698 | | public: |
3699 | | DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ruleSet); |
3700 | | }; |
3701 | | |
3702 | | template <typename Types> |
3703 | | struct ChainContextFormat2_5 |
3704 | | { |
3705 | | using ChainRuleSet = OT::ChainRuleSet<SmallTypes>; |
3706 | | |
3707 | | bool intersects (const hb_set_t *glyphs) const |
3708 | 0 | { |
3709 | 0 | if (!(this+coverage).intersects (glyphs)) |
3710 | 0 | return false; |
3711 | 0 |
|
3712 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3713 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3714 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3715 | 0 |
|
3716 | 0 | hb_map_t caches[3] = {}; |
3717 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3718 | 0 | {intersects_class, nullptr}, |
3719 | 0 | ContextFormat::ClassBasedContext, |
3720 | 0 | {&backtrack_class_def, |
3721 | 0 | &input_class_def, |
3722 | 0 | &lookahead_class_def}, |
3723 | 0 | {&caches[0], &caches[1], &caches[2]} |
3724 | 0 | }; |
3725 | 0 |
|
3726 | 0 | hb_set_t retained_coverage_glyphs; |
3727 | 0 | (this+coverage).intersect_set (*glyphs, retained_coverage_glyphs); |
3728 | 0 |
|
3729 | 0 | hb_set_t coverage_glyph_classes; |
3730 | 0 | input_class_def.intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); |
3731 | 0 |
|
3732 | 0 | return |
3733 | 0 | + hb_iter (ruleSet) |
3734 | 0 | | hb_map (hb_add (this)) |
3735 | 0 | | hb_enumerate |
3736 | 0 | | hb_map ([&] (const hb_pair_t<unsigned, const ChainRuleSet &> p) |
3737 | 0 | { return input_class_def.intersects_class (glyphs, p.first) && |
3738 | 0 | coverage_glyph_classes.has (p.first) && |
3739 | 0 | p.second.intersects (glyphs, lookup_context); }) |
3740 | 0 | | hb_any |
3741 | 0 | ; |
3742 | 0 | } |
3743 | | |
3744 | | bool may_have_non_1to1 () const |
3745 | 0 | { return true; } |
3746 | | |
3747 | | void closure (hb_closure_context_t *c) const |
3748 | 0 | { |
3749 | 0 | if (!(this+coverage).intersects (c->glyphs)) |
3750 | 0 | return; |
3751 | | |
3752 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
3753 | 0 | if (unlikely (!cur_active_glyphs)) return; |
3754 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
3755 | 0 | *cur_active_glyphs); |
3756 | |
|
3757 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3758 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3759 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3760 | |
|
3761 | 0 | hb_map_t caches[3] = {}; |
3762 | 0 | intersected_class_cache_t intersected_cache; |
3763 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3764 | 0 | {intersects_class, intersected_class_glyphs}, |
3765 | 0 | ContextFormat::ClassBasedContext, |
3766 | 0 | {&backtrack_class_def, |
3767 | 0 | &input_class_def, |
3768 | 0 | &lookahead_class_def}, |
3769 | 0 | {&caches[0], &caches[1], &caches[2]}, |
3770 | 0 | &intersected_cache |
3771 | 0 | }; |
3772 | |
|
3773 | 0 | + hb_enumerate (ruleSet) |
3774 | 0 | | hb_filter ([&] (unsigned _) |
3775 | 0 | { return input_class_def.intersects_class (&c->parent_active_glyphs (), _); }, |
3776 | 0 | hb_first) |
3777 | 0 | | hb_apply ([&] (const hb_pair_t<unsigned, const typename Types::template OffsetTo<ChainRuleSet>&> _) |
3778 | 0 | { |
3779 | 0 | const ChainRuleSet& chainrule_set = this+_.second; |
3780 | 0 | chainrule_set.closure (c, _.first, lookup_context); |
3781 | 0 | }) |
3782 | 0 | ; |
3783 | |
|
3784 | 0 | c->pop_cur_done_glyphs (); |
3785 | 0 | } |
3786 | | |
3787 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
3788 | 0 | { |
3789 | 0 | if (!(this+coverage).intersects (c->glyphs)) |
3790 | 0 | return; |
3791 | 0 |
|
3792 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3793 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3794 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3795 | 0 |
|
3796 | 0 | hb_map_t caches[3] = {}; |
3797 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3798 | 0 | {intersects_class, nullptr}, |
3799 | 0 | ContextFormat::ClassBasedContext, |
3800 | 0 | {&backtrack_class_def, |
3801 | 0 | &input_class_def, |
3802 | 0 | &lookahead_class_def}, |
3803 | 0 | {&caches[0], &caches[1], &caches[2]} |
3804 | 0 | }; |
3805 | 0 |
|
3806 | 0 | + hb_iter (ruleSet) |
3807 | 0 | | hb_map (hb_add (this)) |
3808 | 0 | | hb_enumerate |
3809 | 0 | | hb_filter([&] (unsigned klass) |
3810 | 0 | { return input_class_def.intersects_class (c->glyphs, klass); }, hb_first) |
3811 | 0 | | hb_map (hb_second) |
3812 | 0 | | hb_apply ([&] (const ChainRuleSet &_) |
3813 | 0 | { _.closure_lookups (c, lookup_context); }) |
3814 | 0 | ; |
3815 | 0 | } |
3816 | | |
3817 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
3818 | | |
3819 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
3820 | 0 | { |
3821 | 0 | (this+coverage).collect_coverage (c->input); |
3822 | |
|
3823 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3824 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3825 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3826 | |
|
3827 | 0 | struct ChainContextCollectGlyphsLookupContext lookup_context = { |
3828 | 0 | {collect_class}, |
3829 | 0 | {&backtrack_class_def, |
3830 | 0 | &input_class_def, |
3831 | 0 | &lookahead_class_def} |
3832 | 0 | }; |
3833 | |
|
3834 | 0 | + hb_iter (ruleSet) |
3835 | 0 | | hb_map (hb_add (this)) |
3836 | 0 | | hb_apply ([&] (const ChainRuleSet &_) { _.collect_glyphs (c, lookup_context); }) |
3837 | 0 | ; |
3838 | 0 | } |
3839 | | |
3840 | | bool would_apply (hb_would_apply_context_t *c) const |
3841 | 0 | { |
3842 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3843 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3844 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3845 | |
|
3846 | 0 | unsigned int index = input_class_def.get_class (c->glyphs[0]); |
3847 | 0 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
3848 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3849 | 0 | {{match_class, match_class, match_class}}, |
3850 | 0 | {&backtrack_class_def, |
3851 | 0 | &input_class_def, |
3852 | 0 | &lookahead_class_def} |
3853 | 0 | }; |
3854 | 0 | return rule_set.would_apply (c, lookup_context); |
3855 | 0 | } |
3856 | | |
3857 | 118 | const Coverage &get_coverage () const { return this+coverage; } |
3858 | | |
3859 | | unsigned cache_cost () const |
3860 | 118 | { |
3861 | 118 | return (this+lookaheadClassDef).cost () * ruleSet.len; |
3862 | 118 | } |
3863 | | static void * cache_func (void *p, hb_ot_lookup_cache_op_t op) |
3864 | 92 | { |
3865 | 92 | switch (op) |
3866 | 92 | { |
3867 | 46 | case hb_ot_lookup_cache_op_t::CREATE: |
3868 | 46 | return (void *) true; |
3869 | 0 | case hb_ot_lookup_cache_op_t::ENTER: |
3870 | 0 | { |
3871 | 0 | hb_ot_apply_context_t *c = (hb_ot_apply_context_t *) p; |
3872 | 0 | if (!HB_BUFFER_TRY_ALLOCATE_VAR (c->buffer, syllable)) |
3873 | 0 | return (void *) false; |
3874 | 0 | auto &info = c->buffer->info; |
3875 | 0 | unsigned count = c->buffer->len; |
3876 | 0 | for (unsigned i = 0; i < count; i++) |
3877 | 0 | info[i].syllable() = 255; |
3878 | 0 | c->new_syllables = 255; |
3879 | 0 | return (void *) true; |
3880 | 0 | } |
3881 | 0 | case hb_ot_lookup_cache_op_t::LEAVE: |
3882 | 0 | { |
3883 | 0 | hb_ot_apply_context_t *c = (hb_ot_apply_context_t *) p; |
3884 | 0 | c->new_syllables = (unsigned) -1; |
3885 | 0 | HB_BUFFER_DEALLOCATE_VAR (c->buffer, syllable); |
3886 | 0 | return nullptr; |
3887 | 0 | } |
3888 | 46 | case hb_ot_lookup_cache_op_t::DESTROY: |
3889 | 46 | return nullptr; |
3890 | 92 | } |
3891 | 0 | return nullptr; |
3892 | 92 | } |
3893 | | |
3894 | 0 | bool apply_cached (hb_ot_apply_context_t *c) const { return _apply (c, true); } |
3895 | 0 | bool apply (hb_ot_apply_context_t *c) const { return _apply (c, false); } |
3896 | | bool _apply (hb_ot_apply_context_t *c, bool cached) const |
3897 | 0 | { |
3898 | 0 | TRACE_APPLY (this); |
3899 | 0 | unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); |
3900 | 0 | if (index == NOT_COVERED) return_trace (false); |
3901 | | |
3902 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3903 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3904 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3905 | | |
3906 | | /* match_class_caches1 is slightly faster. Use it for lookahead, |
3907 | | * which is typically longer. */ |
3908 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3909 | 0 | {{cached && &backtrack_class_def == &lookahead_class_def ? match_class_cached1 : match_class, |
3910 | 0 | cached ? match_class_cached2 : match_class, |
3911 | 0 | cached ? match_class_cached1 : match_class}}, |
3912 | 0 | {&backtrack_class_def, |
3913 | 0 | &input_class_def, |
3914 | 0 | &lookahead_class_def} |
3915 | 0 | }; |
3916 | | |
3917 | | // Note: Corresponds to match_class_cached2 |
3918 | 0 | if (cached && ((c->buffer->cur().syllable() & 0xF0) >> 4) < 15) |
3919 | 0 | index = (c->buffer->cur().syllable () & 0xF0) >> 4; |
3920 | 0 | else |
3921 | 0 | index = input_class_def.get_class (c->buffer->cur().codepoint); |
3922 | 0 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
3923 | 0 | return_trace (rule_set.apply (c, lookup_context)); |
3924 | 0 | } |
3925 | | |
3926 | | bool subset (hb_subset_context_t *c) const |
3927 | 0 | { |
3928 | 0 | TRACE_SUBSET (this); |
3929 | 0 | auto *out = c->serializer->start_embed (*this); |
3930 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
3931 | 0 | out->format = format; |
3932 | 0 | out->coverage.serialize_subset (c, coverage, this); |
3933 | 0 |
|
3934 | 0 | hb_map_t backtrack_klass_map; |
3935 | 0 | hb_map_t input_klass_map; |
3936 | 0 | hb_map_t lookahead_klass_map; |
3937 | 0 |
|
3938 | 0 | out->backtrackClassDef.serialize_subset (c, backtrackClassDef, this, &backtrack_klass_map); |
3939 | 0 | // TODO: subset inputClassDef based on glyphs survived in Coverage subsetting |
3940 | 0 | out->inputClassDef.serialize_subset (c, inputClassDef, this, &input_klass_map); |
3941 | 0 | out->lookaheadClassDef.serialize_subset (c, lookaheadClassDef, this, &lookahead_klass_map); |
3942 | 0 |
|
3943 | 0 | if (unlikely (!c->serializer->propagate_error (backtrack_klass_map, |
3944 | 0 | input_klass_map, |
3945 | 0 | lookahead_klass_map))) |
3946 | 0 | return_trace (false); |
3947 | 0 |
|
3948 | 0 | const hb_set_t* glyphset = c->plan->glyphset_gsub (); |
3949 | 0 | hb_set_t retained_coverage_glyphs; |
3950 | 0 | (this+coverage).intersect_set (*glyphset, retained_coverage_glyphs); |
3951 | 0 |
|
3952 | 0 | hb_set_t coverage_glyph_classes; |
3953 | 0 | (this+inputClassDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); |
3954 | 0 |
|
3955 | 0 | int non_zero_index = -1, index = 0; |
3956 | 0 | bool ret = true; |
3957 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
3958 | 0 | auto last_non_zero = c->serializer->snapshot (); |
3959 | 0 | for (const auto& _ : + hb_enumerate (ruleSet) |
3960 | 0 | | hb_filter (input_klass_map, hb_first)) |
3961 | 0 | { |
3962 | 0 | auto *o = out->ruleSet.serialize_append (c->serializer); |
3963 | 0 | if (unlikely (!o)) |
3964 | 0 | { |
3965 | 0 | ret = false; |
3966 | 0 | break; |
3967 | 0 | } |
3968 | 0 | if (coverage_glyph_classes.has (_.first) && |
3969 | 0 | o->serialize_subset (c, _.second, this, |
3970 | 0 | lookup_map, |
3971 | 0 | &backtrack_klass_map, |
3972 | 0 | &input_klass_map, |
3973 | 0 | &lookahead_klass_map)) |
3974 | 0 | { |
3975 | 0 | last_non_zero = c->serializer->snapshot (); |
3976 | 0 | non_zero_index = index; |
3977 | 0 | } |
3978 | 0 |
|
3979 | 0 | index++; |
3980 | 0 | } |
3981 | 0 |
|
3982 | 0 | if (!ret || non_zero_index == -1) return_trace (false); |
3983 | 0 |
|
3984 | 0 | // prune empty trailing ruleSets |
3985 | 0 | if (index > non_zero_index) { |
3986 | 0 | c->serializer->revert (last_non_zero); |
3987 | 0 | out->ruleSet.len = non_zero_index + 1; |
3988 | 0 | } |
3989 | 0 |
|
3990 | 0 | return_trace (bool (out->ruleSet)); |
3991 | 0 | } |
3992 | | |
3993 | | bool sanitize (hb_sanitize_context_t *c) const |
3994 | 141 | { |
3995 | 141 | TRACE_SANITIZE (this); |
3996 | 141 | return_trace (coverage.sanitize (c, this) && |
3997 | 141 | backtrackClassDef.sanitize (c, this) && |
3998 | 141 | inputClassDef.sanitize (c, this) && |
3999 | 141 | lookaheadClassDef.sanitize (c, this) && |
4000 | 141 | ruleSet.sanitize (c, this)); |
4001 | 141 | } |
4002 | | |
4003 | | protected: |
4004 | | HBUINT16 format; /* Format identifier--format = 2 */ |
4005 | | typename Types::template OffsetTo<Coverage> |
4006 | | coverage; /* Offset to Coverage table--from |
4007 | | * beginning of table */ |
4008 | | typename Types::template OffsetTo<ClassDef> |
4009 | | backtrackClassDef; /* Offset to glyph ClassDef table |
4010 | | * containing backtrack sequence |
4011 | | * data--from beginning of table */ |
4012 | | typename Types::template OffsetTo<ClassDef> |
4013 | | inputClassDef; /* Offset to glyph ClassDef |
4014 | | * table containing input sequence |
4015 | | * data--from beginning of table */ |
4016 | | typename Types::template OffsetTo<ClassDef> |
4017 | | lookaheadClassDef; /* Offset to glyph ClassDef table |
4018 | | * containing lookahead sequence |
4019 | | * data--from beginning of table */ |
4020 | | Array16Of<typename Types::template OffsetTo<ChainRuleSet>> |
4021 | | ruleSet; /* Array of ChainRuleSet tables |
4022 | | * ordered by class */ |
4023 | | public: |
4024 | | DEFINE_SIZE_ARRAY (4 + 4 * Types::size, ruleSet); |
4025 | | }; |
4026 | | |
4027 | | struct ChainContextFormat3 |
4028 | | { |
4029 | | using RuleSet = OT::RuleSet<SmallTypes>; |
4030 | | |
4031 | | bool intersects (const hb_set_t *glyphs) const |
4032 | 0 | { |
4033 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4034 | 0 |
|
4035 | 0 | if (!(this+input[0]).intersects (glyphs)) |
4036 | 0 | return false; |
4037 | 0 |
|
4038 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4039 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
4040 | 0 | {intersects_coverage, nullptr}, |
4041 | 0 | ContextFormat::CoverageBasedContext, |
4042 | 0 | {this, this, this} |
4043 | 0 | }; |
4044 | 0 | return chain_context_intersects (glyphs, |
4045 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4046 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4047 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4048 | 0 | lookup_context); |
4049 | 0 | } |
4050 | | |
4051 | | bool may_have_non_1to1 () const |
4052 | 0 | { return true; } |
4053 | | |
4054 | | void closure (hb_closure_context_t *c) const |
4055 | 0 | { |
4056 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4057 | |
|
4058 | 0 | if (!(this+input[0]).intersects (c->glyphs)) |
4059 | 0 | return; |
4060 | | |
4061 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
4062 | 0 | if (unlikely (!cur_active_glyphs)) |
4063 | 0 | return; |
4064 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
4065 | 0 | *cur_active_glyphs); |
4066 | |
|
4067 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4068 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4069 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
4070 | 0 | {intersects_coverage, intersected_coverage_glyphs}, |
4071 | 0 | ContextFormat::CoverageBasedContext, |
4072 | 0 | {this, this, this} |
4073 | 0 | }; |
4074 | 0 | chain_context_closure_lookup (c, |
4075 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4076 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4077 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4078 | 0 | lookup.len, lookup.arrayZ, |
4079 | 0 | 0, lookup_context); |
4080 | |
|
4081 | 0 | c->pop_cur_done_glyphs (); |
4082 | 0 | } |
4083 | | |
4084 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
4085 | 0 | { |
4086 | 0 | if (!intersects (c->glyphs)) |
4087 | 0 | return; |
4088 | 0 |
|
4089 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4090 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4091 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4092 | 0 | recurse_lookups (c, lookup.len, lookup.arrayZ); |
4093 | 0 | } |
4094 | | |
4095 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
4096 | | |
4097 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
4098 | 0 | { |
4099 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4100 | |
|
4101 | 0 | (this+input[0]).collect_coverage (c->input); |
4102 | |
|
4103 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4104 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4105 | |
|
4106 | 0 | struct ChainContextCollectGlyphsLookupContext lookup_context = { |
4107 | 0 | {collect_coverage}, |
4108 | 0 | {this, this, this} |
4109 | 0 | }; |
4110 | 0 | chain_context_collect_glyphs_lookup (c, |
4111 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4112 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4113 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4114 | 0 | lookup.len, lookup.arrayZ, |
4115 | 0 | lookup_context); |
4116 | 0 | } |
4117 | | |
4118 | | bool would_apply (hb_would_apply_context_t *c) const |
4119 | 0 | { |
4120 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4121 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4122 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4123 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
4124 | 0 | {{match_coverage, match_coverage, match_coverage}}, |
4125 | 0 | {this, this, this} |
4126 | 0 | }; |
4127 | 0 | return chain_context_would_apply_lookup (c, |
4128 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4129 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4130 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4131 | 0 | lookup.len, lookup.arrayZ, lookup_context); |
4132 | 0 | } |
4133 | | |
4134 | | const Coverage &get_coverage () const |
4135 | 0 | { |
4136 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4137 | 0 | return this+input[0]; |
4138 | 0 | } |
4139 | | |
4140 | | bool apply (hb_ot_apply_context_t *c) const |
4141 | 0 | { |
4142 | 0 | TRACE_APPLY (this); |
4143 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4144 | |
|
4145 | 0 | unsigned int index = (this+input[0]).get_coverage (c->buffer->cur().codepoint); |
4146 | 0 | if (index == NOT_COVERED) return_trace (false); |
4147 | | |
4148 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4149 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4150 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
4151 | 0 | {{match_coverage, match_coverage, match_coverage}}, |
4152 | 0 | {this, this, this} |
4153 | 0 | }; |
4154 | 0 | return_trace (chain_context_apply_lookup (c, |
4155 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4156 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4157 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4158 | 0 | lookup.len, lookup.arrayZ, lookup_context)); |
4159 | 0 | } |
4160 | | |
4161 | | template<typename Iterator, |
4162 | | hb_requires (hb_is_iterator (Iterator))> |
4163 | | bool serialize_coverage_offsets (hb_subset_context_t *c, Iterator it, const void* base) const |
4164 | 0 | { |
4165 | 0 | TRACE_SERIALIZE (this); |
4166 | 0 | auto *out = c->serializer->start_embed<Array16OfOffset16To<Coverage>> (); |
4167 | 0 |
|
4168 | 0 | if (unlikely (!c->serializer->allocate_size<HBUINT16> (HBUINT16::static_size))) |
4169 | 0 | return_trace (false); |
4170 | 0 |
|
4171 | 0 | for (auto& offset : it) { |
4172 | 0 | auto *o = out->serialize_append (c->serializer); |
4173 | 0 | if (unlikely (!o) || !o->serialize_subset (c, offset, base)) |
4174 | 0 | return_trace (false); |
4175 | 0 | } |
4176 | 0 |
|
4177 | 0 | return_trace (true); |
4178 | 0 | } |
4179 | | |
4180 | | bool subset (hb_subset_context_t *c) const |
4181 | 0 | { |
4182 | 0 | TRACE_SUBSET (this); |
4183 | 0 |
|
4184 | 0 | if (unlikely (!c->serializer->embed (this->format))) return_trace (false); |
4185 | 0 |
|
4186 | 0 | if (!serialize_coverage_offsets (c, backtrack.iter (), this)) |
4187 | 0 | return_trace (false); |
4188 | 0 |
|
4189 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4190 | 0 | if (!serialize_coverage_offsets (c, input.iter (), this)) |
4191 | 0 | return_trace (false); |
4192 | 0 |
|
4193 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4194 | 0 | if (!serialize_coverage_offsets (c, lookahead.iter (), this)) |
4195 | 0 | return_trace (false); |
4196 | 0 |
|
4197 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4198 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
4199 | 0 |
|
4200 | 0 | HBUINT16 *lookupCount = c->serializer->copy<HBUINT16> (lookup.len); |
4201 | 0 | if (!lookupCount) return_trace (false); |
4202 | 0 |
|
4203 | 0 | unsigned count = serialize_lookuprecord_array (c->serializer, lookup.as_array (), lookup_map); |
4204 | 0 | return_trace (c->serializer->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
4205 | 0 | } |
4206 | | |
4207 | | bool sanitize (hb_sanitize_context_t *c) const |
4208 | 0 | { |
4209 | 0 | TRACE_SANITIZE (this); |
4210 | 0 | if (unlikely (!backtrack.sanitize (c, this))) return_trace (false); |
4211 | 0 | hb_barrier (); |
4212 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4213 | 0 | if (unlikely (!input.sanitize (c, this))) return_trace (false); |
4214 | 0 | hb_barrier (); |
4215 | 0 | if (unlikely (!input.len)) return_trace (false); /* To be consistent with Context. */ |
4216 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4217 | 0 | if (unlikely (!lookahead.sanitize (c, this))) return_trace (false); |
4218 | 0 | hb_barrier (); |
4219 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4220 | 0 | return_trace (likely (lookup.sanitize (c))); |
4221 | 0 | } |
4222 | | |
4223 | | protected: |
4224 | | HBUINT16 format; /* Format identifier--format = 3 */ |
4225 | | Array16OfOffset16To<Coverage> |
4226 | | backtrack; /* Array of coverage tables |
4227 | | * in backtracking sequence, in glyph |
4228 | | * sequence order */ |
4229 | | Array16OfOffset16To<Coverage> |
4230 | | inputX ; /* Array of coverage |
4231 | | * tables in input sequence, in glyph |
4232 | | * sequence order */ |
4233 | | Array16OfOffset16To<Coverage> |
4234 | | lookaheadX; /* Array of coverage tables |
4235 | | * in lookahead sequence, in glyph |
4236 | | * sequence order */ |
4237 | | Array16Of<LookupRecord> |
4238 | | lookupX; /* Array of LookupRecords--in |
4239 | | * design order) */ |
4240 | | public: |
4241 | | DEFINE_SIZE_MIN (10); |
4242 | | }; |
4243 | | |
4244 | | struct ChainContext |
4245 | | { |
4246 | | template <typename context_t, typename ...Ts> |
4247 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
4248 | 259 | { |
4249 | 259 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); |
4250 | 259 | TRACE_DISPATCH (this, u.format); |
4251 | 259 | switch (u.format) { |
4252 | 0 | case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); |
4253 | 259 | case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); |
4254 | 0 | case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...)); |
4255 | | #ifndef HB_NO_BEYOND_64K |
4256 | | case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...)); |
4257 | | case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...)); |
4258 | | #endif |
4259 | 0 | default:return_trace (c->default_return_value ()); |
4260 | 259 | } |
4261 | 259 | } Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::ChainContext::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::ChainContext::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::ChainContext::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::ChainContext::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const Unexecuted instantiation: hb_subset_context_t::return_t OT::ChainContext::dispatch<hb_subset_context_t>(hb_subset_context_t*) const hb_sanitize_context_t::return_t OT::ChainContext::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const Line | Count | Source | 4248 | 141 | { | 4249 | 141 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); | 4250 | 141 | TRACE_DISPATCH (this, u.format); | 4251 | 141 | switch (u.format) { | 4252 | 0 | case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); | 4253 | 141 | case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); | 4254 | 0 | case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...)); | 4255 | | #ifndef HB_NO_BEYOND_64K | 4256 | | case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...)); | 4257 | | case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...)); | 4258 | | #endif | 4259 | 0 | default:return_trace (c->default_return_value ()); | 4260 | 141 | } | 4261 | 141 | } |
Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::ChainContext::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const OT::hb_accelerate_subtables_context_t::return_t OT::ChainContext::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const Line | Count | Source | 4248 | 118 | { | 4249 | 118 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); | 4250 | 118 | TRACE_DISPATCH (this, u.format); | 4251 | 118 | switch (u.format) { | 4252 | 0 | case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); | 4253 | 118 | case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); | 4254 | 0 | case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...)); | 4255 | | #ifndef HB_NO_BEYOND_64K | 4256 | | case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...)); | 4257 | | case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...)); | 4258 | | #endif | 4259 | 0 | default:return_trace (c->default_return_value ()); | 4260 | 118 | } | 4261 | 118 | } |
Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::ChainContext::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::ChainContext::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::ChainContext::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::ChainContext::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::ChainContext::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const |
4262 | | |
4263 | | protected: |
4264 | | union { |
4265 | | HBUINT16 format; /* Format identifier */ |
4266 | | ChainContextFormat1_4<SmallTypes> format1; |
4267 | | ChainContextFormat2_5<SmallTypes> format2; |
4268 | | ChainContextFormat3 format3; |
4269 | | #ifndef HB_NO_BEYOND_64K |
4270 | | ChainContextFormat1_4<MediumTypes> format4; |
4271 | | ChainContextFormat2_5<MediumTypes> format5; |
4272 | | #endif |
4273 | | } u; |
4274 | | }; |
4275 | | |
4276 | | |
4277 | | template <typename T> |
4278 | | struct ExtensionFormat1 |
4279 | | { |
4280 | 0 | unsigned int get_type () const { return extensionLookupType; } Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::get_type() const Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::get_type() const |
4281 | | |
4282 | | template <typename X> |
4283 | | const X& get_subtable () const |
4284 | 0 | { return this + reinterpret_cast<const Offset32To<typename T::SubTable> &> (extensionOffset); } Unexecuted instantiation: OT::Layout::GPOS_impl::PosLookupSubTable const& OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::get_subtable<OT::Layout::GPOS_impl::PosLookupSubTable>() const Unexecuted instantiation: OT::Layout::GSUB_impl::SubstLookupSubTable const& OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::get_subtable<OT::Layout::GSUB_impl::SubstLookupSubTable>() const |
4285 | | |
4286 | | template <typename context_t, typename ...Ts> |
4287 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
4288 | 0 | { |
4289 | 0 | if (unlikely (!c->may_dispatch (this, this))) return c->no_dispatch_return_value (); |
4290 | 0 | TRACE_DISPATCH (this, format); |
4291 | 0 | return_trace (get_subtable<typename T::SubTable> ().dispatch (c, get_type (), std::forward<Ts> (ds)...)); |
4292 | 0 | } Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const Unexecuted instantiation: hb_sanitize_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const Unexecuted instantiation: hb_sanitize_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const |
4293 | | |
4294 | | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const |
4295 | | { dispatch (c); } |
4296 | | |
4297 | | /* This is called from may_dispatch() above with hb_sanitize_context_t. */ |
4298 | | bool sanitize (hb_sanitize_context_t *c) const |
4299 | 0 | { |
4300 | 0 | TRACE_SANITIZE (this); |
4301 | 0 | return_trace (c->check_struct (this) && |
4302 | 0 | hb_barrier () && |
4303 | 0 | extensionLookupType != T::SubTable::Extension); |
4304 | 0 | } Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::sanitize(hb_sanitize_context_t*) const |
4305 | | |
4306 | | bool subset (hb_subset_context_t *c) const |
4307 | 0 | { |
4308 | 0 | TRACE_SUBSET (this); |
4309 | 0 |
|
4310 | 0 | auto *out = c->serializer->start_embed (this); |
4311 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
4312 | 0 |
|
4313 | 0 | out->format = format; |
4314 | 0 | out->extensionLookupType = extensionLookupType; |
4315 | 0 |
|
4316 | 0 | const auto& src_offset = |
4317 | 0 | reinterpret_cast<const Offset32To<typename T::SubTable> &> (extensionOffset); |
4318 | 0 | auto& dest_offset = |
4319 | 0 | reinterpret_cast<Offset32To<typename T::SubTable> &> (out->extensionOffset); |
4320 | 0 |
|
4321 | 0 | return_trace (dest_offset.serialize_subset (c, src_offset, this, get_type ())); |
4322 | 0 | } Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::subset(hb_subset_context_t*) const Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::subset(hb_subset_context_t*) const |
4323 | | |
4324 | | protected: |
4325 | | HBUINT16 format; /* Format identifier. Set to 1. */ |
4326 | | HBUINT16 extensionLookupType; /* Lookup type of subtable referenced |
4327 | | * by ExtensionOffset (i.e. the |
4328 | | * extension subtable). */ |
4329 | | Offset32 extensionOffset; /* Offset to the extension subtable, |
4330 | | * of lookup type subtable. */ |
4331 | | public: |
4332 | | DEFINE_SIZE_STATIC (8); |
4333 | | }; |
4334 | | |
4335 | | template <typename T> |
4336 | | struct Extension |
4337 | | { |
4338 | | unsigned int get_type () const |
4339 | 0 | { |
4340 | 0 | switch (u.format) { |
4341 | 0 | case 1: hb_barrier (); return u.format1.get_type (); |
4342 | 0 | default:return 0; |
4343 | 0 | } |
4344 | 0 | } Unexecuted instantiation: OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::get_type() const Unexecuted instantiation: OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::get_type() const |
4345 | | template <typename X> |
4346 | | const X& get_subtable () const |
4347 | | { |
4348 | | switch (u.format) { |
4349 | | case 1: hb_barrier (); return u.format1.template get_subtable<typename T::SubTable> (); |
4350 | | default:return Null (typename T::SubTable); |
4351 | | } |
4352 | | } |
4353 | | |
4354 | | // Specialization of dispatch for subset. dispatch() normally just |
4355 | | // dispatches to the sub table this points too, but for subset |
4356 | | // we need to run subset on this subtable too. |
4357 | | template <typename ...Ts> |
4358 | | typename hb_subset_context_t::return_t dispatch (hb_subset_context_t *c, Ts&&... ds) const |
4359 | 0 | { |
4360 | 0 | switch (u.format) { |
4361 | 0 | case 1: hb_barrier (); return u.format1.subset (c); |
4362 | 0 | default: return c->default_return_value (); |
4363 | 0 | } |
4364 | 0 | } Unexecuted instantiation: bool OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<>(hb_subset_context_t*) const Unexecuted instantiation: bool OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<>(hb_subset_context_t*) const |
4365 | | |
4366 | | template <typename context_t, typename ...Ts> |
4367 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
4368 | 0 | { |
4369 | 0 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); |
4370 | 0 | TRACE_DISPATCH (this, u.format); |
4371 | 0 | switch (u.format) { |
4372 | 0 | case 1: hb_barrier (); return_trace (u.format1.dispatch (c, std::forward<Ts> (ds)...)); |
4373 | 0 | default:return_trace (c->default_return_value ()); |
4374 | 0 | } |
4375 | 0 | } Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const Unexecuted instantiation: hb_sanitize_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const Unexecuted instantiation: hb_sanitize_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const |
4376 | | |
4377 | | protected: |
4378 | | union { |
4379 | | HBUINT16 format; /* Format identifier */ |
4380 | | ExtensionFormat1<T> format1; |
4381 | | } u; |
4382 | | }; |
4383 | | |
4384 | | |
4385 | | /* |
4386 | | * GSUB/GPOS Common |
4387 | | */ |
4388 | | |
4389 | | struct hb_ot_layout_lookup_accelerator_t |
4390 | | { |
4391 | | template <typename TLookup> |
4392 | | static hb_ot_layout_lookup_accelerator_t *create (const TLookup &lookup) |
4393 | 220 | { |
4394 | 220 | unsigned count = lookup.get_subtable_count (); |
4395 | | |
4396 | 220 | unsigned size = sizeof (hb_ot_layout_lookup_accelerator_t) - |
4397 | 220 | HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) + |
4398 | 220 | count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t); |
4399 | | |
4400 | | /* The following is a calloc because when we are collecting subtables, |
4401 | | * some of them might be invalid and hence not collect; as a result, |
4402 | | * we might not fill in all the count entries of the subtables array. |
4403 | | * Zeroing it allows the set digest to gatekeep it without having to |
4404 | | * initialize it further. */ |
4405 | 220 | auto *thiz = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (1, size); |
4406 | 220 | if (unlikely (!thiz)) |
4407 | 0 | return nullptr; |
4408 | | |
4409 | 220 | hb_accelerate_subtables_context_t c_accelerate_subtables (thiz->subtables); |
4410 | 220 | lookup.dispatch (&c_accelerate_subtables); |
4411 | | |
4412 | 220 | thiz->digest.init (); |
4413 | 220 | for (auto& subtable : hb_iter (thiz->subtables, count)) |
4414 | 400 | thiz->digest.union_ (subtable.digest); |
4415 | | |
4416 | 220 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4417 | 220 | if (c_accelerate_subtables.cache_user_cost < 4) |
4418 | 174 | c_accelerate_subtables.cache_user_idx = (unsigned) -1; |
4419 | | |
4420 | 220 | thiz->cache_user_idx = c_accelerate_subtables.cache_user_idx; |
4421 | | |
4422 | 220 | if (thiz->cache_user_idx != (unsigned) -1) |
4423 | 46 | { |
4424 | 46 | thiz->cache = thiz->subtables[thiz->cache_user_idx].cache_func (nullptr, hb_ot_lookup_cache_op_t::CREATE); |
4425 | 46 | if (!thiz->cache) |
4426 | 0 | thiz->cache_user_idx = (unsigned) -1; |
4427 | 46 | } |
4428 | | |
4429 | 620 | for (unsigned i = 0; i < count; i++) |
4430 | 400 | if (i != thiz->cache_user_idx) |
4431 | 354 | thiz->subtables[i].apply_cached_func = thiz->subtables[i].apply_func; |
4432 | 220 | #endif |
4433 | | |
4434 | 220 | return thiz; |
4435 | 220 | } OT::hb_ot_layout_lookup_accelerator_t* OT::hb_ot_layout_lookup_accelerator_t::create<OT::Layout::GPOS_impl::PosLookup>(OT::Layout::GPOS_impl::PosLookup const&) Line | Count | Source | 4393 | 120 | { | 4394 | 120 | unsigned count = lookup.get_subtable_count (); | 4395 | | | 4396 | 120 | unsigned size = sizeof (hb_ot_layout_lookup_accelerator_t) - | 4397 | 120 | HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) + | 4398 | 120 | count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t); | 4399 | | | 4400 | | /* The following is a calloc because when we are collecting subtables, | 4401 | | * some of them might be invalid and hence not collect; as a result, | 4402 | | * we might not fill in all the count entries of the subtables array. | 4403 | | * Zeroing it allows the set digest to gatekeep it without having to | 4404 | | * initialize it further. */ | 4405 | 120 | auto *thiz = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (1, size); | 4406 | 120 | if (unlikely (!thiz)) | 4407 | 0 | return nullptr; | 4408 | | | 4409 | 120 | hb_accelerate_subtables_context_t c_accelerate_subtables (thiz->subtables); | 4410 | 120 | lookup.dispatch (&c_accelerate_subtables); | 4411 | | | 4412 | 120 | thiz->digest.init (); | 4413 | 120 | for (auto& subtable : hb_iter (thiz->subtables, count)) | 4414 | 228 | thiz->digest.union_ (subtable.digest); | 4415 | | | 4416 | 120 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 4417 | 120 | if (c_accelerate_subtables.cache_user_cost < 4) | 4418 | 120 | c_accelerate_subtables.cache_user_idx = (unsigned) -1; | 4419 | | | 4420 | 120 | thiz->cache_user_idx = c_accelerate_subtables.cache_user_idx; | 4421 | | | 4422 | 120 | if (thiz->cache_user_idx != (unsigned) -1) | 4423 | 0 | { | 4424 | 0 | thiz->cache = thiz->subtables[thiz->cache_user_idx].cache_func (nullptr, hb_ot_lookup_cache_op_t::CREATE); | 4425 | 0 | if (!thiz->cache) | 4426 | 0 | thiz->cache_user_idx = (unsigned) -1; | 4427 | 0 | } | 4428 | | | 4429 | 348 | for (unsigned i = 0; i < count; i++) | 4430 | 228 | if (i != thiz->cache_user_idx) | 4431 | 228 | thiz->subtables[i].apply_cached_func = thiz->subtables[i].apply_func; | 4432 | 120 | #endif | 4433 | | | 4434 | 120 | return thiz; | 4435 | 120 | } |
OT::hb_ot_layout_lookup_accelerator_t* OT::hb_ot_layout_lookup_accelerator_t::create<OT::Layout::GSUB_impl::SubstLookup>(OT::Layout::GSUB_impl::SubstLookup const&) Line | Count | Source | 4393 | 100 | { | 4394 | 100 | unsigned count = lookup.get_subtable_count (); | 4395 | | | 4396 | 100 | unsigned size = sizeof (hb_ot_layout_lookup_accelerator_t) - | 4397 | 100 | HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) + | 4398 | 100 | count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t); | 4399 | | | 4400 | | /* The following is a calloc because when we are collecting subtables, | 4401 | | * some of them might be invalid and hence not collect; as a result, | 4402 | | * we might not fill in all the count entries of the subtables array. | 4403 | | * Zeroing it allows the set digest to gatekeep it without having to | 4404 | | * initialize it further. */ | 4405 | 100 | auto *thiz = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (1, size); | 4406 | 100 | if (unlikely (!thiz)) | 4407 | 0 | return nullptr; | 4408 | | | 4409 | 100 | hb_accelerate_subtables_context_t c_accelerate_subtables (thiz->subtables); | 4410 | 100 | lookup.dispatch (&c_accelerate_subtables); | 4411 | | | 4412 | 100 | thiz->digest.init (); | 4413 | 100 | for (auto& subtable : hb_iter (thiz->subtables, count)) | 4414 | 172 | thiz->digest.union_ (subtable.digest); | 4415 | | | 4416 | 100 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE | 4417 | 100 | if (c_accelerate_subtables.cache_user_cost < 4) | 4418 | 54 | c_accelerate_subtables.cache_user_idx = (unsigned) -1; | 4419 | | | 4420 | 100 | thiz->cache_user_idx = c_accelerate_subtables.cache_user_idx; | 4421 | | | 4422 | 100 | if (thiz->cache_user_idx != (unsigned) -1) | 4423 | 46 | { | 4424 | 46 | thiz->cache = thiz->subtables[thiz->cache_user_idx].cache_func (nullptr, hb_ot_lookup_cache_op_t::CREATE); | 4425 | 46 | if (!thiz->cache) | 4426 | 0 | thiz->cache_user_idx = (unsigned) -1; | 4427 | 46 | } | 4428 | | | 4429 | 272 | for (unsigned i = 0; i < count; i++) | 4430 | 172 | if (i != thiz->cache_user_idx) | 4431 | 126 | thiz->subtables[i].apply_cached_func = thiz->subtables[i].apply_func; | 4432 | 100 | #endif | 4433 | | | 4434 | 100 | return thiz; | 4435 | 100 | } |
|
4436 | | |
4437 | | void fini () |
4438 | 220 | { |
4439 | 220 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4440 | 220 | if (cache) |
4441 | 46 | { |
4442 | 46 | assert (cache_user_idx != (unsigned) -1); |
4443 | 46 | subtables[cache_user_idx].cache_func (cache, hb_ot_lookup_cache_op_t::DESTROY); |
4444 | 46 | } |
4445 | 220 | #endif |
4446 | 220 | } |
4447 | | |
4448 | | bool may_have (hb_codepoint_t g) const |
4449 | 0 | { return digest.may_have (g); } |
4450 | | |
4451 | | #ifndef HB_OPTIMIZE_SIZE |
4452 | | HB_ALWAYS_INLINE |
4453 | | #endif |
4454 | | bool apply (hb_ot_apply_context_t *c, unsigned subtables_count, bool use_cache) const |
4455 | 57 | { |
4456 | 57 | c->lookup_accel = this; |
4457 | 57 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4458 | 57 | if (use_cache) |
4459 | 0 | { |
4460 | 0 | return |
4461 | 0 | + hb_iter (hb_iter (subtables, subtables_count)) |
4462 | 0 | | hb_map ([&c] (const hb_accelerate_subtables_context_t::hb_applicable_t &_) { return _.apply_cached (c); }) |
4463 | 0 | | hb_any |
4464 | 0 | ; |
4465 | 0 | } |
4466 | 57 | else |
4467 | 57 | #endif |
4468 | 57 | { |
4469 | 57 | return |
4470 | 57 | + hb_iter (hb_iter (subtables, subtables_count)) |
4471 | 342 | | hb_map ([&c] (const hb_accelerate_subtables_context_t::hb_applicable_t &_) { return _.apply (c); }) |
4472 | 57 | | hb_any |
4473 | 57 | ; |
4474 | 57 | } |
4475 | 0 | return false; |
4476 | 57 | } |
4477 | | |
4478 | | bool cache_enter (hb_ot_apply_context_t *c) const |
4479 | 315 | { |
4480 | 315 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4481 | 315 | return cache_user_idx != (unsigned) -1 && |
4482 | 315 | subtables[cache_user_idx].cache_enter (c); |
4483 | | #else |
4484 | | return false; |
4485 | | #endif |
4486 | 315 | } |
4487 | | void cache_leave (hb_ot_apply_context_t *c) const |
4488 | 0 | { |
4489 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4490 | 0 | subtables[cache_user_idx].cache_leave (c); |
4491 | 0 | #endif |
4492 | 0 | } |
4493 | | |
4494 | | |
4495 | | hb_set_digest_t digest; |
4496 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4497 | | public: |
4498 | | void *cache = nullptr; |
4499 | | private: |
4500 | | unsigned cache_user_idx = (unsigned) -1; |
4501 | | #endif |
4502 | | private: |
4503 | | hb_accelerate_subtables_context_t::hb_applicable_t subtables[HB_VAR_ARRAY]; |
4504 | | }; |
4505 | | |
4506 | | template <typename Types> |
4507 | | struct GSUBGPOSVersion1_2 |
4508 | | { |
4509 | | friend struct GSUBGPOS; |
4510 | | |
4511 | | protected: |
4512 | | FixedVersion<>version; /* Version of the GSUB/GPOS table--initially set |
4513 | | * to 0x00010000u */ |
4514 | | typename Types:: template OffsetTo<ScriptList> |
4515 | | scriptList; /* ScriptList table */ |
4516 | | typename Types::template OffsetTo<FeatureList> |
4517 | | featureList; /* FeatureList table */ |
4518 | | typename Types::template OffsetTo<LookupList<Types>> |
4519 | | lookupList; /* LookupList table */ |
4520 | | Offset32To<FeatureVariations> |
4521 | | featureVars; /* Offset to Feature Variations |
4522 | | table--from beginning of table |
4523 | | * (may be NULL). Introduced |
4524 | | * in version 0x00010001. */ |
4525 | | public: |
4526 | | DEFINE_SIZE_MIN (4 + 3 * Types::size); |
4527 | | |
4528 | | unsigned int get_size () const |
4529 | 0 | { |
4530 | 0 | return min_size + |
4531 | 0 | (version.to_int () >= 0x00010001u ? featureVars.static_size : 0); |
4532 | 0 | } |
4533 | | |
4534 | | const typename Types::template OffsetTo<LookupList<Types>>* get_lookup_list_offset () const |
4535 | | { |
4536 | | return &lookupList; |
4537 | | } |
4538 | | |
4539 | | template <typename TLookup> |
4540 | | bool sanitize (hb_sanitize_context_t *c) const |
4541 | 4.60k | { |
4542 | 4.60k | TRACE_SANITIZE (this); |
4543 | 4.60k | typedef List16OfOffsetTo<TLookup, typename Types::HBUINT> TLookupList; |
4544 | 4.60k | if (unlikely (!(scriptList.sanitize (c, this) && |
4545 | 4.60k | featureList.sanitize (c, this) && |
4546 | 4.60k | reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList).sanitize (c, this)))) |
4547 | 0 | return_trace (false); |
4548 | | |
4549 | 4.60k | #ifndef HB_NO_VAR |
4550 | 4.60k | if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this)))) |
4551 | 0 | return_trace (false); |
4552 | 4.60k | #endif |
4553 | | |
4554 | 4.60k | return_trace (true); |
4555 | 4.60k | } bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::sanitize<OT::Layout::GPOS_impl::PosLookup>(hb_sanitize_context_t*) const Line | Count | Source | 4541 | 2.30k | { | 4542 | 2.30k | TRACE_SANITIZE (this); | 4543 | 2.30k | typedef List16OfOffsetTo<TLookup, typename Types::HBUINT> TLookupList; | 4544 | 2.30k | if (unlikely (!(scriptList.sanitize (c, this) && | 4545 | 2.30k | featureList.sanitize (c, this) && | 4546 | 2.30k | reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList).sanitize (c, this)))) | 4547 | 0 | return_trace (false); | 4548 | | | 4549 | 2.30k | #ifndef HB_NO_VAR | 4550 | 2.30k | if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this)))) | 4551 | 0 | return_trace (false); | 4552 | 2.30k | #endif | 4553 | | | 4554 | 2.30k | return_trace (true); | 4555 | 2.30k | } |
bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::sanitize<OT::Layout::GSUB_impl::SubstLookup>(hb_sanitize_context_t*) const Line | Count | Source | 4541 | 2.30k | { | 4542 | 2.30k | TRACE_SANITIZE (this); | 4543 | 2.30k | typedef List16OfOffsetTo<TLookup, typename Types::HBUINT> TLookupList; | 4544 | 2.30k | if (unlikely (!(scriptList.sanitize (c, this) && | 4545 | 2.30k | featureList.sanitize (c, this) && | 4546 | 2.30k | reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList).sanitize (c, this)))) | 4547 | 0 | return_trace (false); | 4548 | | | 4549 | 2.30k | #ifndef HB_NO_VAR | 4550 | 2.30k | if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this)))) | 4551 | 0 | return_trace (false); | 4552 | 2.30k | #endif | 4553 | | | 4554 | 2.30k | return_trace (true); | 4555 | 2.30k | } |
|
4556 | | |
4557 | | template <typename TLookup> |
4558 | | bool subset (hb_subset_layout_context_t *c) const |
4559 | 0 | { |
4560 | 0 | TRACE_SUBSET (this); |
4561 | 0 |
|
4562 | 0 | auto *out = c->subset_context->serializer->start_embed (this); |
4563 | 0 | if (unlikely (!c->subset_context->serializer->extend_min (out))) return_trace (false); |
4564 | 0 |
|
4565 | 0 | out->version = version; |
4566 | 0 |
|
4567 | 0 | typedef LookupOffsetList<TLookup, typename Types::HBUINT> TLookupList; |
4568 | 0 | reinterpret_cast<typename Types::template OffsetTo<TLookupList> &> (out->lookupList) |
4569 | 0 | .serialize_subset (c->subset_context, |
4570 | 0 | reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList), |
4571 | 0 | this, |
4572 | 0 | c); |
4573 | 0 |
|
4574 | 0 | reinterpret_cast<typename Types::template OffsetTo<RecordListOfFeature> &> (out->featureList) |
4575 | 0 | .serialize_subset (c->subset_context, |
4576 | 0 | reinterpret_cast<const typename Types::template OffsetTo<RecordListOfFeature> &> (featureList), |
4577 | 0 | this, |
4578 | 0 | c); |
4579 | 0 |
|
4580 | 0 | out->scriptList.serialize_subset (c->subset_context, |
4581 | 0 | scriptList, |
4582 | 0 | this, |
4583 | 0 | c); |
4584 | 0 |
|
4585 | 0 | #ifndef HB_NO_VAR |
4586 | 0 | if (version.to_int () >= 0x00010001u) |
4587 | 0 | { |
4588 | 0 | auto snapshot = c->subset_context->serializer->snapshot (); |
4589 | 0 | if (!c->subset_context->serializer->extend_min (&out->featureVars)) |
4590 | 0 | return_trace (false); |
4591 | 0 |
|
4592 | 0 | // if all axes are pinned all feature vars are dropped. |
4593 | 0 | bool ret = !c->subset_context->plan->all_axes_pinned |
4594 | 0 | && out->featureVars.serialize_subset (c->subset_context, featureVars, this, c); |
4595 | 0 | if (!ret && version.major == 1) |
4596 | 0 | { |
4597 | 0 | c->subset_context->serializer->revert (snapshot); |
4598 | 0 | out->version.major = 1; |
4599 | 0 | out->version.minor = 0; |
4600 | 0 | } |
4601 | 0 | } |
4602 | 0 | #endif |
4603 | 0 |
|
4604 | 0 | return_trace (true); |
4605 | 0 | } Unexecuted instantiation: bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::subset<OT::Layout::GPOS_impl::PosLookup>(OT::hb_subset_layout_context_t*) const Unexecuted instantiation: bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::subset<OT::Layout::GSUB_impl::SubstLookup>(OT::hb_subset_layout_context_t*) const |
4606 | | }; |
4607 | | |
4608 | | struct GSUBGPOS |
4609 | | { |
4610 | | unsigned int get_size () const |
4611 | 0 | { |
4612 | 0 | switch (u.version.major) { |
4613 | 0 | case 1: hb_barrier (); return u.version1.get_size (); |
4614 | 0 | #ifndef HB_NO_BEYOND_64K |
4615 | 0 | case 2: hb_barrier (); return u.version2.get_size (); |
4616 | 0 | #endif |
4617 | 0 | default: return u.version.static_size; |
4618 | 0 | } |
4619 | 0 | } |
4620 | | |
4621 | | template <typename TLookup> |
4622 | | bool sanitize (hb_sanitize_context_t *c) const |
4623 | 4.60k | { |
4624 | 4.60k | TRACE_SANITIZE (this); |
4625 | 4.60k | if (unlikely (!u.version.sanitize (c))) return_trace (false); |
4626 | 4.60k | hb_barrier (); |
4627 | 4.60k | switch (u.version.major) { |
4628 | 4.60k | case 1: hb_barrier (); return_trace (u.version1.sanitize<TLookup> (c)); |
4629 | | #ifndef HB_NO_BEYOND_64K |
4630 | | case 2: hb_barrier (); return_trace (u.version2.sanitize<TLookup> (c)); |
4631 | | #endif |
4632 | 0 | default: return_trace (true); |
4633 | 4.60k | } |
4634 | 4.60k | } bool OT::GSUBGPOS::sanitize<OT::Layout::GPOS_impl::PosLookup>(hb_sanitize_context_t*) const Line | Count | Source | 4623 | 2.30k | { | 4624 | 2.30k | TRACE_SANITIZE (this); | 4625 | 2.30k | if (unlikely (!u.version.sanitize (c))) return_trace (false); | 4626 | 2.30k | hb_barrier (); | 4627 | 2.30k | switch (u.version.major) { | 4628 | 2.30k | case 1: hb_barrier (); return_trace (u.version1.sanitize<TLookup> (c)); | 4629 | | #ifndef HB_NO_BEYOND_64K | 4630 | | case 2: hb_barrier (); return_trace (u.version2.sanitize<TLookup> (c)); | 4631 | | #endif | 4632 | 0 | default: return_trace (true); | 4633 | 2.30k | } | 4634 | 2.30k | } |
bool OT::GSUBGPOS::sanitize<OT::Layout::GSUB_impl::SubstLookup>(hb_sanitize_context_t*) const Line | Count | Source | 4623 | 2.30k | { | 4624 | 2.30k | TRACE_SANITIZE (this); | 4625 | 2.30k | if (unlikely (!u.version.sanitize (c))) return_trace (false); | 4626 | 2.30k | hb_barrier (); | 4627 | 2.30k | switch (u.version.major) { | 4628 | 2.30k | case 1: hb_barrier (); return_trace (u.version1.sanitize<TLookup> (c)); | 4629 | | #ifndef HB_NO_BEYOND_64K | 4630 | | case 2: hb_barrier (); return_trace (u.version2.sanitize<TLookup> (c)); | 4631 | | #endif | 4632 | 0 | default: return_trace (true); | 4633 | 2.30k | } | 4634 | 2.30k | } |
|
4635 | | |
4636 | | template <typename TLookup> |
4637 | | bool subset (hb_subset_layout_context_t *c) const |
4638 | 0 | { |
4639 | 0 | switch (u.version.major) { |
4640 | 0 | case 1: hb_barrier (); return u.version1.subset<TLookup> (c); |
4641 | 0 | #ifndef HB_NO_BEYOND_64K |
4642 | 0 | case 2: hb_barrier (); return u.version2.subset<TLookup> (c); |
4643 | 0 | #endif |
4644 | 0 | default: return false; |
4645 | 0 | } |
4646 | 0 | } Unexecuted instantiation: bool OT::GSUBGPOS::subset<OT::Layout::GPOS_impl::PosLookup>(OT::hb_subset_layout_context_t*) const Unexecuted instantiation: bool OT::GSUBGPOS::subset<OT::Layout::GSUB_impl::SubstLookup>(OT::hb_subset_layout_context_t*) const |
4647 | | |
4648 | | const ScriptList &get_script_list () const |
4649 | 37.5k | { |
4650 | 37.5k | switch (u.version.major) { |
4651 | 37.5k | case 1: hb_barrier (); return this+u.version1.scriptList; |
4652 | | #ifndef HB_NO_BEYOND_64K |
4653 | | case 2: hb_barrier (); return this+u.version2.scriptList; |
4654 | | #endif |
4655 | 0 | default: return Null (ScriptList); |
4656 | 37.5k | } |
4657 | 37.5k | } |
4658 | | const FeatureList &get_feature_list () const |
4659 | 683 | { |
4660 | 683 | switch (u.version.major) { |
4661 | 683 | case 1: hb_barrier (); return this+u.version1.featureList; |
4662 | | #ifndef HB_NO_BEYOND_64K |
4663 | | case 2: hb_barrier (); return this+u.version2.featureList; |
4664 | | #endif |
4665 | 0 | default: return Null (FeatureList); |
4666 | 683 | } |
4667 | 683 | } |
4668 | | unsigned int get_lookup_count () const |
4669 | 4.95k | { |
4670 | 4.95k | switch (u.version.major) { |
4671 | 4.95k | case 1: hb_barrier (); return (this+u.version1.lookupList).len; |
4672 | | #ifndef HB_NO_BEYOND_64K |
4673 | | case 2: hb_barrier (); return (this+u.version2.lookupList).len; |
4674 | | #endif |
4675 | 0 | default: return 0; |
4676 | 4.95k | } |
4677 | 4.95k | } |
4678 | | const Lookup& get_lookup (unsigned int i) const |
4679 | 535 | { |
4680 | 535 | switch (u.version.major) { |
4681 | 535 | case 1: hb_barrier (); return (this+u.version1.lookupList)[i]; |
4682 | | #ifndef HB_NO_BEYOND_64K |
4683 | | case 2: hb_barrier (); return (this+u.version2.lookupList)[i]; |
4684 | | #endif |
4685 | 0 | default: return Null (Lookup); |
4686 | 535 | } |
4687 | 535 | } |
4688 | | const FeatureVariations &get_feature_variations () const |
4689 | 407k | { |
4690 | 407k | switch (u.version.major) { |
4691 | 407k | case 1: hb_barrier (); return (u.version.to_int () >= 0x00010001u && hb_barrier () ? this+u.version1.featureVars : Null (FeatureVariations)); |
4692 | | #ifndef HB_NO_BEYOND_64K |
4693 | | case 2: hb_barrier (); return this+u.version2.featureVars; |
4694 | | #endif |
4695 | 0 | default: return Null (FeatureVariations); |
4696 | 407k | } |
4697 | 407k | } |
4698 | | |
4699 | 5.39k | bool has_data () const { return u.version.to_int (); } |
4700 | | unsigned int get_script_count () const |
4701 | 0 | { return get_script_list ().len; } |
4702 | | const Tag& get_script_tag (unsigned int i) const |
4703 | 0 | { return get_script_list ().get_tag (i); } |
4704 | | unsigned int get_script_tags (unsigned int start_offset, |
4705 | | unsigned int *script_count /* IN/OUT */, |
4706 | | hb_tag_t *script_tags /* OUT */) const |
4707 | 0 | { return get_script_list ().get_tags (start_offset, script_count, script_tags); } |
4708 | | const Script& get_script (unsigned int i) const |
4709 | 16.2k | { return get_script_list ()[i]; } |
4710 | | bool find_script_index (hb_tag_t tag, unsigned int *index) const |
4711 | 21.3k | { return get_script_list ().find_index (tag, index); } |
4712 | | |
4713 | | unsigned int get_feature_count () const |
4714 | 0 | { return get_feature_list ().len; } |
4715 | | hb_tag_t get_feature_tag (unsigned int i) const |
4716 | 5.72k | { return i == Index::NOT_FOUND_INDEX ? HB_TAG_NONE : get_feature_list ().get_tag (i); } |
4717 | | unsigned int get_feature_tags (unsigned int start_offset, |
4718 | | unsigned int *feature_count /* IN/OUT */, |
4719 | | hb_tag_t *feature_tags /* OUT */) const |
4720 | 0 | { return get_feature_list ().get_tags (start_offset, feature_count, feature_tags); } |
4721 | | const Feature& get_feature (unsigned int i) const |
4722 | 348 | { return get_feature_list ()[i]; } |
4723 | | bool find_feature_index (hb_tag_t tag, unsigned int *index) const |
4724 | 0 | { return get_feature_list ().find_index (tag, index); } |
4725 | | |
4726 | | bool find_variations_index (const int *coords, unsigned int num_coords, |
4727 | | unsigned int *index, |
4728 | | ItemVarStoreInstancer *instancer) const |
4729 | 407k | { |
4730 | | #ifdef HB_NO_VAR |
4731 | | *index = FeatureVariations::NOT_FOUND_INDEX; |
4732 | | return false; |
4733 | | #endif |
4734 | 407k | return get_feature_variations ().find_index (coords, num_coords, index, instancer); |
4735 | 407k | } |
4736 | | const Feature& get_feature_variation (unsigned int feature_index, |
4737 | | unsigned int variations_index) const |
4738 | 348 | { |
4739 | 348 | #ifndef HB_NO_VAR |
4740 | 348 | if (FeatureVariations::NOT_FOUND_INDEX != variations_index && |
4741 | 348 | u.version.to_int () >= 0x00010001u) |
4742 | 0 | { |
4743 | 0 | const Feature *feature = get_feature_variations ().find_substitute (variations_index, |
4744 | 0 | feature_index); |
4745 | 0 | if (feature) |
4746 | 0 | return *feature; |
4747 | 0 | } |
4748 | 348 | #endif |
4749 | 348 | return get_feature (feature_index); |
4750 | 348 | } |
4751 | | |
4752 | | void feature_variation_collect_lookups (const hb_set_t *feature_indexes, |
4753 | | const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map, |
4754 | | hb_set_t *lookup_indexes /* OUT */) const |
4755 | 0 | { |
4756 | 0 | #ifndef HB_NO_VAR |
4757 | 0 | get_feature_variations ().collect_lookups (feature_indexes, feature_record_cond_idx_map, lookup_indexes); |
4758 | 0 | #endif |
4759 | 0 | } |
4760 | | |
4761 | | #ifndef HB_NO_VAR |
4762 | | void collect_feature_substitutes_with_variations (hb_collect_feature_substitutes_with_var_context_t *c) const |
4763 | 0 | { get_feature_variations ().collect_feature_substitutes_with_variations (c); } |
4764 | | #endif |
4765 | | |
4766 | | template <typename TLookup> |
4767 | | void closure_lookups (hb_face_t *face, |
4768 | | const hb_set_t *glyphs, |
4769 | | hb_set_t *lookup_indexes /* IN/OUT */) const |
4770 | 0 | { |
4771 | 0 | hb_set_t visited_lookups, inactive_lookups; |
4772 | 0 | hb_closure_lookups_context_t c (face, glyphs, &visited_lookups, &inactive_lookups); |
4773 | 0 |
|
4774 | 0 | c.set_recurse_func (TLookup::template dispatch_recurse_func<hb_closure_lookups_context_t>); |
4775 | 0 |
|
4776 | 0 | for (unsigned lookup_index : *lookup_indexes) |
4777 | 0 | reinterpret_cast<const TLookup &> (get_lookup (lookup_index)).closure_lookups (&c, lookup_index); |
4778 | 0 |
|
4779 | 0 | hb_set_union (lookup_indexes, &visited_lookups); |
4780 | 0 | hb_set_subtract (lookup_indexes, &inactive_lookups); |
4781 | 0 | } Unexecuted instantiation: void OT::GSUBGPOS::closure_lookups<OT::Layout::GPOS_impl::PosLookup>(hb_face_t*, hb_set_t const*, hb_set_t*) const Unexecuted instantiation: void OT::GSUBGPOS::closure_lookups<OT::Layout::GSUB_impl::SubstLookup>(hb_face_t*, hb_set_t const*, hb_set_t*) const |
4782 | | |
4783 | | void prune_langsys (const hb_map_t *duplicate_feature_map, |
4784 | | const hb_set_t *layout_scripts, |
4785 | | hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *script_langsys_map, |
4786 | | hb_set_t *new_feature_indexes /* OUT */) const |
4787 | 0 | { |
4788 | 0 | hb_prune_langsys_context_t c (this, script_langsys_map, duplicate_feature_map, new_feature_indexes); |
4789 | 0 |
|
4790 | 0 | unsigned count = get_script_count (); |
4791 | 0 | for (unsigned script_index = 0; script_index < count; script_index++) |
4792 | 0 | { |
4793 | 0 | const Tag& tag = get_script_tag (script_index); |
4794 | 0 | if (!layout_scripts->has (tag)) continue; |
4795 | 0 | const Script& s = get_script (script_index); |
4796 | 0 | s.prune_langsys (&c, script_index); |
4797 | 0 | } |
4798 | 0 | } |
4799 | | |
4800 | | void prune_features (const hb_map_t *lookup_indices, /* IN */ |
4801 | | const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map, /* IN */ |
4802 | | const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map, /* IN */ |
4803 | | hb_set_t *feature_indices /* IN/OUT */) const |
4804 | 0 | { |
4805 | 0 | #ifndef HB_NO_VAR |
4806 | 0 | // This is the set of feature indices which have alternate versions defined |
4807 | 0 | // if the FeatureVariation's table and the alternate version(s) intersect the |
4808 | 0 | // set of lookup indices. |
4809 | 0 | hb_set_t alternate_feature_indices; |
4810 | 0 | get_feature_variations ().closure_features (lookup_indices, feature_record_cond_idx_map, &alternate_feature_indices); |
4811 | 0 | if (unlikely (alternate_feature_indices.in_error())) |
4812 | 0 | { |
4813 | 0 | feature_indices->err (); |
4814 | 0 | return; |
4815 | 0 | } |
4816 | 0 | #endif |
4817 | 0 |
|
4818 | 0 | for (unsigned i : hb_iter (feature_indices)) |
4819 | 0 | { |
4820 | 0 | hb_tag_t tag = get_feature_tag (i); |
4821 | 0 | if (tag == HB_TAG ('p', 'r', 'e', 'f')) |
4822 | 0 | // Note: Never ever drop feature 'pref', even if it's empty. |
4823 | 0 | // HarfBuzz chooses shaper for Khmer based on presence of this |
4824 | 0 | // feature. See thread at: |
4825 | 0 | // http://lists.freedesktop.org/archives/harfbuzz/2012-November/002660.html |
4826 | 0 | continue; |
4827 | 0 |
|
4828 | 0 |
|
4829 | 0 | const Feature *f = &(get_feature (i)); |
4830 | 0 | const Feature** p = nullptr; |
4831 | 0 | if (feature_substitutes_map->has (i, &p)) |
4832 | 0 | f = *p; |
4833 | 0 |
|
4834 | 0 | if (!f->featureParams.is_null () && |
4835 | 0 | tag == HB_TAG ('s', 'i', 'z', 'e')) |
4836 | 0 | continue; |
4837 | 0 |
|
4838 | 0 | if (!f->intersects_lookup_indexes (lookup_indices) |
4839 | 0 | #ifndef HB_NO_VAR |
4840 | 0 | && !alternate_feature_indices.has (i) |
4841 | 0 | #endif |
4842 | 0 | ) |
4843 | 0 | feature_indices->del (i); |
4844 | 0 | } |
4845 | 0 | } |
4846 | | |
4847 | | void collect_name_ids (const hb_map_t *feature_index_map, |
4848 | | hb_set_t *nameids_to_retain /* OUT */) const |
4849 | 0 | { |
4850 | 0 | unsigned count = get_feature_count (); |
4851 | 0 | for (unsigned i = 0 ; i < count; i++) |
4852 | 0 | { |
4853 | 0 | if (!feature_index_map->has (i)) continue; |
4854 | 0 | hb_tag_t tag = get_feature_tag (i); |
4855 | 0 | get_feature (i).collect_name_ids (tag, nameids_to_retain); |
4856 | 0 | } |
4857 | 0 | } |
4858 | | |
4859 | | template <typename T> |
4860 | | struct accelerator_t |
4861 | | { |
4862 | | accelerator_t (hb_face_t *face) |
4863 | 4.60k | { |
4864 | 4.60k | hb_sanitize_context_t sc; |
4865 | 4.60k | sc.lazy_some_gpos = true; |
4866 | 4.60k | this->table = sc.reference_table<T> (face); |
4867 | | |
4868 | 4.60k | if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face))) |
4869 | 0 | { |
4870 | 0 | hb_blob_destroy (this->table.get_blob ()); |
4871 | 0 | this->table = hb_blob_get_empty (); |
4872 | 0 | } |
4873 | | |
4874 | 4.60k | this->lookup_count = table->get_lookup_count (); |
4875 | | |
4876 | 4.60k | this->accels = (hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *) hb_calloc (this->lookup_count, sizeof (*accels)); |
4877 | 4.60k | if (unlikely (!this->accels)) |
4878 | 0 | { |
4879 | 0 | this->lookup_count = 0; |
4880 | 0 | this->table.destroy (); |
4881 | 0 | this->table = hb_blob_get_empty (); |
4882 | 0 | } |
4883 | 4.60k | } OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::accelerator_t(hb_face_t*) Line | Count | Source | 4863 | 2.30k | { | 4864 | 2.30k | hb_sanitize_context_t sc; | 4865 | 2.30k | sc.lazy_some_gpos = true; | 4866 | 2.30k | this->table = sc.reference_table<T> (face); | 4867 | | | 4868 | 2.30k | if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face))) | 4869 | 0 | { | 4870 | 0 | hb_blob_destroy (this->table.get_blob ()); | 4871 | 0 | this->table = hb_blob_get_empty (); | 4872 | 0 | } | 4873 | | | 4874 | 2.30k | this->lookup_count = table->get_lookup_count (); | 4875 | | | 4876 | 2.30k | this->accels = (hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *) hb_calloc (this->lookup_count, sizeof (*accels)); | 4877 | 2.30k | if (unlikely (!this->accels)) | 4878 | 0 | { | 4879 | 0 | this->lookup_count = 0; | 4880 | 0 | this->table.destroy (); | 4881 | 0 | this->table = hb_blob_get_empty (); | 4882 | 0 | } | 4883 | 2.30k | } |
OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::accelerator_t(hb_face_t*) Line | Count | Source | 4863 | 2.30k | { | 4864 | 2.30k | hb_sanitize_context_t sc; | 4865 | 2.30k | sc.lazy_some_gpos = true; | 4866 | 2.30k | this->table = sc.reference_table<T> (face); | 4867 | | | 4868 | 2.30k | if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face))) | 4869 | 0 | { | 4870 | 0 | hb_blob_destroy (this->table.get_blob ()); | 4871 | 0 | this->table = hb_blob_get_empty (); | 4872 | 0 | } | 4873 | | | 4874 | 2.30k | this->lookup_count = table->get_lookup_count (); | 4875 | | | 4876 | 2.30k | this->accels = (hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *) hb_calloc (this->lookup_count, sizeof (*accels)); | 4877 | 2.30k | if (unlikely (!this->accels)) | 4878 | 0 | { | 4879 | 0 | this->lookup_count = 0; | 4880 | 0 | this->table.destroy (); | 4881 | 0 | this->table = hb_blob_get_empty (); | 4882 | 0 | } | 4883 | 2.30k | } |
|
4884 | | ~accelerator_t () |
4885 | 4.60k | { |
4886 | 12.2k | for (unsigned int i = 0; i < this->lookup_count; i++) |
4887 | 7.66k | { |
4888 | 7.66k | auto *accel = this->accels[i].get_relaxed (); |
4889 | 7.66k | if (accel) |
4890 | 220 | accel->fini (); |
4891 | 7.66k | hb_free (accel); |
4892 | 7.66k | } |
4893 | 4.60k | hb_free (this->accels); |
4894 | 4.60k | this->table.destroy (); |
4895 | 4.60k | } OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::~accelerator_t() Line | Count | Source | 4885 | 2.30k | { | 4886 | 9.68k | for (unsigned int i = 0; i < this->lookup_count; i++) | 4887 | 7.38k | { | 4888 | 7.38k | auto *accel = this->accels[i].get_relaxed (); | 4889 | 7.38k | if (accel) | 4890 | 100 | accel->fini (); | 4891 | 7.38k | hb_free (accel); | 4892 | 7.38k | } | 4893 | 2.30k | hb_free (this->accels); | 4894 | 2.30k | this->table.destroy (); | 4895 | 2.30k | } |
OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::~accelerator_t() Line | Count | Source | 4885 | 2.30k | { | 4886 | 2.57k | for (unsigned int i = 0; i < this->lookup_count; i++) | 4887 | 276 | { | 4888 | 276 | auto *accel = this->accels[i].get_relaxed (); | 4889 | 276 | if (accel) | 4890 | 120 | accel->fini (); | 4891 | 276 | hb_free (accel); | 4892 | 276 | } | 4893 | 2.30k | hb_free (this->accels); | 4894 | 2.30k | this->table.destroy (); | 4895 | 2.30k | } |
|
4896 | | |
4897 | 402k | hb_blob_t *get_blob () const { return table.get_blob (); } OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::get_blob() const Line | Count | Source | 4897 | 201k | hb_blob_t *get_blob () const { return table.get_blob (); } |
OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::get_blob() const Line | Count | Source | 4897 | 201k | hb_blob_t *get_blob () const { return table.get_blob (); } |
|
4898 | | |
4899 | | hb_ot_layout_lookup_accelerator_t *get_accel (unsigned lookup_index) const |
4900 | 11.7k | { |
4901 | 11.7k | if (unlikely (lookup_index >= lookup_count)) return nullptr; |
4902 | | |
4903 | 11.7k | retry: |
4904 | 11.7k | auto *accel = accels[lookup_index].get_acquire (); |
4905 | 11.7k | if (unlikely (!accel)) |
4906 | 220 | { |
4907 | 220 | accel = hb_ot_layout_lookup_accelerator_t::create (table->get_lookup (lookup_index)); |
4908 | 220 | if (unlikely (!accel)) |
4909 | 0 | return nullptr; |
4910 | | |
4911 | 220 | if (unlikely (!accels[lookup_index].cmpexch (nullptr, accel))) |
4912 | 0 | { |
4913 | 0 | accel->fini (); |
4914 | 0 | hb_free (accel); |
4915 | 0 | goto retry; |
4916 | 0 | } |
4917 | 220 | } |
4918 | | |
4919 | 11.7k | return accel; |
4920 | 11.7k | } OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::get_accel(unsigned int) const Line | Count | Source | 4900 | 6.87k | { | 4901 | 6.87k | if (unlikely (lookup_index >= lookup_count)) return nullptr; | 4902 | | | 4903 | 6.87k | retry: | 4904 | 6.87k | auto *accel = accels[lookup_index].get_acquire (); | 4905 | 6.87k | if (unlikely (!accel)) | 4906 | 120 | { | 4907 | 120 | accel = hb_ot_layout_lookup_accelerator_t::create (table->get_lookup (lookup_index)); | 4908 | 120 | if (unlikely (!accel)) | 4909 | 0 | return nullptr; | 4910 | | | 4911 | 120 | if (unlikely (!accels[lookup_index].cmpexch (nullptr, accel))) | 4912 | 0 | { | 4913 | 0 | accel->fini (); | 4914 | 0 | hb_free (accel); | 4915 | 0 | goto retry; | 4916 | 0 | } | 4917 | 120 | } | 4918 | | | 4919 | 6.87k | return accel; | 4920 | 6.87k | } |
OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::get_accel(unsigned int) const Line | Count | Source | 4900 | 4.92k | { | 4901 | 4.92k | if (unlikely (lookup_index >= lookup_count)) return nullptr; | 4902 | | | 4903 | 4.92k | retry: | 4904 | 4.92k | auto *accel = accels[lookup_index].get_acquire (); | 4905 | 4.92k | if (unlikely (!accel)) | 4906 | 100 | { | 4907 | 100 | accel = hb_ot_layout_lookup_accelerator_t::create (table->get_lookup (lookup_index)); | 4908 | 100 | if (unlikely (!accel)) | 4909 | 0 | return nullptr; | 4910 | | | 4911 | 100 | if (unlikely (!accels[lookup_index].cmpexch (nullptr, accel))) | 4912 | 0 | { | 4913 | 0 | accel->fini (); | 4914 | 0 | hb_free (accel); | 4915 | 0 | goto retry; | 4916 | 0 | } | 4917 | 100 | } | 4918 | | | 4919 | 4.92k | return accel; | 4920 | 4.92k | } |
|
4921 | | |
4922 | | hb_blob_ptr_t<T> table; |
4923 | | unsigned int lookup_count; |
4924 | | hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *accels; |
4925 | | }; |
4926 | | |
4927 | | protected: |
4928 | | union { |
4929 | | FixedVersion<> version; /* Version identifier */ |
4930 | | GSUBGPOSVersion1_2<SmallTypes> version1; |
4931 | | #ifndef HB_NO_BEYOND_64K |
4932 | | GSUBGPOSVersion1_2<MediumTypes> version2; |
4933 | | #endif |
4934 | | } u; |
4935 | | public: |
4936 | | DEFINE_SIZE_MIN (4); |
4937 | | }; |
4938 | | |
4939 | | |
4940 | | } /* namespace OT */ |
4941 | | |
4942 | | |
4943 | | #endif /* HB_OT_LAYOUT_GSUBGPOS_HH */ |