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