/src/pango/subprojects/harfbuzz/src/hb-ot-layout-gsubgpos.hh
Line | Count | Source |
1 | | /* |
2 | | * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
3 | | * Copyright © 2010,2012 Google, Inc. |
4 | | * |
5 | | * This is part of HarfBuzz, a text shaping library. |
6 | | * |
7 | | * Permission is hereby granted, without written agreement and without |
8 | | * license or royalty fees, to use, copy, modify, and distribute this |
9 | | * software and its documentation for any purpose, provided that the |
10 | | * above copyright notice and the following two paragraphs appear in |
11 | | * all copies of this software. |
12 | | * |
13 | | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
14 | | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
15 | | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
16 | | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
17 | | * DAMAGE. |
18 | | * |
19 | | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
20 | | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
21 | | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
22 | | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
23 | | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
24 | | * |
25 | | * Red Hat Author(s): Behdad Esfahbod |
26 | | * Google Author(s): Behdad Esfahbod |
27 | | */ |
28 | | |
29 | | #ifndef HB_OT_LAYOUT_GSUBGPOS_HH |
30 | | #define HB_OT_LAYOUT_GSUBGPOS_HH |
31 | | |
32 | | #include "hb.hh" |
33 | | #include "hb-buffer.hh" |
34 | | #include "hb-map.hh" |
35 | | #include "hb-set.hh" |
36 | | #include "hb-ot-map.hh" |
37 | | #include "hb-ot-layout-common.hh" |
38 | | #include "hb-ot-layout-gdef-table.hh" |
39 | | |
40 | | |
41 | | namespace OT { |
42 | | |
43 | | |
44 | | struct hb_intersects_context_t : |
45 | | hb_dispatch_context_t<hb_intersects_context_t, bool> |
46 | | { |
47 | | template <typename T> |
48 | 0 | return_t dispatch (const T &obj) { return obj.intersects (this->glyphs); }Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
49 | 0 | static return_t default_return_value () { return false; } |
50 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
51 | | |
52 | | const hb_set_t *glyphs; |
53 | | |
54 | | hb_intersects_context_t (const hb_set_t *glyphs_) : |
55 | 0 | glyphs (glyphs_) {} |
56 | | }; |
57 | | |
58 | | struct hb_have_non_1to1_context_t : |
59 | | hb_dispatch_context_t<hb_have_non_1to1_context_t, bool> |
60 | | { |
61 | | template <typename T> |
62 | 0 | return_t dispatch (const T &obj) { return obj.may_have_non_1to1 (); }Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
63 | 0 | static return_t default_return_value () { return false; } |
64 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
65 | | }; |
66 | | |
67 | | struct hb_closure_context_t : |
68 | | hb_dispatch_context_t<hb_closure_context_t> |
69 | | { |
70 | | typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indicies, unsigned seq_index, unsigned end_index); |
71 | | template <typename T> |
72 | 0 | return_t dispatch (const T &obj) { obj.closure (this); return hb_empty_t (); }Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
73 | 0 | static return_t default_return_value () { return hb_empty_t (); } |
74 | | void recurse (unsigned lookup_index, hb_set_t *covered_seq_indicies, unsigned seq_index, unsigned end_index) |
75 | 0 | { |
76 | 0 | if (unlikely (nesting_level_left == 0 || !recurse_func)) |
77 | 0 | return; |
78 | | |
79 | 0 | nesting_level_left--; |
80 | 0 | recurse_func (this, lookup_index, covered_seq_indicies, seq_index, end_index); |
81 | 0 | nesting_level_left++; |
82 | 0 | } |
83 | | |
84 | | void reset_lookup_visit_count () |
85 | 0 | { lookup_count = 0; } |
86 | | |
87 | | bool lookup_limit_exceeded () |
88 | 0 | { return lookup_count > HB_MAX_LOOKUP_VISIT_COUNT; } |
89 | | |
90 | | bool should_visit_lookup (unsigned int lookup_index) |
91 | 0 | { |
92 | 0 | if (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT) |
93 | 0 | return false; |
94 | | |
95 | 0 | if (is_lookup_done (lookup_index)) |
96 | 0 | return false; |
97 | | |
98 | 0 | return true; |
99 | 0 | } |
100 | | |
101 | | bool is_lookup_done (unsigned int lookup_index) |
102 | 0 | { |
103 | 0 | if (unlikely (done_lookups_glyph_count->in_error () || |
104 | 0 | done_lookups_glyph_set->in_error ())) |
105 | 0 | return true; |
106 | | |
107 | | /* Have we visited this lookup with the current set of glyphs? */ |
108 | 0 | if (done_lookups_glyph_count->get (lookup_index) != glyphs->get_population ()) |
109 | 0 | { |
110 | 0 | done_lookups_glyph_count->set (lookup_index, glyphs->get_population ()); |
111 | |
|
112 | 0 | if (!done_lookups_glyph_set->has (lookup_index)) |
113 | 0 | { |
114 | 0 | if (unlikely (!done_lookups_glyph_set->set (lookup_index, hb::unique_ptr<hb_set_t> {hb_set_create ()}))) |
115 | 0 | return true; |
116 | 0 | } |
117 | | |
118 | 0 | done_lookups_glyph_set->get (lookup_index)->clear (); |
119 | 0 | } |
120 | | |
121 | 0 | hb_set_t *covered_glyph_set = done_lookups_glyph_set->get (lookup_index); |
122 | 0 | if (unlikely (covered_glyph_set->in_error ())) |
123 | 0 | return true; |
124 | 0 | if (parent_active_glyphs ().is_subset (*covered_glyph_set)) |
125 | 0 | return true; |
126 | | |
127 | 0 | covered_glyph_set->union_ (parent_active_glyphs ()); |
128 | 0 | return false; |
129 | 0 | } |
130 | | |
131 | 0 | const hb_set_t& previous_parent_active_glyphs () { |
132 | 0 | if (active_glyphs_stack.length <= 1) |
133 | 0 | return *glyphs; |
134 | | |
135 | 0 | return active_glyphs_stack[active_glyphs_stack.length - 2]; |
136 | 0 | } |
137 | | |
138 | | const hb_set_t& parent_active_glyphs () |
139 | 0 | { |
140 | 0 | if (!active_glyphs_stack) |
141 | 0 | return *glyphs; |
142 | | |
143 | 0 | return active_glyphs_stack.tail (); |
144 | 0 | } |
145 | | |
146 | | hb_set_t* push_cur_active_glyphs () |
147 | 0 | { |
148 | 0 | hb_set_t *s = active_glyphs_stack.push (); |
149 | 0 | if (unlikely (active_glyphs_stack.in_error ())) |
150 | 0 | return nullptr; |
151 | 0 | return s; |
152 | 0 | } |
153 | | |
154 | | bool pop_cur_done_glyphs () |
155 | 0 | { |
156 | 0 | if (!active_glyphs_stack) |
157 | 0 | return false; |
158 | | |
159 | 0 | active_glyphs_stack.pop (); |
160 | 0 | return true; |
161 | 0 | } |
162 | | |
163 | | hb_face_t *face; |
164 | | hb_set_t *glyphs; |
165 | | hb_set_t output[1]; |
166 | | hb_vector_t<hb_set_t> active_glyphs_stack; |
167 | | recurse_func_t recurse_func = nullptr; |
168 | | unsigned int nesting_level_left; |
169 | | |
170 | | hb_closure_context_t (hb_face_t *face_, |
171 | | hb_set_t *glyphs_, |
172 | | hb_map_t *done_lookups_glyph_count_, |
173 | | hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *done_lookups_glyph_set_, |
174 | | unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
175 | 0 | face (face_), |
176 | 0 | glyphs (glyphs_), |
177 | 0 | nesting_level_left (nesting_level_left_), |
178 | 0 | done_lookups_glyph_count (done_lookups_glyph_count_), |
179 | 0 | done_lookups_glyph_set (done_lookups_glyph_set_) |
180 | 0 | {} |
181 | | |
182 | 0 | ~hb_closure_context_t () { flush (); } |
183 | | |
184 | 0 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
185 | | |
186 | | void flush () |
187 | 0 | { |
188 | 0 | output->del_range (face->get_num_glyphs (), HB_SET_VALUE_INVALID); /* Remove invalid glyphs. */ |
189 | 0 | glyphs->union_ (*output); |
190 | 0 | output->clear (); |
191 | 0 | active_glyphs_stack.pop (); |
192 | 0 | active_glyphs_stack.reset (); |
193 | 0 | } |
194 | | |
195 | | private: |
196 | | hb_map_t *done_lookups_glyph_count; |
197 | | hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *done_lookups_glyph_set; |
198 | | unsigned int lookup_count = 0; |
199 | | }; |
200 | | |
201 | | |
202 | | |
203 | | struct hb_closure_lookups_context_t : |
204 | | hb_dispatch_context_t<hb_closure_lookups_context_t> |
205 | | { |
206 | | typedef return_t (*recurse_func_t) (hb_closure_lookups_context_t *c, unsigned lookup_index); |
207 | | template <typename T> |
208 | 0 | return_t dispatch (const T &obj) { obj.closure_lookups (this); return hb_empty_t (); }Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
209 | 0 | static return_t default_return_value () { return hb_empty_t (); } |
210 | | void recurse (unsigned lookup_index) |
211 | 0 | { |
212 | 0 | if (unlikely (nesting_level_left == 0 || !recurse_func)) |
213 | 0 | return; |
214 | 0 |
|
215 | 0 | /* Return if new lookup was recursed to before. */ |
216 | 0 | if (lookup_limit_exceeded () |
217 | 0 | || visited_lookups->in_error () |
218 | 0 | || visited_lookups->has (lookup_index)) |
219 | 0 | // Don't increment lookup count here, that will be done in the call to closure_lookups() |
220 | 0 | // made by recurse_func. |
221 | 0 | return; |
222 | 0 |
|
223 | 0 | nesting_level_left--; |
224 | 0 | recurse_func (this, lookup_index); |
225 | 0 | nesting_level_left++; |
226 | 0 | } |
227 | | |
228 | | void set_lookup_visited (unsigned lookup_index) |
229 | 0 | { visited_lookups->add (lookup_index); } |
230 | | |
231 | | void set_lookup_inactive (unsigned lookup_index) |
232 | 0 | { inactive_lookups->add (lookup_index); } |
233 | | |
234 | | bool lookup_limit_exceeded () |
235 | 0 | { |
236 | 0 | bool ret = lookup_count > HB_MAX_LOOKUP_VISIT_COUNT; |
237 | 0 | if (ret) |
238 | 0 | DEBUG_MSG (SUBSET, nullptr, "lookup visit count limit exceeded in lookup closure!"); |
239 | 0 | return ret; } |
240 | | |
241 | | bool is_lookup_visited (unsigned lookup_index) |
242 | 0 | { |
243 | 0 | if (unlikely (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT)) |
244 | 0 | { |
245 | 0 | DEBUG_MSG (SUBSET, nullptr, "total visited lookup count %u exceeds max limit, lookup %u is dropped.", |
246 | 0 | lookup_count, lookup_index); |
247 | 0 | return true; |
248 | 0 | } |
249 | 0 |
|
250 | 0 | if (unlikely (visited_lookups->in_error ())) |
251 | 0 | return true; |
252 | 0 |
|
253 | 0 | return visited_lookups->has (lookup_index); |
254 | 0 | } |
255 | | |
256 | | hb_face_t *face; |
257 | | const hb_set_t *glyphs; |
258 | | recurse_func_t recurse_func; |
259 | | unsigned int nesting_level_left; |
260 | | |
261 | | hb_closure_lookups_context_t (hb_face_t *face_, |
262 | | const hb_set_t *glyphs_, |
263 | | hb_set_t *visited_lookups_, |
264 | | hb_set_t *inactive_lookups_, |
265 | | unsigned nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
266 | | face (face_), |
267 | | glyphs (glyphs_), |
268 | | recurse_func (nullptr), |
269 | | nesting_level_left (nesting_level_left_), |
270 | | visited_lookups (visited_lookups_), |
271 | | inactive_lookups (inactive_lookups_), |
272 | 0 | lookup_count (0) {} |
273 | | |
274 | 0 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
275 | | |
276 | | private: |
277 | | hb_set_t *visited_lookups; |
278 | | hb_set_t *inactive_lookups; |
279 | | unsigned int lookup_count; |
280 | | }; |
281 | | |
282 | | struct hb_would_apply_context_t : |
283 | | hb_dispatch_context_t<hb_would_apply_context_t, bool> |
284 | | { |
285 | | template <typename T> |
286 | 0 | return_t dispatch (const T &obj) { return obj.would_apply (this); }Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
287 | 0 | static return_t default_return_value () { return false; } |
288 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
289 | | |
290 | | hb_face_t *face; |
291 | | const hb_codepoint_t *glyphs; |
292 | | unsigned int len; |
293 | | bool zero_context; |
294 | | |
295 | | hb_would_apply_context_t (hb_face_t *face_, |
296 | | const hb_codepoint_t *glyphs_, |
297 | | unsigned int len_, |
298 | | bool zero_context_) : |
299 | 0 | face (face_), |
300 | 0 | glyphs (glyphs_), |
301 | 0 | len (len_), |
302 | 0 | zero_context (zero_context_) {} |
303 | | }; |
304 | | |
305 | | struct hb_collect_glyphs_context_t : |
306 | | hb_dispatch_context_t<hb_collect_glyphs_context_t> |
307 | | { |
308 | | typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index); |
309 | | template <typename T> |
310 | 0 | return_t dispatch (const T &obj) { obj.collect_glyphs (this); return hb_empty_t (); }Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&) Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
311 | 0 | static return_t default_return_value () { return hb_empty_t (); } |
312 | | void recurse (unsigned int lookup_index) |
313 | 0 | { |
314 | 0 | if (unlikely (nesting_level_left == 0 || !recurse_func)) |
315 | 0 | return; |
316 | | |
317 | | /* Note that GPOS sets recurse_func to nullptr already, so it doesn't get |
318 | | * past the previous check. For GSUB, we only want to collect the output |
319 | | * glyphs in the recursion. If output is not requested, we can go home now. |
320 | | * |
321 | | * Note further, that the above is not exactly correct. A recursed lookup |
322 | | * is allowed to match input that is not matched in the context, but that's |
323 | | * not how most fonts are built. It's possible to relax that and recurse |
324 | | * with all sets here if it proves to be an issue. |
325 | | */ |
326 | | |
327 | 0 | if (output == hb_set_get_empty ()) |
328 | 0 | return; |
329 | | |
330 | | /* Return if new lookup was recursed to before. */ |
331 | 0 | if (recursed_lookups->has (lookup_index)) |
332 | 0 | return; |
333 | | |
334 | 0 | hb_set_t *old_before = before; |
335 | 0 | hb_set_t *old_input = input; |
336 | 0 | hb_set_t *old_after = after; |
337 | 0 | before = input = after = hb_set_get_empty (); |
338 | |
|
339 | 0 | nesting_level_left--; |
340 | 0 | recurse_func (this, lookup_index); |
341 | 0 | nesting_level_left++; |
342 | |
|
343 | 0 | before = old_before; |
344 | 0 | input = old_input; |
345 | 0 | after = old_after; |
346 | |
|
347 | 0 | recursed_lookups->add (lookup_index); |
348 | 0 | } |
349 | | |
350 | | hb_face_t *face; |
351 | | hb_set_t *before; |
352 | | hb_set_t *input; |
353 | | hb_set_t *after; |
354 | | hb_set_t *output; |
355 | | recurse_func_t recurse_func; |
356 | | hb_set_t *recursed_lookups; |
357 | | unsigned int nesting_level_left; |
358 | | |
359 | | hb_collect_glyphs_context_t (hb_face_t *face_, |
360 | | hb_set_t *glyphs_before, /* OUT. May be NULL */ |
361 | | hb_set_t *glyphs_input, /* OUT. May be NULL */ |
362 | | hb_set_t *glyphs_after, /* OUT. May be NULL */ |
363 | | hb_set_t *glyphs_output, /* OUT. May be NULL */ |
364 | | unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : |
365 | 0 | face (face_), |
366 | 0 | before (glyphs_before ? glyphs_before : hb_set_get_empty ()), |
367 | 0 | input (glyphs_input ? glyphs_input : hb_set_get_empty ()), |
368 | 0 | after (glyphs_after ? glyphs_after : hb_set_get_empty ()), |
369 | 0 | output (glyphs_output ? glyphs_output : hb_set_get_empty ()), |
370 | 0 | recurse_func (nullptr), |
371 | 0 | recursed_lookups (hb_set_create ()), |
372 | 0 | nesting_level_left (nesting_level_left_) {} |
373 | 0 | ~hb_collect_glyphs_context_t () { hb_set_destroy (recursed_lookups); } |
374 | | |
375 | 0 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
376 | | }; |
377 | | |
378 | | |
379 | | |
380 | | template <typename set_t> |
381 | | struct hb_collect_coverage_context_t : |
382 | | hb_dispatch_context_t<hb_collect_coverage_context_t<set_t>, const Coverage &> |
383 | | { |
384 | | typedef const Coverage &return_t; // Stoopid that we have to dupe this here. |
385 | | template <typename T> |
386 | | return_t dispatch (const T &obj) { return obj.get_coverage (); } |
387 | | static return_t default_return_value () { return Null (Coverage); } |
388 | | bool stop_sublookup_iteration (return_t r) const |
389 | | { |
390 | | r.collect_coverage (set); |
391 | | return false; |
392 | | } |
393 | | |
394 | | hb_collect_coverage_context_t (set_t *set_) : |
395 | | set (set_) {} |
396 | | |
397 | | set_t *set; |
398 | | }; |
399 | | |
400 | | struct 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 | 0 | void set_ignore_zwnj (bool ignore_zwnj_) { ignore_zwnj = ignore_zwnj_; } |
408 | 0 | void set_ignore_zwj (bool ignore_zwj_) { ignore_zwj = ignore_zwj_; } |
409 | 0 | void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; } |
410 | 0 | void set_mask (hb_mask_t mask_) { mask = mask_; } |
411 | 0 | void set_per_syllable (bool per_syllable_) { per_syllable = per_syllable_; } |
412 | 0 | 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 | 0 | { 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 | 0 | { |
477 | 0 | c = c_; |
478 | 0 | end = c->buffer->len; |
479 | 0 | match_glyph_data16 = nullptr; |
480 | | #ifndef HB_NO_BEYOND_64K |
481 | | match_glyph_data24 = nullptr; |
482 | | #endif |
483 | 0 | matcher.set_match_func (nullptr, nullptr); |
484 | 0 | matcher.set_lookup_props (c->lookup_props); |
485 | | /* Ignore ZWNJ if we are matching GPOS, or matching GSUB context and asked to. */ |
486 | 0 | 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 | 0 | matcher.set_ignore_zwj (context_match || c->auto_zwj); |
489 | 0 | matcher.set_mask (context_match ? -1 : c->lookup_mask); |
490 | | /* Per syllable matching is only for GSUB. */ |
491 | 0 | matcher.set_per_syllable (c->table_index == 0 && c->per_syllable); |
492 | 0 | matcher.set_syllable (0); |
493 | 0 | } |
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 ItemVariationStore &var_store; |
712 | | ItemVariationStore::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 | | unsigned new_syllables = (unsigned) -1; |
727 | | |
728 | | signed last_base = -1; // GPOS uses |
729 | | unsigned last_base_until = 0; // GPOS uses |
730 | | |
731 | | hb_ot_apply_context_t (unsigned int table_index_, |
732 | | hb_font_t *font_, |
733 | | hb_buffer_t *buffer_, |
734 | | hb_blob_t *table_blob_) : |
735 | 0 | table_index (table_index_), |
736 | 0 | font (font_), face (font->face), buffer (buffer_), |
737 | 0 | sanitizer (table_blob_), |
738 | | gdef ( |
739 | | #ifndef HB_NO_OT_LAYOUT |
740 | 0 | *face->table.GDEF->table |
741 | | #else |
742 | | Null (GDEF) |
743 | | #endif |
744 | | ), |
745 | | gdef_accel ( |
746 | | #ifndef HB_NO_OT_LAYOUT |
747 | 0 | *face->table.GDEF |
748 | | #else |
749 | | Null (GDEF::accelerator_t) |
750 | | #endif |
751 | | ), |
752 | 0 | var_store (gdef.get_var_store ()), |
753 | | var_store_cache ( |
754 | | #ifndef HB_NO_VAR |
755 | 0 | table_index == 1 && font->num_coords ? var_store.create_cache () : nullptr |
756 | | #else |
757 | | nullptr |
758 | | #endif |
759 | | ), |
760 | 0 | digest (buffer_->digest ()), |
761 | 0 | direction (buffer_->props.direction), |
762 | 0 | has_glyph_classes (gdef.has_glyph_classes ()) |
763 | 0 | { init_iters (); } |
764 | | |
765 | | ~hb_ot_apply_context_t () |
766 | 0 | { |
767 | 0 | #ifndef HB_NO_VAR |
768 | 0 | ItemVariationStore::destroy_cache (var_store_cache); |
769 | 0 | #endif |
770 | 0 | } |
771 | | |
772 | | void init_iters () |
773 | 0 | { |
774 | 0 | iter_input.init (this, false); |
775 | 0 | iter_context.init (this, true); |
776 | 0 | } |
777 | | |
778 | 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 (); } |
779 | 0 | void set_auto_zwj (bool auto_zwj_, bool init = true) { auto_zwj = auto_zwj_; if (init) init_iters (); } |
780 | 0 | void set_auto_zwnj (bool auto_zwnj_, bool init = true) { auto_zwnj = auto_zwnj_; if (init) init_iters (); } |
781 | 0 | void set_per_syllable (bool per_syllable_, bool init = true) { per_syllable = per_syllable_; if (init) init_iters (); } |
782 | 0 | void set_random (bool random_) { random = random_; } |
783 | 0 | void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
784 | 0 | void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; } |
785 | 0 | void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; init_iters (); } |
786 | | |
787 | | uint32_t random_number () |
788 | 0 | { |
789 | | /* http://www.cplusplus.com/reference/random/minstd_rand/ */ |
790 | 0 | buffer->random_state = buffer->random_state * 48271 % 2147483647; |
791 | 0 | return buffer->random_state; |
792 | 0 | } |
793 | | |
794 | | bool match_properties_mark (hb_codepoint_t glyph, |
795 | | unsigned int glyph_props, |
796 | | unsigned int match_props) const |
797 | 0 | { |
798 | | /* If using mark filtering sets, the high short of |
799 | | * match_props has the set index. |
800 | | */ |
801 | 0 | if (match_props & LookupFlag::UseMarkFilteringSet) |
802 | 0 | return gdef_accel.mark_set_covers (match_props >> 16, glyph); |
803 | | |
804 | | /* The second byte of match_props has the meaning |
805 | | * "ignore marks of attachment type different than |
806 | | * the attachment type specified." |
807 | | */ |
808 | 0 | if (match_props & LookupFlag::MarkAttachmentType) |
809 | 0 | return (match_props & LookupFlag::MarkAttachmentType) == (glyph_props & LookupFlag::MarkAttachmentType); |
810 | | |
811 | 0 | return true; |
812 | 0 | } |
813 | | |
814 | | #ifndef HB_OPTIMIZE_SIZE |
815 | | HB_ALWAYS_INLINE |
816 | | #endif |
817 | | bool check_glyph_property (const hb_glyph_info_t *info, |
818 | | unsigned int match_props) const |
819 | 0 | { |
820 | 0 | unsigned int glyph_props = _hb_glyph_info_get_glyph_props (info); |
821 | | |
822 | | /* Not covered, if, for example, glyph class is ligature and |
823 | | * match_props includes LookupFlags::IgnoreLigatures |
824 | | */ |
825 | 0 | if (glyph_props & match_props & LookupFlag::IgnoreFlags) |
826 | 0 | return false; |
827 | | |
828 | 0 | if (unlikely (glyph_props & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) |
829 | 0 | return match_properties_mark (info->codepoint, glyph_props, match_props); |
830 | | |
831 | 0 | return true; |
832 | 0 | } |
833 | | |
834 | | void _set_glyph_class (hb_codepoint_t glyph_index, |
835 | | unsigned int class_guess = 0, |
836 | | bool ligature = false, |
837 | | bool component = false) |
838 | 0 | { |
839 | 0 | digest.add (glyph_index); |
840 | |
|
841 | 0 | if (new_syllables != (unsigned) -1) |
842 | 0 | buffer->cur().syllable() = new_syllables; |
843 | |
|
844 | 0 | unsigned int props = _hb_glyph_info_get_glyph_props (&buffer->cur()); |
845 | 0 | props |= HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED; |
846 | 0 | if (ligature) |
847 | 0 | { |
848 | 0 | props |= HB_OT_LAYOUT_GLYPH_PROPS_LIGATED; |
849 | | /* In the only place that the MULTIPLIED bit is used, Uniscribe |
850 | | * seems to only care about the "last" transformation between |
851 | | * Ligature and Multiple substitutions. Ie. if you ligate, expand, |
852 | | * and ligate again, it forgives the multiplication and acts as |
853 | | * if only ligation happened. As such, clear MULTIPLIED bit. |
854 | | */ |
855 | 0 | props &= ~HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED; |
856 | 0 | } |
857 | 0 | if (component) |
858 | 0 | props |= HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED; |
859 | 0 | if (likely (has_glyph_classes)) |
860 | 0 | { |
861 | 0 | props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE; |
862 | 0 | _hb_glyph_info_set_glyph_props (&buffer->cur(), props | gdef_accel.get_glyph_props (glyph_index)); |
863 | 0 | } |
864 | 0 | else if (class_guess) |
865 | 0 | { |
866 | 0 | props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE; |
867 | 0 | _hb_glyph_info_set_glyph_props (&buffer->cur(), props | class_guess); |
868 | 0 | } |
869 | 0 | else |
870 | 0 | _hb_glyph_info_set_glyph_props (&buffer->cur(), props); |
871 | 0 | } |
872 | | |
873 | | void replace_glyph (hb_codepoint_t glyph_index) |
874 | 0 | { |
875 | 0 | _set_glyph_class (glyph_index); |
876 | 0 | (void) buffer->replace_glyph (glyph_index); |
877 | 0 | } |
878 | | void replace_glyph_inplace (hb_codepoint_t glyph_index) |
879 | 0 | { |
880 | 0 | _set_glyph_class (glyph_index); |
881 | 0 | buffer->cur().codepoint = glyph_index; |
882 | 0 | } |
883 | | void replace_glyph_with_ligature (hb_codepoint_t glyph_index, |
884 | | unsigned int class_guess) |
885 | 0 | { |
886 | 0 | _set_glyph_class (glyph_index, class_guess, true); |
887 | 0 | (void) buffer->replace_glyph (glyph_index); |
888 | 0 | } |
889 | | void output_glyph_for_component (hb_codepoint_t glyph_index, |
890 | | unsigned int class_guess) |
891 | 0 | { |
892 | 0 | _set_glyph_class (glyph_index, class_guess, false, true); |
893 | 0 | (void) buffer->output_glyph (glyph_index); |
894 | 0 | } |
895 | | }; |
896 | | |
897 | | |
898 | | struct hb_accelerate_subtables_context_t : |
899 | | hb_dispatch_context_t<hb_accelerate_subtables_context_t> |
900 | | { |
901 | | template <typename Type> |
902 | | static inline bool apply_to (const void *obj, hb_ot_apply_context_t *c) |
903 | 0 | { |
904 | 0 | const Type *typed_obj = (const Type *) obj; |
905 | 0 | return typed_obj->apply (c); |
906 | 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*) |
907 | | |
908 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
909 | | template <typename T> |
910 | | static inline auto apply_cached_ (const T *obj, hb_ot_apply_context_t *c, hb_priority<1>) HB_RETURN (bool, obj->apply_cached (c) ) |
911 | | template <typename T> |
912 | | static inline auto apply_cached_ (const T *obj, hb_ot_apply_context_t *c, hb_priority<0>) HB_RETURN (bool, obj->apply (c) ) |
913 | | template <typename Type> |
914 | | static inline bool apply_cached_to (const void *obj, hb_ot_apply_context_t *c) |
915 | 0 | { |
916 | 0 | const Type *typed_obj = (const Type *) obj; |
917 | 0 | return apply_cached_ (typed_obj, c, hb_prioritize); |
918 | 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*) |
919 | | |
920 | | template <typename T> |
921 | | 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) ) |
922 | | template <typename T> |
923 | 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>) |
924 | | template <typename Type> |
925 | | static inline bool cache_func_to (const void *obj, hb_ot_apply_context_t *c, bool enter) |
926 | 0 | { |
927 | 0 | const Type *typed_obj = (const Type *) obj; |
928 | 0 | return cache_func_ (typed_obj, c, enter, hb_prioritize); |
929 | 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) |
930 | | #endif |
931 | | |
932 | | typedef bool (*hb_apply_func_t) (const void *obj, hb_ot_apply_context_t *c); |
933 | | typedef bool (*hb_cache_func_t) (const void *obj, hb_ot_apply_context_t *c, bool enter); |
934 | | |
935 | | struct hb_applicable_t |
936 | | { |
937 | | friend struct hb_accelerate_subtables_context_t; |
938 | | friend struct hb_ot_layout_lookup_accelerator_t; |
939 | | |
940 | | template <typename T> |
941 | | void init (const T &obj_, |
942 | | hb_apply_func_t apply_func_ |
943 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
944 | | , hb_apply_func_t apply_cached_func_ |
945 | | , hb_cache_func_t cache_func_ |
946 | | #endif |
947 | | ) |
948 | 0 | { |
949 | 0 | obj = &obj_; |
950 | 0 | apply_func = apply_func_; |
951 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
952 | 0 | apply_cached_func = apply_cached_func_; |
953 | 0 | cache_func = cache_func_; |
954 | 0 | #endif |
955 | 0 | digest.init (); |
956 | 0 | obj_.get_coverage ().collect_coverage (&digest); |
957 | 0 | } 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)) Unexecuted instantiation: 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)) Unexecuted instantiation: 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)) Unexecuted instantiation: 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)) 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)) Unexecuted instantiation: 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)) 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)) Unexecuted instantiation: 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)) 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)) |
958 | | |
959 | | bool apply (hb_ot_apply_context_t *c) const |
960 | 0 | { |
961 | 0 | return digest.may_have (c->buffer->cur().codepoint) && apply_func (obj, c); |
962 | 0 | } |
963 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
964 | | bool apply_cached (hb_ot_apply_context_t *c) const |
965 | 0 | { |
966 | 0 | return digest.may_have (c->buffer->cur().codepoint) && apply_cached_func (obj, c); |
967 | 0 | } |
968 | | bool cache_enter (hb_ot_apply_context_t *c) const |
969 | 0 | { |
970 | 0 | return cache_func (obj, c, true); |
971 | 0 | } |
972 | | void cache_leave (hb_ot_apply_context_t *c) const |
973 | 0 | { |
974 | 0 | cache_func (obj, c, false); |
975 | 0 | } |
976 | | #endif |
977 | | |
978 | | private: |
979 | | const void *obj; |
980 | | hb_apply_func_t apply_func; |
981 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
982 | | hb_apply_func_t apply_cached_func; |
983 | | hb_cache_func_t cache_func; |
984 | | #endif |
985 | | hb_set_digest_t digest; |
986 | | }; |
987 | | |
988 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
989 | | template <typename T> |
990 | | auto cache_cost (const T &obj, hb_priority<1>) HB_AUTO_RETURN ( obj.cache_cost () ) |
991 | | template <typename T> |
992 | | auto cache_cost (const T &obj, hb_priority<0>) HB_AUTO_RETURN ( 0u ) |
993 | | #endif |
994 | | |
995 | | /* Dispatch interface. */ |
996 | | template <typename T> |
997 | | return_t dispatch (const T &obj) |
998 | 0 | { |
999 | 0 | hb_applicable_t *entry = &array[i++]; |
1000 | |
|
1001 | 0 | entry->init (obj, |
1002 | 0 | apply_to<T> |
1003 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
1004 | 0 | , apply_cached_to<T> |
1005 | 0 | , cache_func_to<T> |
1006 | 0 | #endif |
1007 | 0 | ); |
1008 | |
|
1009 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
1010 | | /* Cache handling |
1011 | | * |
1012 | | * We allow one subtable from each lookup to use a cache. The assumption |
1013 | | * being that multiple subtables of the same lookup cannot use a cache |
1014 | | * because the resources they would use will collide. As such, we ask |
1015 | | * each subtable to tell us how much it costs (which a cache would avoid), |
1016 | | * and we allocate the cache opportunity to the costliest subtable. |
1017 | | */ |
1018 | 0 | unsigned cost = cache_cost (obj, hb_prioritize); |
1019 | 0 | if (cost > cache_user_cost) |
1020 | 0 | { |
1021 | 0 | cache_user_idx = i - 1; |
1022 | 0 | cache_user_cost = cost; |
1023 | 0 | } |
1024 | 0 | #endif |
1025 | |
|
1026 | 0 | return hb_empty_t (); |
1027 | 0 | } 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&) Unexecuted instantiation: 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&) Unexecuted instantiation: 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&) Unexecuted instantiation: 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&) 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&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&) 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&) Unexecuted instantiation: 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&) Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&) |
1028 | 0 | static return_t default_return_value () { return hb_empty_t (); } |
1029 | | |
1030 | | hb_accelerate_subtables_context_t (hb_applicable_t *array_) : |
1031 | 0 | array (array_) {} |
1032 | | |
1033 | | hb_applicable_t *array; |
1034 | | unsigned i = 0; |
1035 | | |
1036 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
1037 | | unsigned cache_user_idx = (unsigned) -1; |
1038 | | unsigned cache_user_cost = 0; |
1039 | | #endif |
1040 | | }; |
1041 | | |
1042 | | |
1043 | | typedef bool (*intersects_func_t) (const hb_set_t *glyphs, unsigned value, const void *data, void *cache); |
1044 | | typedef void (*intersected_glyphs_func_t) (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, void *cache); |
1045 | | typedef void (*collect_glyphs_func_t) (hb_set_t *glyphs, unsigned value, const void *data); |
1046 | | typedef bool (*match_func_t) (hb_glyph_info_t &info, unsigned value, const void *data); |
1047 | | |
1048 | | struct ContextClosureFuncs |
1049 | | { |
1050 | | intersects_func_t intersects; |
1051 | | intersected_glyphs_func_t intersected_glyphs; |
1052 | | }; |
1053 | | struct ContextCollectGlyphsFuncs |
1054 | | { |
1055 | | collect_glyphs_func_t collect; |
1056 | | }; |
1057 | | struct ContextApplyFuncs |
1058 | | { |
1059 | | match_func_t match; |
1060 | | }; |
1061 | | struct ChainContextApplyFuncs |
1062 | | { |
1063 | | match_func_t match[3]; |
1064 | | }; |
1065 | | |
1066 | | |
1067 | | static inline bool intersects_glyph (const hb_set_t *glyphs, unsigned value, const void *data HB_UNUSED, void *cache HB_UNUSED) |
1068 | 0 | { |
1069 | 0 | return glyphs->has (value); |
1070 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1071 | | static inline bool intersects_class (const hb_set_t *glyphs, unsigned value, const void *data, void *cache) |
1072 | 0 | { |
1073 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1074 | 0 | hb_map_t *map = (hb_map_t *) cache; |
1075 | |
|
1076 | 0 | hb_codepoint_t *cached_v; |
1077 | 0 | if (map->has (value, &cached_v)) |
1078 | 0 | return *cached_v; |
1079 | | |
1080 | 0 | bool v = class_def.intersects_class (glyphs, value); |
1081 | 0 | map->set (value, v); |
1082 | |
|
1083 | 0 | return v; |
1084 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1085 | | static inline bool intersects_coverage (const hb_set_t *glyphs, unsigned value, const void *data, void *cache HB_UNUSED) |
1086 | 0 | { |
1087 | 0 | Offset16To<Coverage> coverage; |
1088 | 0 | coverage = value; |
1089 | 0 | return (data+coverage).intersects (glyphs); |
1090 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1091 | | |
1092 | | |
1093 | | 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) |
1094 | 0 | { |
1095 | 0 | unsigned g = reinterpret_cast<const HBUINT16 *>(data)[value]; |
1096 | 0 | intersected_glyphs->add (g); |
1097 | 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-ot-layout.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-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*) |
1098 | | |
1099 | | using intersected_class_cache_t = hb_hashmap_t<unsigned, hb_set_t>; |
1100 | | |
1101 | | static inline void intersected_class_glyphs (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, void *cache) |
1102 | 0 | { |
1103 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1104 | |
|
1105 | 0 | intersected_class_cache_t *map = (intersected_class_cache_t *) cache; |
1106 | |
|
1107 | 0 | hb_set_t *cached_v; |
1108 | 0 | if (map->has (value, &cached_v)) |
1109 | 0 | { |
1110 | 0 | intersected_glyphs->union_ (*cached_v); |
1111 | 0 | return; |
1112 | 0 | } |
1113 | | |
1114 | 0 | hb_set_t v; |
1115 | 0 | class_def.intersected_class_glyphs (glyphs, value, &v); |
1116 | |
|
1117 | 0 | intersected_glyphs->union_ (v); |
1118 | |
|
1119 | 0 | map->set (value, std::move (v)); |
1120 | 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-ot-layout.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-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*) |
1121 | | |
1122 | | 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) |
1123 | 0 | { |
1124 | 0 | Offset16To<Coverage> coverage; |
1125 | 0 | coverage = value; |
1126 | 0 | (data+coverage).intersect_set (*glyphs, *intersected_glyphs); |
1127 | 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-ot-layout.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-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*) |
1128 | | |
1129 | | |
1130 | | template <typename HBUINT> |
1131 | | static inline bool array_is_subset_of (const hb_set_t *glyphs, |
1132 | | unsigned int count, |
1133 | | const HBUINT values[], |
1134 | | intersects_func_t intersects_func, |
1135 | | const void *intersects_data, |
1136 | | void *cache) |
1137 | 0 | { |
1138 | 0 | for (const auto &_ : + hb_iter (values, count)) |
1139 | 0 | if (!intersects_func (glyphs, _, intersects_data, cache)) return false; |
1140 | 0 | return true; |
1141 | 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-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-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-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*) |
1142 | | |
1143 | | |
1144 | | static inline void collect_glyph (hb_set_t *glyphs, unsigned value, const void *data HB_UNUSED) |
1145 | 0 | { |
1146 | 0 | glyphs->add (value); |
1147 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1148 | | static inline void collect_class (hb_set_t *glyphs, unsigned value, const void *data) |
1149 | 0 | { |
1150 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1151 | 0 | class_def.collect_class (glyphs, value); |
1152 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1153 | | static inline void collect_coverage (hb_set_t *glyphs, unsigned value, const void *data) |
1154 | 0 | { |
1155 | 0 | Offset16To<Coverage> coverage; |
1156 | 0 | coverage = value; |
1157 | 0 | (data+coverage).collect_coverage (glyphs); |
1158 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1159 | | template <typename HBUINT> |
1160 | | static inline void collect_array (hb_collect_glyphs_context_t *c HB_UNUSED, |
1161 | | hb_set_t *glyphs, |
1162 | | unsigned int count, |
1163 | | const HBUINT values[], |
1164 | | collect_glyphs_func_t collect_func, |
1165 | | const void *collect_data) |
1166 | 0 | { |
1167 | 0 | return |
1168 | 0 | + hb_iter (values, count) |
1169 | 0 | | hb_apply ([&] (const HBUINT &_) { collect_func (glyphs, _, collect_data); }) |
1170 | 0 | ; |
1171 | 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-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-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-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*) |
1172 | | |
1173 | | |
1174 | | static inline bool match_always (hb_glyph_info_t &info HB_UNUSED, unsigned value HB_UNUSED, const void *data HB_UNUSED) |
1175 | 0 | { |
1176 | 0 | return true; |
1177 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1178 | | static inline bool match_glyph (hb_glyph_info_t &info, unsigned value, const void *data HB_UNUSED) |
1179 | 0 | { |
1180 | 0 | return info.codepoint == value; |
1181 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1182 | | static inline bool match_class (hb_glyph_info_t &info, unsigned value, const void *data) |
1183 | 0 | { |
1184 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1185 | 0 | return class_def.get_class (info.codepoint) == value; |
1186 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1187 | | static inline bool match_class_cached (hb_glyph_info_t &info, unsigned value, const void *data) |
1188 | 0 | { |
1189 | 0 | unsigned klass = info.syllable(); |
1190 | 0 | if (klass < 255) |
1191 | 0 | return klass == value; |
1192 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1193 | 0 | klass = class_def.get_class (info.codepoint); |
1194 | 0 | if (likely (klass < 255)) |
1195 | 0 | info.syllable() = klass; |
1196 | 0 | return klass == value; |
1197 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1198 | | static inline bool match_class_cached1 (hb_glyph_info_t &info, unsigned value, const void *data) |
1199 | 0 | { |
1200 | 0 | unsigned klass = info.syllable() & 0x0F; |
1201 | 0 | if (klass < 15) |
1202 | 0 | return klass == value; |
1203 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1204 | 0 | klass = class_def.get_class (info.codepoint); |
1205 | 0 | if (likely (klass < 15)) |
1206 | 0 | info.syllable() = (info.syllable() & 0xF0) | klass; |
1207 | 0 | return klass == value; |
1208 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1209 | | static inline bool match_class_cached2 (hb_glyph_info_t &info, unsigned value, const void *data) |
1210 | 0 | { |
1211 | 0 | unsigned klass = (info.syllable() & 0xF0) >> 4; |
1212 | 0 | if (klass < 15) |
1213 | 0 | return klass == value; |
1214 | 0 | const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); |
1215 | 0 | klass = class_def.get_class (info.codepoint); |
1216 | 0 | if (likely (klass < 15)) |
1217 | 0 | info.syllable() = (info.syllable() & 0x0F) | (klass << 4); |
1218 | 0 | return klass == value; |
1219 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1220 | | static inline bool match_coverage (hb_glyph_info_t &info, unsigned value, const void *data) |
1221 | 0 | { |
1222 | 0 | Offset16To<Coverage> coverage; |
1223 | 0 | coverage = value; |
1224 | 0 | return (data+coverage).get_coverage (info.codepoint) != NOT_COVERED; |
1225 | 0 | } Unexecuted instantiation: hb-ot-face.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-aat-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*) |
1226 | | |
1227 | | template <typename HBUINT> |
1228 | | static inline bool would_match_input (hb_would_apply_context_t *c, |
1229 | | unsigned int count, /* Including the first glyph (not matched) */ |
1230 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1231 | | match_func_t match_func, |
1232 | | const void *match_data) |
1233 | 0 | { |
1234 | 0 | if (count != c->len) |
1235 | 0 | return false; |
1236 | | |
1237 | 0 | for (unsigned int i = 1; i < count; i++) |
1238 | 0 | { |
1239 | 0 | hb_glyph_info_t info; |
1240 | 0 | info.codepoint = c->glyphs[i]; |
1241 | 0 | if (likely (!match_func (info, input[i - 1], match_data))) |
1242 | 0 | return false; |
1243 | 0 | } |
1244 | | |
1245 | 0 | return true; |
1246 | 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-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-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-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*) |
1247 | | template <typename HBUINT> |
1248 | | #ifndef HB_OPTIMIZE_SIZE |
1249 | | HB_ALWAYS_INLINE |
1250 | | #endif |
1251 | | static bool match_input (hb_ot_apply_context_t *c, |
1252 | | unsigned int count, /* Including the first glyph (not matched) */ |
1253 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1254 | | match_func_t match_func, |
1255 | | const void *match_data, |
1256 | | unsigned int *end_position, |
1257 | | unsigned int match_positions[HB_MAX_CONTEXT_LENGTH], |
1258 | | unsigned int *p_total_component_count = nullptr) |
1259 | 0 | { |
1260 | 0 | TRACE_APPLY (nullptr); |
1261 | |
|
1262 | 0 | if (unlikely (count > HB_MAX_CONTEXT_LENGTH)) return_trace (false); |
1263 | | |
1264 | 0 | hb_buffer_t *buffer = c->buffer; |
1265 | |
|
1266 | 0 | hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; |
1267 | 0 | skippy_iter.reset (buffer->idx); |
1268 | 0 | skippy_iter.set_match_func (match_func, match_data); |
1269 | 0 | skippy_iter.set_glyph_data (input); |
1270 | | |
1271 | | /* |
1272 | | * This is perhaps the trickiest part of OpenType... Remarks: |
1273 | | * |
1274 | | * - If all components of the ligature were marks, we call this a mark ligature. |
1275 | | * |
1276 | | * - If there is no GDEF, and the ligature is NOT a mark ligature, we categorize |
1277 | | * it as a ligature glyph. |
1278 | | * |
1279 | | * - Ligatures cannot be formed across glyphs attached to different components |
1280 | | * of previous ligatures. Eg. the sequence is LAM,SHADDA,LAM,FATHA,HEH, and |
1281 | | * LAM,LAM,HEH form a ligature, leaving SHADDA,FATHA next to eachother. |
1282 | | * However, it would be wrong to ligate that SHADDA,FATHA sequence. |
1283 | | * There are a couple of exceptions to this: |
1284 | | * |
1285 | | * o If a ligature tries ligating with marks that belong to it itself, go ahead, |
1286 | | * assuming that the font designer knows what they are doing (otherwise it can |
1287 | | * break Indic stuff when a matra wants to ligate with a conjunct, |
1288 | | * |
1289 | | * o If two marks want to ligate and they belong to different components of the |
1290 | | * same ligature glyph, and said ligature glyph is to be ignored according to |
1291 | | * mark-filtering rules, then allow. |
1292 | | * https://github.com/harfbuzz/harfbuzz/issues/545 |
1293 | | */ |
1294 | |
|
1295 | 0 | unsigned int total_component_count = 0; |
1296 | |
|
1297 | 0 | unsigned int first_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); |
1298 | 0 | unsigned int first_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); |
1299 | |
|
1300 | 0 | enum { |
1301 | 0 | LIGBASE_NOT_CHECKED, |
1302 | 0 | LIGBASE_MAY_NOT_SKIP, |
1303 | 0 | LIGBASE_MAY_SKIP |
1304 | 0 | } ligbase = LIGBASE_NOT_CHECKED; |
1305 | |
|
1306 | 0 | for (unsigned int i = 1; i < count; i++) |
1307 | 0 | { |
1308 | 0 | unsigned unsafe_to; |
1309 | 0 | if (!skippy_iter.next (&unsafe_to)) |
1310 | 0 | { |
1311 | 0 | *end_position = unsafe_to; |
1312 | 0 | return_trace (false); |
1313 | 0 | } |
1314 | | |
1315 | 0 | match_positions[i] = skippy_iter.idx; |
1316 | |
|
1317 | 0 | unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[skippy_iter.idx]); |
1318 | 0 | unsigned int this_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx]); |
1319 | |
|
1320 | 0 | if (first_lig_id && first_lig_comp) |
1321 | 0 | { |
1322 | | /* If first component was attached to a previous ligature component, |
1323 | | * all subsequent components should be attached to the same ligature |
1324 | | * component, otherwise we shouldn't ligate them... */ |
1325 | 0 | if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp) |
1326 | 0 | { |
1327 | | /* ...unless, we are attached to a base ligature and that base |
1328 | | * ligature is ignorable. */ |
1329 | 0 | if (ligbase == LIGBASE_NOT_CHECKED) |
1330 | 0 | { |
1331 | 0 | bool found = false; |
1332 | 0 | const auto *out = buffer->out_info; |
1333 | 0 | unsigned int j = buffer->out_len; |
1334 | 0 | while (j && _hb_glyph_info_get_lig_id (&out[j - 1]) == first_lig_id) |
1335 | 0 | { |
1336 | 0 | if (_hb_glyph_info_get_lig_comp (&out[j - 1]) == 0) |
1337 | 0 | { |
1338 | 0 | j--; |
1339 | 0 | found = true; |
1340 | 0 | break; |
1341 | 0 | } |
1342 | 0 | j--; |
1343 | 0 | } |
1344 | |
|
1345 | 0 | if (found && skippy_iter.may_skip (out[j]) == hb_ot_apply_context_t::matcher_t::SKIP_YES) |
1346 | 0 | ligbase = LIGBASE_MAY_SKIP; |
1347 | 0 | else |
1348 | 0 | ligbase = LIGBASE_MAY_NOT_SKIP; |
1349 | 0 | } |
1350 | |
|
1351 | 0 | if (ligbase == LIGBASE_MAY_NOT_SKIP) |
1352 | 0 | return_trace (false); |
1353 | 0 | } |
1354 | 0 | } |
1355 | 0 | else |
1356 | 0 | { |
1357 | | /* If first component was NOT attached to a previous ligature component, |
1358 | | * all subsequent components should also NOT be attached to any ligature |
1359 | | * component, unless they are attached to the first component itself! */ |
1360 | 0 | if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id)) |
1361 | 0 | return_trace (false); |
1362 | 0 | } |
1363 | | |
1364 | 0 | total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[skippy_iter.idx]); |
1365 | 0 | } |
1366 | | |
1367 | 0 | *end_position = skippy_iter.idx + 1; |
1368 | |
|
1369 | 0 | if (p_total_component_count) |
1370 | 0 | { |
1371 | 0 | total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur()); |
1372 | 0 | *p_total_component_count = total_component_count; |
1373 | 0 | } |
1374 | |
|
1375 | 0 | match_positions[0] = buffer->idx; |
1376 | |
|
1377 | 0 | return_trace (true); |
1378 | 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-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-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-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*) |
1379 | | static inline bool ligate_input (hb_ot_apply_context_t *c, |
1380 | | unsigned int count, /* Including the first glyph */ |
1381 | | const unsigned int match_positions[HB_MAX_CONTEXT_LENGTH], /* Including the first glyph */ |
1382 | | unsigned int match_end, |
1383 | | hb_codepoint_t lig_glyph, |
1384 | | unsigned int total_component_count) |
1385 | 0 | { |
1386 | 0 | TRACE_APPLY (nullptr); |
1387 | |
|
1388 | 0 | hb_buffer_t *buffer = c->buffer; |
1389 | |
|
1390 | 0 | buffer->merge_clusters (buffer->idx, match_end); |
1391 | | |
1392 | | /* - If a base and one or more marks ligate, consider that as a base, NOT |
1393 | | * ligature, such that all following marks can still attach to it. |
1394 | | * https://github.com/harfbuzz/harfbuzz/issues/1109 |
1395 | | * |
1396 | | * - If all components of the ligature were marks, we call this a mark ligature. |
1397 | | * If it *is* a mark ligature, we don't allocate a new ligature id, and leave |
1398 | | * the ligature to keep its old ligature id. This will allow it to attach to |
1399 | | * a base ligature in GPOS. Eg. if the sequence is: LAM,LAM,SHADDA,FATHA,HEH, |
1400 | | * and LAM,LAM,HEH for a ligature, they will leave SHADDA and FATHA with a |
1401 | | * ligature id and component value of 2. Then if SHADDA,FATHA form a ligature |
1402 | | * later, we don't want them to lose their ligature id/component, otherwise |
1403 | | * GPOS will fail to correctly position the mark ligature on top of the |
1404 | | * LAM,LAM,HEH ligature. See: |
1405 | | * https://bugzilla.gnome.org/show_bug.cgi?id=676343 |
1406 | | * |
1407 | | * - If a ligature is formed of components that some of which are also ligatures |
1408 | | * themselves, and those ligature components had marks attached to *their* |
1409 | | * components, we have to attach the marks to the new ligature component |
1410 | | * positions! Now *that*'s tricky! And these marks may be following the |
1411 | | * last component of the whole sequence, so we should loop forward looking |
1412 | | * for them and update them. |
1413 | | * |
1414 | | * Eg. the sequence is LAM,LAM,SHADDA,FATHA,HEH, and the font first forms a |
1415 | | * 'calt' ligature of LAM,HEH, leaving the SHADDA and FATHA with a ligature |
1416 | | * id and component == 1. Now, during 'liga', the LAM and the LAM-HEH ligature |
1417 | | * form a LAM-LAM-HEH ligature. We need to reassign the SHADDA and FATHA to |
1418 | | * the new ligature with a component value of 2. |
1419 | | * |
1420 | | * This in fact happened to a font... See: |
1421 | | * https://bugzilla.gnome.org/show_bug.cgi?id=437633 |
1422 | | */ |
1423 | |
|
1424 | 0 | bool is_base_ligature = _hb_glyph_info_is_base_glyph (&buffer->info[match_positions[0]]); |
1425 | 0 | bool is_mark_ligature = _hb_glyph_info_is_mark (&buffer->info[match_positions[0]]); |
1426 | 0 | for (unsigned int i = 1; i < count; i++) |
1427 | 0 | if (!_hb_glyph_info_is_mark (&buffer->info[match_positions[i]])) |
1428 | 0 | { |
1429 | 0 | is_base_ligature = false; |
1430 | 0 | is_mark_ligature = false; |
1431 | 0 | break; |
1432 | 0 | } |
1433 | 0 | bool is_ligature = !is_base_ligature && !is_mark_ligature; |
1434 | |
|
1435 | 0 | unsigned int klass = is_ligature ? HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE : 0; |
1436 | 0 | unsigned int lig_id = is_ligature ? _hb_allocate_lig_id (buffer) : 0; |
1437 | 0 | unsigned int last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); |
1438 | 0 | unsigned int last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur()); |
1439 | 0 | unsigned int components_so_far = last_num_components; |
1440 | |
|
1441 | 0 | if (is_ligature) |
1442 | 0 | { |
1443 | 0 | _hb_glyph_info_set_lig_props_for_ligature (&buffer->cur(), lig_id, total_component_count); |
1444 | 0 | if (_hb_glyph_info_get_general_category (&buffer->cur()) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) |
1445 | 0 | { |
1446 | 0 | _hb_glyph_info_set_general_category (&buffer->cur(), HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER); |
1447 | 0 | } |
1448 | 0 | } |
1449 | 0 | c->replace_glyph_with_ligature (lig_glyph, klass); |
1450 | |
|
1451 | 0 | for (unsigned int i = 1; i < count; i++) |
1452 | 0 | { |
1453 | 0 | while (buffer->idx < match_positions[i] && buffer->successful) |
1454 | 0 | { |
1455 | 0 | if (is_ligature) |
1456 | 0 | { |
1457 | 0 | unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); |
1458 | 0 | if (this_comp == 0) |
1459 | 0 | this_comp = last_num_components; |
1460 | 0 | unsigned int new_lig_comp = components_so_far - last_num_components + |
1461 | 0 | hb_min (this_comp, last_num_components); |
1462 | 0 | _hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, new_lig_comp); |
1463 | 0 | } |
1464 | 0 | (void) buffer->next_glyph (); |
1465 | 0 | } |
1466 | |
|
1467 | 0 | last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur()); |
1468 | 0 | last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur()); |
1469 | 0 | components_so_far += last_num_components; |
1470 | | |
1471 | | /* Skip the base glyph */ |
1472 | 0 | buffer->idx++; |
1473 | 0 | } |
1474 | |
|
1475 | 0 | if (!is_mark_ligature && last_lig_id) |
1476 | 0 | { |
1477 | | /* Re-adjust components for any marks following. */ |
1478 | 0 | for (unsigned i = buffer->idx; i < buffer->len; ++i) |
1479 | 0 | { |
1480 | 0 | if (last_lig_id != _hb_glyph_info_get_lig_id (&buffer->info[i])) break; |
1481 | | |
1482 | 0 | unsigned this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]); |
1483 | 0 | if (!this_comp) break; |
1484 | | |
1485 | 0 | unsigned new_lig_comp = components_so_far - last_num_components + |
1486 | 0 | hb_min (this_comp, last_num_components); |
1487 | 0 | _hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig_comp); |
1488 | 0 | } |
1489 | 0 | } |
1490 | 0 | return_trace (true); |
1491 | 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-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-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-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) |
1492 | | |
1493 | | template <typename HBUINT> |
1494 | | #ifndef HB_OPTIMIZE_SIZE |
1495 | | HB_ALWAYS_INLINE |
1496 | | #endif |
1497 | | static bool match_backtrack (hb_ot_apply_context_t *c, |
1498 | | unsigned int count, |
1499 | | const HBUINT backtrack[], |
1500 | | match_func_t match_func, |
1501 | | const void *match_data, |
1502 | | unsigned int *match_start) |
1503 | 0 | { |
1504 | 0 | TRACE_APPLY (nullptr); |
1505 | |
|
1506 | 0 | hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; |
1507 | 0 | skippy_iter.reset (c->buffer->backtrack_len ()); |
1508 | 0 | skippy_iter.set_match_func (match_func, match_data); |
1509 | 0 | skippy_iter.set_glyph_data (backtrack); |
1510 | |
|
1511 | 0 | for (unsigned int i = 0; i < count; i++) |
1512 | 0 | { |
1513 | 0 | unsigned unsafe_from; |
1514 | 0 | if (!skippy_iter.prev (&unsafe_from)) |
1515 | 0 | { |
1516 | 0 | *match_start = unsafe_from; |
1517 | 0 | return_trace (false); |
1518 | 0 | } |
1519 | 0 | } |
1520 | | |
1521 | 0 | *match_start = skippy_iter.idx; |
1522 | 0 | return_trace (true); |
1523 | 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-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-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-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*) |
1524 | | |
1525 | | template <typename HBUINT> |
1526 | | #ifndef HB_OPTIMIZE_SIZE |
1527 | | HB_ALWAYS_INLINE |
1528 | | #endif |
1529 | | static bool match_lookahead (hb_ot_apply_context_t *c, |
1530 | | unsigned int count, |
1531 | | const HBUINT lookahead[], |
1532 | | match_func_t match_func, |
1533 | | const void *match_data, |
1534 | | unsigned int start_index, |
1535 | | unsigned int *end_index) |
1536 | 0 | { |
1537 | 0 | TRACE_APPLY (nullptr); |
1538 | |
|
1539 | 0 | hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_context; |
1540 | 0 | skippy_iter.reset (start_index - 1); |
1541 | 0 | skippy_iter.set_match_func (match_func, match_data); |
1542 | 0 | skippy_iter.set_glyph_data (lookahead); |
1543 | |
|
1544 | 0 | for (unsigned int i = 0; i < count; i++) |
1545 | 0 | { |
1546 | 0 | unsigned unsafe_to; |
1547 | 0 | if (!skippy_iter.next (&unsafe_to)) |
1548 | 0 | { |
1549 | 0 | *end_index = unsafe_to; |
1550 | 0 | return_trace (false); |
1551 | 0 | } |
1552 | 0 | } |
1553 | | |
1554 | 0 | *end_index = skippy_iter.idx + 1; |
1555 | 0 | return_trace (true); |
1556 | 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-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-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-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*) |
1557 | | |
1558 | | |
1559 | | |
1560 | | struct LookupRecord |
1561 | | { |
1562 | | bool serialize (hb_serialize_context_t *c, |
1563 | | const hb_map_t *lookup_map) const |
1564 | 0 | { |
1565 | 0 | TRACE_SERIALIZE (this); |
1566 | 0 | auto *out = c->embed (*this); |
1567 | 0 | if (unlikely (!out)) return_trace (false); |
1568 | 0 |
|
1569 | 0 | return_trace (c->check_assign (out->lookupListIndex, lookup_map->get (lookupListIndex), HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
1570 | 0 | } |
1571 | | |
1572 | | bool sanitize (hb_sanitize_context_t *c) const |
1573 | 0 | { |
1574 | 0 | TRACE_SANITIZE (this); |
1575 | 0 | return_trace (c->check_struct (this)); |
1576 | 0 | } |
1577 | | |
1578 | | HBUINT16 sequenceIndex; /* Index into current glyph |
1579 | | * sequence--first glyph = 0 */ |
1580 | | HBUINT16 lookupListIndex; /* Lookup to apply to that |
1581 | | * position--zero--based */ |
1582 | | public: |
1583 | | DEFINE_SIZE_STATIC (4); |
1584 | | }; |
1585 | | |
1586 | | static unsigned serialize_lookuprecord_array (hb_serialize_context_t *c, |
1587 | | const hb_array_t<const LookupRecord> lookupRecords, |
1588 | | const hb_map_t *lookup_map) |
1589 | 0 | { |
1590 | 0 | unsigned count = 0; |
1591 | 0 | for (const LookupRecord& r : lookupRecords) |
1592 | 0 | { |
1593 | 0 | if (!lookup_map->has (r.lookupListIndex)) |
1594 | 0 | continue; |
1595 | 0 |
|
1596 | 0 | if (!r.serialize (c, lookup_map)) |
1597 | 0 | return 0; |
1598 | 0 |
|
1599 | 0 | count++; |
1600 | 0 | } |
1601 | 0 | return count; |
1602 | 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-ot-layout.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-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*) |
1603 | | |
1604 | | enum ContextFormat { SimpleContext = 1, ClassBasedContext = 2, CoverageBasedContext = 3 }; |
1605 | | |
1606 | | template <typename HBUINT> |
1607 | | static void context_closure_recurse_lookups (hb_closure_context_t *c, |
1608 | | unsigned inputCount, const HBUINT input[], |
1609 | | unsigned lookupCount, |
1610 | | const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */, |
1611 | | unsigned value, |
1612 | | ContextFormat context_format, |
1613 | | const void *data, |
1614 | | intersected_glyphs_func_t intersected_glyphs_func, |
1615 | | void *cache) |
1616 | 0 | { |
1617 | 0 | hb_set_t covered_seq_indicies; |
1618 | 0 | hb_set_t pos_glyphs; |
1619 | 0 | for (unsigned int i = 0; i < lookupCount; i++) |
1620 | 0 | { |
1621 | 0 | unsigned seqIndex = lookupRecord[i].sequenceIndex; |
1622 | 0 | if (seqIndex >= inputCount) continue; |
1623 | | |
1624 | 0 | bool has_pos_glyphs = false; |
1625 | |
|
1626 | 0 | if (!covered_seq_indicies.has (seqIndex)) |
1627 | 0 | { |
1628 | 0 | has_pos_glyphs = true; |
1629 | 0 | pos_glyphs.clear (); |
1630 | 0 | if (seqIndex == 0) |
1631 | 0 | { |
1632 | 0 | switch (context_format) { |
1633 | 0 | case ContextFormat::SimpleContext: |
1634 | 0 | pos_glyphs.add (value); |
1635 | 0 | break; |
1636 | 0 | case ContextFormat::ClassBasedContext: |
1637 | 0 | intersected_glyphs_func (&c->parent_active_glyphs (), data, value, &pos_glyphs, cache); |
1638 | 0 | break; |
1639 | 0 | case ContextFormat::CoverageBasedContext: |
1640 | 0 | pos_glyphs.set (c->parent_active_glyphs ()); |
1641 | 0 | break; |
1642 | 0 | } |
1643 | 0 | } |
1644 | 0 | else |
1645 | 0 | { |
1646 | 0 | const void *input_data = input; |
1647 | 0 | unsigned input_value = seqIndex - 1; |
1648 | 0 | if (context_format != ContextFormat::SimpleContext) |
1649 | 0 | { |
1650 | 0 | input_data = data; |
1651 | 0 | input_value = input[seqIndex - 1]; |
1652 | 0 | } |
1653 | |
|
1654 | 0 | intersected_glyphs_func (c->glyphs, input_data, input_value, &pos_glyphs, cache); |
1655 | 0 | } |
1656 | 0 | } |
1657 | | |
1658 | 0 | covered_seq_indicies.add (seqIndex); |
1659 | 0 | hb_set_t *cur_active_glyphs = c->push_cur_active_glyphs (); |
1660 | 0 | if (unlikely (!cur_active_glyphs)) |
1661 | 0 | return; |
1662 | 0 | if (has_pos_glyphs) { |
1663 | 0 | *cur_active_glyphs = std::move (pos_glyphs); |
1664 | 0 | } else { |
1665 | 0 | *cur_active_glyphs = *c->glyphs; |
1666 | 0 | } |
1667 | |
|
1668 | 0 | unsigned endIndex = inputCount; |
1669 | 0 | if (context_format == ContextFormat::CoverageBasedContext) |
1670 | 0 | endIndex += 1; |
1671 | |
|
1672 | 0 | c->recurse (lookupRecord[i].lookupListIndex, &covered_seq_indicies, seqIndex, endIndex); |
1673 | |
|
1674 | 0 | c->pop_cur_done_glyphs (); |
1675 | 0 | } |
1676 | 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-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-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-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*) |
1677 | | |
1678 | | template <typename context_t> |
1679 | | static inline void recurse_lookups (context_t *c, |
1680 | | unsigned int lookupCount, |
1681 | | const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */) |
1682 | 0 | { |
1683 | 0 | for (unsigned int i = 0; i < lookupCount; i++) |
1684 | 0 | c->recurse (lookupRecord[i].lookupListIndex); |
1685 | 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-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-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-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*) |
1686 | | |
1687 | | static inline void apply_lookup (hb_ot_apply_context_t *c, |
1688 | | unsigned int count, /* Including the first glyph */ |
1689 | | unsigned int match_positions[HB_MAX_CONTEXT_LENGTH], /* Including the first glyph */ |
1690 | | unsigned int lookupCount, |
1691 | | const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */ |
1692 | | unsigned int match_end) |
1693 | 0 | { |
1694 | 0 | hb_buffer_t *buffer = c->buffer; |
1695 | 0 | int end; |
1696 | | |
1697 | | /* All positions are distance from beginning of *output* buffer. |
1698 | | * Adjust. */ |
1699 | 0 | { |
1700 | 0 | unsigned int bl = buffer->backtrack_len (); |
1701 | 0 | end = bl + match_end - buffer->idx; |
1702 | |
|
1703 | 0 | int delta = bl - buffer->idx; |
1704 | | /* Convert positions to new indexing. */ |
1705 | 0 | for (unsigned int j = 0; j < count; j++) |
1706 | 0 | match_positions[j] += delta; |
1707 | 0 | } |
1708 | |
|
1709 | 0 | for (unsigned int i = 0; i < lookupCount && buffer->successful; i++) |
1710 | 0 | { |
1711 | 0 | unsigned int idx = lookupRecord[i].sequenceIndex; |
1712 | 0 | if (idx >= count) |
1713 | 0 | continue; |
1714 | | |
1715 | 0 | unsigned int orig_len = buffer->backtrack_len () + buffer->lookahead_len (); |
1716 | | |
1717 | | /* This can happen if earlier recursed lookups deleted many entries. */ |
1718 | 0 | if (unlikely (match_positions[idx] >= orig_len)) |
1719 | 0 | continue; |
1720 | | |
1721 | 0 | if (unlikely (!buffer->move_to (match_positions[idx]))) |
1722 | 0 | break; |
1723 | | |
1724 | 0 | if (unlikely (buffer->max_ops <= 0)) |
1725 | 0 | break; |
1726 | | |
1727 | 0 | if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ()) |
1728 | 0 | { |
1729 | 0 | if (buffer->have_output) |
1730 | 0 | c->buffer->sync_so_far (); |
1731 | 0 | c->buffer->message (c->font, |
1732 | 0 | "recursing to lookup %u at %u", |
1733 | 0 | (unsigned) lookupRecord[i].lookupListIndex, |
1734 | 0 | buffer->idx); |
1735 | 0 | } |
1736 | |
|
1737 | 0 | if (!c->recurse (lookupRecord[i].lookupListIndex)) |
1738 | 0 | continue; |
1739 | | |
1740 | 0 | if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ()) |
1741 | 0 | { |
1742 | 0 | if (buffer->have_output) |
1743 | 0 | c->buffer->sync_so_far (); |
1744 | 0 | c->buffer->message (c->font, |
1745 | 0 | "recursed to lookup %u", |
1746 | 0 | (unsigned) lookupRecord[i].lookupListIndex); |
1747 | 0 | } |
1748 | |
|
1749 | 0 | unsigned int new_len = buffer->backtrack_len () + buffer->lookahead_len (); |
1750 | 0 | int delta = new_len - orig_len; |
1751 | |
|
1752 | 0 | if (!delta) |
1753 | 0 | continue; |
1754 | | |
1755 | | /* Recursed lookup changed buffer len. Adjust. |
1756 | | * |
1757 | | * TODO: |
1758 | | * |
1759 | | * Right now, if buffer length increased by n, we assume n new glyphs |
1760 | | * were added right after the current position, and if buffer length |
1761 | | * was decreased by n, we assume n match positions after the current |
1762 | | * one where removed. The former (buffer length increased) case is |
1763 | | * fine, but the decrease case can be improved in at least two ways, |
1764 | | * both of which are significant: |
1765 | | * |
1766 | | * - If recursed-to lookup is MultipleSubst and buffer length |
1767 | | * decreased, then it's current match position that was deleted, |
1768 | | * NOT the one after it. |
1769 | | * |
1770 | | * - If buffer length was decreased by n, it does not necessarily |
1771 | | * mean that n match positions where removed, as there recursed-to |
1772 | | * lookup might had a different LookupFlag. Here's a constructed |
1773 | | * case of that: |
1774 | | * https://github.com/harfbuzz/harfbuzz/discussions/3538 |
1775 | | * |
1776 | | * It should be possible to construct tests for both of these cases. |
1777 | | */ |
1778 | | |
1779 | 0 | end += delta; |
1780 | 0 | if (end < int (match_positions[idx])) |
1781 | 0 | { |
1782 | | /* End might end up being smaller than match_positions[idx] if the recursed |
1783 | | * lookup ended up removing many items. |
1784 | | * Just never rewind end beyond start of current position, since that is |
1785 | | * not possible in the recursed lookup. Also adjust delta as such. |
1786 | | * |
1787 | | * https://bugs.chromium.org/p/chromium/issues/detail?id=659496 |
1788 | | * https://github.com/harfbuzz/harfbuzz/issues/1611 |
1789 | | */ |
1790 | 0 | delta += match_positions[idx] - end; |
1791 | 0 | end = match_positions[idx]; |
1792 | 0 | } |
1793 | |
|
1794 | 0 | unsigned int next = idx + 1; /* next now is the position after the recursed lookup. */ |
1795 | |
|
1796 | 0 | if (delta > 0) |
1797 | 0 | { |
1798 | 0 | if (unlikely (delta + count > HB_MAX_CONTEXT_LENGTH)) |
1799 | 0 | break; |
1800 | 0 | } |
1801 | 0 | else |
1802 | 0 | { |
1803 | | /* NOTE: delta is non-positive. */ |
1804 | 0 | delta = hb_max (delta, (int) next - (int) count); |
1805 | 0 | next -= delta; |
1806 | 0 | } |
1807 | | |
1808 | | /* Shift! */ |
1809 | 0 | memmove (match_positions + next + delta, match_positions + next, |
1810 | 0 | (count - next) * sizeof (match_positions[0])); |
1811 | 0 | next += delta; |
1812 | 0 | count += delta; |
1813 | | |
1814 | | /* Fill in new entries. */ |
1815 | 0 | for (unsigned int j = idx + 1; j < next; j++) |
1816 | 0 | match_positions[j] = match_positions[j - 1] + 1; |
1817 | | |
1818 | | /* And fixup the rest. */ |
1819 | 0 | for (; next < count; next++) |
1820 | 0 | match_positions[next] += delta; |
1821 | 0 | } |
1822 | |
|
1823 | 0 | (void) buffer->move_to (end); |
1824 | 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-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-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-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) |
1825 | | |
1826 | | |
1827 | | |
1828 | | /* Contextual lookups */ |
1829 | | |
1830 | | struct ContextClosureLookupContext |
1831 | | { |
1832 | | ContextClosureFuncs funcs; |
1833 | | ContextFormat context_format; |
1834 | | const void *intersects_data; |
1835 | | void *intersects_cache; |
1836 | | void *intersected_glyphs_cache; |
1837 | | }; |
1838 | | |
1839 | | struct ContextCollectGlyphsLookupContext |
1840 | | { |
1841 | | ContextCollectGlyphsFuncs funcs; |
1842 | | const void *collect_data; |
1843 | | }; |
1844 | | |
1845 | | struct ContextApplyLookupContext |
1846 | | { |
1847 | | ContextApplyFuncs funcs; |
1848 | | const void *match_data; |
1849 | | }; |
1850 | | |
1851 | | template <typename HBUINT> |
1852 | | static inline bool context_intersects (const hb_set_t *glyphs, |
1853 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1854 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1855 | | ContextClosureLookupContext &lookup_context) |
1856 | 0 | { |
1857 | 0 | return array_is_subset_of (glyphs, |
1858 | 0 | inputCount ? inputCount - 1 : 0, input, |
1859 | 0 | lookup_context.funcs.intersects, |
1860 | 0 | lookup_context.intersects_data, |
1861 | 0 | lookup_context.intersects_cache); |
1862 | 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-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-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-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&) |
1863 | | |
1864 | | template <typename HBUINT> |
1865 | | static inline void context_closure_lookup (hb_closure_context_t *c, |
1866 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1867 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1868 | | unsigned int lookupCount, |
1869 | | const LookupRecord lookupRecord[], |
1870 | | unsigned value, /* Index of first glyph in Coverage or Class value in ClassDef table */ |
1871 | | ContextClosureLookupContext &lookup_context) |
1872 | 0 | { |
1873 | 0 | if (context_intersects (c->glyphs, |
1874 | 0 | inputCount, input, |
1875 | 0 | lookup_context)) |
1876 | 0 | context_closure_recurse_lookups (c, |
1877 | 0 | inputCount, input, |
1878 | 0 | lookupCount, lookupRecord, |
1879 | 0 | value, |
1880 | 0 | lookup_context.context_format, |
1881 | 0 | lookup_context.intersects_data, |
1882 | 0 | lookup_context.funcs.intersected_glyphs, |
1883 | 0 | lookup_context.intersected_glyphs_cache); |
1884 | 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-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-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-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&) |
1885 | | |
1886 | | template <typename HBUINT> |
1887 | | static inline void context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c, |
1888 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1889 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1890 | | unsigned int lookupCount, |
1891 | | const LookupRecord lookupRecord[], |
1892 | | ContextCollectGlyphsLookupContext &lookup_context) |
1893 | 0 | { |
1894 | 0 | collect_array (c, c->input, |
1895 | 0 | inputCount ? inputCount - 1 : 0, input, |
1896 | 0 | lookup_context.funcs.collect, lookup_context.collect_data); |
1897 | 0 | recurse_lookups (c, |
1898 | 0 | lookupCount, lookupRecord); |
1899 | 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-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-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-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&) |
1900 | | |
1901 | | template <typename HBUINT> |
1902 | | static inline bool context_would_apply_lookup (hb_would_apply_context_t *c, |
1903 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1904 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1905 | | unsigned int lookupCount HB_UNUSED, |
1906 | | const LookupRecord lookupRecord[] HB_UNUSED, |
1907 | | const ContextApplyLookupContext &lookup_context) |
1908 | 0 | { |
1909 | 0 | return would_match_input (c, |
1910 | 0 | inputCount, input, |
1911 | 0 | lookup_context.funcs.match, lookup_context.match_data); |
1912 | 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-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-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-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&) |
1913 | | |
1914 | | template <typename HBUINT> |
1915 | | HB_ALWAYS_INLINE |
1916 | | static bool context_apply_lookup (hb_ot_apply_context_t *c, |
1917 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
1918 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
1919 | | unsigned int lookupCount, |
1920 | | const LookupRecord lookupRecord[], |
1921 | | const ContextApplyLookupContext &lookup_context) |
1922 | 0 | { |
1923 | 0 | unsigned match_end = 0; |
1924 | 0 | unsigned match_positions[HB_MAX_CONTEXT_LENGTH]; |
1925 | 0 | if (match_input (c, |
1926 | 0 | inputCount, input, |
1927 | 0 | lookup_context.funcs.match, lookup_context.match_data, |
1928 | 0 | &match_end, match_positions)) |
1929 | 0 | { |
1930 | 0 | c->buffer->unsafe_to_break (c->buffer->idx, match_end); |
1931 | 0 | apply_lookup (c, |
1932 | 0 | inputCount, match_positions, |
1933 | 0 | lookupCount, lookupRecord, |
1934 | 0 | match_end); |
1935 | 0 | return true; |
1936 | 0 | } |
1937 | 0 | else |
1938 | 0 | { |
1939 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, match_end); |
1940 | 0 | return false; |
1941 | 0 | } |
1942 | 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-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-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-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&) |
1943 | | |
1944 | | template <typename Types> |
1945 | | struct Rule |
1946 | | { |
1947 | | template <typename T> |
1948 | | friend struct RuleSet; |
1949 | | |
1950 | | bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const |
1951 | 0 | { |
1952 | 0 | return context_intersects (glyphs, |
1953 | 0 | inputCount, inputZ.arrayZ, |
1954 | 0 | lookup_context); |
1955 | 0 | } |
1956 | | |
1957 | | void closure (hb_closure_context_t *c, unsigned value, ContextClosureLookupContext &lookup_context) const |
1958 | 0 | { |
1959 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
1960 | | |
1961 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
1962 | 0 | (inputZ.as_array ((inputCount ? inputCount - 1 : 0))); |
1963 | 0 | context_closure_lookup (c, |
1964 | 0 | inputCount, inputZ.arrayZ, |
1965 | 0 | lookupCount, lookupRecord.arrayZ, |
1966 | 0 | value, lookup_context); |
1967 | 0 | } |
1968 | | |
1969 | | void closure_lookups (hb_closure_lookups_context_t *c, |
1970 | | ContextClosureLookupContext &lookup_context) const |
1971 | 0 | { |
1972 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
1973 | 0 | if (!intersects (c->glyphs, lookup_context)) return; |
1974 | 0 |
|
1975 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
1976 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
1977 | 0 | recurse_lookups (c, lookupCount, lookupRecord.arrayZ); |
1978 | 0 | } |
1979 | | |
1980 | | void collect_glyphs (hb_collect_glyphs_context_t *c, |
1981 | | ContextCollectGlyphsLookupContext &lookup_context) const |
1982 | 0 | { |
1983 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
1984 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
1985 | 0 | context_collect_glyphs_lookup (c, |
1986 | 0 | inputCount, inputZ.arrayZ, |
1987 | 0 | lookupCount, lookupRecord.arrayZ, |
1988 | 0 | lookup_context); |
1989 | 0 | } |
1990 | | |
1991 | | bool would_apply (hb_would_apply_context_t *c, |
1992 | | const ContextApplyLookupContext &lookup_context) const |
1993 | 0 | { |
1994 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
1995 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
1996 | 0 | return context_would_apply_lookup (c, |
1997 | 0 | inputCount, inputZ.arrayZ, |
1998 | 0 | lookupCount, lookupRecord.arrayZ, |
1999 | 0 | lookup_context); |
2000 | 0 | } |
2001 | | |
2002 | | bool apply (hb_ot_apply_context_t *c, |
2003 | | const ContextApplyLookupContext &lookup_context) const |
2004 | 0 | { |
2005 | 0 | TRACE_APPLY (this); |
2006 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2007 | 0 | (inputZ.as_array (inputCount ? inputCount - 1 : 0)); |
2008 | 0 | return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context)); |
2009 | 0 | } |
2010 | | |
2011 | | bool serialize (hb_serialize_context_t *c, |
2012 | | const hb_map_t *input_mapping, /* old->new glyphid or class mapping */ |
2013 | | const hb_map_t *lookup_map) const |
2014 | 0 | { |
2015 | 0 | TRACE_SERIALIZE (this); |
2016 | 0 | auto *out = c->start_embed (this); |
2017 | 0 | if (unlikely (!c->extend_min (out))) return_trace (false); |
2018 | 0 |
|
2019 | 0 | out->inputCount = inputCount; |
2020 | 0 | const auto input = inputZ.as_array (inputCount - 1); |
2021 | 0 | for (const auto org : input) |
2022 | 0 | { |
2023 | 0 | HBUINT16 d; |
2024 | 0 | d = input_mapping->get (org); |
2025 | 0 | c->copy (d); |
2026 | 0 | } |
2027 | 0 |
|
2028 | 0 | const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> |
2029 | 0 | (inputZ.as_array ((inputCount ? inputCount - 1 : 0))); |
2030 | 0 |
|
2031 | 0 | unsigned count = serialize_lookuprecord_array (c, lookupRecord.as_array (lookupCount), lookup_map); |
2032 | 0 | return_trace (c->check_assign (out->lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
2033 | 0 | } |
2034 | | |
2035 | | bool subset (hb_subset_context_t *c, |
2036 | | const hb_map_t *lookup_map, |
2037 | | const hb_map_t *klass_map = nullptr) const |
2038 | 0 | { |
2039 | 0 | TRACE_SUBSET (this); |
2040 | 0 | if (unlikely (!inputCount)) return_trace (false); |
2041 | 0 | const auto input = inputZ.as_array (inputCount - 1); |
2042 | 0 |
|
2043 | 0 | const hb_map_t *mapping = klass_map == nullptr ? c->plan->glyph_map : klass_map; |
2044 | 0 | if (!hb_all (input, mapping)) return_trace (false); |
2045 | 0 | return_trace (serialize (c->serializer, mapping, lookup_map)); |
2046 | 0 | } |
2047 | | |
2048 | | public: |
2049 | | bool sanitize (hb_sanitize_context_t *c) const |
2050 | 0 | { |
2051 | 0 | TRACE_SANITIZE (this); |
2052 | 0 | return_trace (c->check_struct (this) && |
2053 | 0 | hb_barrier () && |
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 | hb_barrier (); |
2830 | 0 | unsigned int count = glyphCount; |
2831 | 0 | if (unlikely (!count)) return_trace (false); /* We want to access coverageZ[0] freely. */ |
2832 | 0 | if (unlikely (!c->check_array (coverageZ.arrayZ, count))) return_trace (false); |
2833 | 0 | for (unsigned int i = 0; i < count; i++) |
2834 | 0 | if (unlikely (!coverageZ[i].sanitize (c, this))) return_trace (false); |
2835 | 0 | const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); |
2836 | 0 | return_trace (likely (c->check_array (lookupRecord, lookupCount))); |
2837 | 0 | } |
2838 | | |
2839 | | protected: |
2840 | | HBUINT16 format; /* Format identifier--format = 3 */ |
2841 | | HBUINT16 glyphCount; /* Number of glyphs in the input glyph |
2842 | | * sequence */ |
2843 | | HBUINT16 lookupCount; /* Number of LookupRecords */ |
2844 | | UnsizedArrayOf<Offset16To<Coverage>> |
2845 | | coverageZ; /* Array of offsets to Coverage |
2846 | | * table in glyph sequence order */ |
2847 | | /*UnsizedArrayOf<LookupRecord> |
2848 | | lookupRecordX;*/ /* Array of LookupRecords--in |
2849 | | * design order */ |
2850 | | public: |
2851 | | DEFINE_SIZE_ARRAY (6, coverageZ); |
2852 | | }; |
2853 | | |
2854 | | struct Context |
2855 | | { |
2856 | | template <typename context_t, typename ...Ts> |
2857 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
2858 | 0 | { |
2859 | 0 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); |
2860 | 0 | TRACE_DISPATCH (this, u.format); |
2861 | 0 | switch (u.format) { |
2862 | 0 | case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); |
2863 | 0 | case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); |
2864 | 0 | case 3: return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...)); |
2865 | | #ifndef HB_NO_BEYOND_64K |
2866 | | case 4: return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...)); |
2867 | | case 5: return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...)); |
2868 | | #endif |
2869 | 0 | default:return_trace (c->default_return_value ()); |
2870 | 0 | } |
2871 | 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 |
2872 | | |
2873 | | protected: |
2874 | | union { |
2875 | | HBUINT16 format; /* Format identifier */ |
2876 | | ContextFormat1_4<SmallTypes> format1; |
2877 | | ContextFormat2_5<SmallTypes> format2; |
2878 | | ContextFormat3 format3; |
2879 | | #ifndef HB_NO_BEYOND_64K |
2880 | | ContextFormat1_4<MediumTypes> format4; |
2881 | | ContextFormat2_5<MediumTypes> format5; |
2882 | | #endif |
2883 | | } u; |
2884 | | }; |
2885 | | |
2886 | | |
2887 | | /* Chaining Contextual lookups */ |
2888 | | |
2889 | | struct ChainContextClosureLookupContext |
2890 | | { |
2891 | | ContextClosureFuncs funcs; |
2892 | | ContextFormat context_format; |
2893 | | const void *intersects_data[3]; |
2894 | | void *intersects_cache[3]; |
2895 | | void *intersected_glyphs_cache; |
2896 | | }; |
2897 | | |
2898 | | struct ChainContextCollectGlyphsLookupContext |
2899 | | { |
2900 | | ContextCollectGlyphsFuncs funcs; |
2901 | | const void *collect_data[3]; |
2902 | | }; |
2903 | | |
2904 | | struct ChainContextApplyLookupContext |
2905 | | { |
2906 | | ChainContextApplyFuncs funcs; |
2907 | | const void *match_data[3]; |
2908 | | }; |
2909 | | |
2910 | | template <typename HBUINT> |
2911 | | static inline bool chain_context_intersects (const hb_set_t *glyphs, |
2912 | | unsigned int backtrackCount, |
2913 | | const HBUINT backtrack[], |
2914 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
2915 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
2916 | | unsigned int lookaheadCount, |
2917 | | const HBUINT lookahead[], |
2918 | | ChainContextClosureLookupContext &lookup_context) |
2919 | 0 | { |
2920 | 0 | return array_is_subset_of (glyphs, |
2921 | 0 | backtrackCount, backtrack, |
2922 | 0 | lookup_context.funcs.intersects, |
2923 | 0 | lookup_context.intersects_data[0], |
2924 | 0 | lookup_context.intersects_cache[0]) |
2925 | 0 | && array_is_subset_of (glyphs, |
2926 | 0 | inputCount ? inputCount - 1 : 0, input, |
2927 | 0 | lookup_context.funcs.intersects, |
2928 | 0 | lookup_context.intersects_data[1], |
2929 | 0 | lookup_context.intersects_cache[1]) |
2930 | 0 | && array_is_subset_of (glyphs, |
2931 | 0 | lookaheadCount, lookahead, |
2932 | 0 | lookup_context.funcs.intersects, |
2933 | 0 | lookup_context.intersects_data[2], |
2934 | 0 | lookup_context.intersects_cache[2]); |
2935 | 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-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-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-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&) |
2936 | | |
2937 | | template <typename HBUINT> |
2938 | | static inline void chain_context_closure_lookup (hb_closure_context_t *c, |
2939 | | unsigned int backtrackCount, |
2940 | | const HBUINT backtrack[], |
2941 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
2942 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
2943 | | unsigned int lookaheadCount, |
2944 | | const HBUINT lookahead[], |
2945 | | unsigned int lookupCount, |
2946 | | const LookupRecord lookupRecord[], |
2947 | | unsigned value, |
2948 | | ChainContextClosureLookupContext &lookup_context) |
2949 | 0 | { |
2950 | 0 | if (chain_context_intersects (c->glyphs, |
2951 | 0 | backtrackCount, backtrack, |
2952 | 0 | inputCount, input, |
2953 | 0 | lookaheadCount, lookahead, |
2954 | 0 | lookup_context)) |
2955 | 0 | context_closure_recurse_lookups (c, |
2956 | 0 | inputCount, input, |
2957 | 0 | lookupCount, lookupRecord, |
2958 | 0 | value, |
2959 | 0 | lookup_context.context_format, |
2960 | 0 | lookup_context.intersects_data[1], |
2961 | 0 | lookup_context.funcs.intersected_glyphs, |
2962 | 0 | lookup_context.intersected_glyphs_cache); |
2963 | 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-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-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-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&) |
2964 | | |
2965 | | template <typename HBUINT> |
2966 | | static inline void chain_context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c, |
2967 | | unsigned int backtrackCount, |
2968 | | const HBUINT backtrack[], |
2969 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
2970 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
2971 | | unsigned int lookaheadCount, |
2972 | | const HBUINT lookahead[], |
2973 | | unsigned int lookupCount, |
2974 | | const LookupRecord lookupRecord[], |
2975 | | ChainContextCollectGlyphsLookupContext &lookup_context) |
2976 | 0 | { |
2977 | 0 | collect_array (c, c->before, |
2978 | 0 | backtrackCount, backtrack, |
2979 | 0 | lookup_context.funcs.collect, lookup_context.collect_data[0]); |
2980 | 0 | collect_array (c, c->input, |
2981 | 0 | inputCount ? inputCount - 1 : 0, input, |
2982 | 0 | lookup_context.funcs.collect, lookup_context.collect_data[1]); |
2983 | 0 | collect_array (c, c->after, |
2984 | 0 | lookaheadCount, lookahead, |
2985 | 0 | lookup_context.funcs.collect, lookup_context.collect_data[2]); |
2986 | 0 | recurse_lookups (c, |
2987 | 0 | lookupCount, lookupRecord); |
2988 | 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-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-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-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&) |
2989 | | |
2990 | | template <typename HBUINT> |
2991 | | static inline bool chain_context_would_apply_lookup (hb_would_apply_context_t *c, |
2992 | | unsigned int backtrackCount, |
2993 | | const HBUINT backtrack[] HB_UNUSED, |
2994 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
2995 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
2996 | | unsigned int lookaheadCount, |
2997 | | const HBUINT lookahead[] HB_UNUSED, |
2998 | | unsigned int lookupCount HB_UNUSED, |
2999 | | const LookupRecord lookupRecord[] HB_UNUSED, |
3000 | | const ChainContextApplyLookupContext &lookup_context) |
3001 | 0 | { |
3002 | 0 | return (c->zero_context ? !backtrackCount && !lookaheadCount : true) |
3003 | 0 | && would_match_input (c, |
3004 | 0 | inputCount, input, |
3005 | 0 | lookup_context.funcs.match[1], lookup_context.match_data[1]); |
3006 | 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-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-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-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&) |
3007 | | |
3008 | | template <typename HBUINT> |
3009 | | HB_ALWAYS_INLINE |
3010 | | static bool chain_context_apply_lookup (hb_ot_apply_context_t *c, |
3011 | | unsigned int backtrackCount, |
3012 | | const HBUINT backtrack[], |
3013 | | unsigned int inputCount, /* Including the first glyph (not matched) */ |
3014 | | const HBUINT input[], /* Array of input values--start with second glyph */ |
3015 | | unsigned int lookaheadCount, |
3016 | | const HBUINT lookahead[], |
3017 | | unsigned int lookupCount, |
3018 | | const LookupRecord lookupRecord[], |
3019 | | const ChainContextApplyLookupContext &lookup_context) |
3020 | 0 | { |
3021 | 0 | unsigned end_index = c->buffer->idx; |
3022 | 0 | unsigned match_end = 0; |
3023 | 0 | unsigned match_positions[HB_MAX_CONTEXT_LENGTH]; |
3024 | 0 | if (!(match_input (c, |
3025 | 0 | inputCount, input, |
3026 | 0 | lookup_context.funcs.match[1], lookup_context.match_data[1], |
3027 | 0 | &match_end, match_positions) && (end_index = match_end) |
3028 | 0 | && match_lookahead (c, |
3029 | 0 | lookaheadCount, lookahead, |
3030 | 0 | lookup_context.funcs.match[2], lookup_context.match_data[2], |
3031 | 0 | match_end, &end_index))) |
3032 | 0 | { |
3033 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, end_index); |
3034 | 0 | return false; |
3035 | 0 | } |
3036 | | |
3037 | 0 | unsigned start_index = c->buffer->out_len; |
3038 | 0 | if (!match_backtrack (c, |
3039 | 0 | backtrackCount, backtrack, |
3040 | 0 | lookup_context.funcs.match[0], lookup_context.match_data[0], |
3041 | 0 | &start_index)) |
3042 | 0 | { |
3043 | 0 | c->buffer->unsafe_to_concat_from_outbuffer (start_index, end_index); |
3044 | 0 | return false; |
3045 | 0 | } |
3046 | | |
3047 | 0 | c->buffer->unsafe_to_break_from_outbuffer (start_index, end_index); |
3048 | 0 | apply_lookup (c, |
3049 | 0 | inputCount, match_positions, |
3050 | 0 | lookupCount, lookupRecord, |
3051 | 0 | match_end); |
3052 | 0 | return true; |
3053 | 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-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-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-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&) |
3054 | | |
3055 | | template <typename Types> |
3056 | | struct ChainRule |
3057 | | { |
3058 | | template <typename T> |
3059 | | friend struct ChainRuleSet; |
3060 | | |
3061 | | bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const |
3062 | 0 | { |
3063 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3064 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3065 | 0 | return chain_context_intersects (glyphs, |
3066 | 0 | backtrack.len, backtrack.arrayZ, |
3067 | 0 | input.lenP1, input.arrayZ, |
3068 | 0 | lookahead.len, lookahead.arrayZ, |
3069 | 0 | lookup_context); |
3070 | 0 | } |
3071 | | |
3072 | | void closure (hb_closure_context_t *c, unsigned value, |
3073 | | ChainContextClosureLookupContext &lookup_context) const |
3074 | 0 | { |
3075 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3076 | | |
3077 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3078 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3079 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3080 | 0 | chain_context_closure_lookup (c, |
3081 | 0 | backtrack.len, backtrack.arrayZ, |
3082 | 0 | input.lenP1, input.arrayZ, |
3083 | 0 | lookahead.len, lookahead.arrayZ, |
3084 | 0 | lookup.len, lookup.arrayZ, |
3085 | 0 | value, |
3086 | 0 | lookup_context); |
3087 | 0 | } |
3088 | | |
3089 | | void closure_lookups (hb_closure_lookups_context_t *c, |
3090 | | ChainContextClosureLookupContext &lookup_context) const |
3091 | 0 | { |
3092 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3093 | 0 | if (!intersects (c->glyphs, lookup_context)) return; |
3094 | 0 |
|
3095 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3096 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3097 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3098 | 0 | recurse_lookups (c, lookup.len, lookup.arrayZ); |
3099 | 0 | } |
3100 | | |
3101 | | void collect_glyphs (hb_collect_glyphs_context_t *c, |
3102 | | ChainContextCollectGlyphsLookupContext &lookup_context) const |
3103 | 0 | { |
3104 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3105 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3106 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3107 | 0 | chain_context_collect_glyphs_lookup (c, |
3108 | 0 | backtrack.len, backtrack.arrayZ, |
3109 | 0 | input.lenP1, input.arrayZ, |
3110 | 0 | lookahead.len, lookahead.arrayZ, |
3111 | 0 | lookup.len, lookup.arrayZ, |
3112 | 0 | lookup_context); |
3113 | 0 | } |
3114 | | |
3115 | | bool would_apply (hb_would_apply_context_t *c, |
3116 | | const ChainContextApplyLookupContext &lookup_context) const |
3117 | 0 | { |
3118 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3119 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3120 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3121 | 0 | return chain_context_would_apply_lookup (c, |
3122 | 0 | backtrack.len, backtrack.arrayZ, |
3123 | 0 | input.lenP1, input.arrayZ, |
3124 | 0 | lookahead.len, lookahead.arrayZ, lookup.len, |
3125 | 0 | lookup.arrayZ, lookup_context); |
3126 | 0 | } |
3127 | | |
3128 | | bool apply (hb_ot_apply_context_t *c, |
3129 | | const ChainContextApplyLookupContext &lookup_context) const |
3130 | 0 | { |
3131 | 0 | TRACE_APPLY (this); |
3132 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3133 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3134 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3135 | 0 | return_trace (chain_context_apply_lookup (c, |
3136 | 0 | backtrack.len, backtrack.arrayZ, |
3137 | 0 | input.lenP1, input.arrayZ, |
3138 | 0 | lookahead.len, lookahead.arrayZ, lookup.len, |
3139 | 0 | lookup.arrayZ, lookup_context)); |
3140 | 0 | } |
3141 | | |
3142 | | template<typename Iterator, |
3143 | | hb_requires (hb_is_iterator (Iterator))> |
3144 | | void serialize_array (hb_serialize_context_t *c, |
3145 | | HBUINT16 len, |
3146 | | Iterator it) const |
3147 | 0 | { |
3148 | 0 | c->copy (len); |
3149 | 0 | for (const auto g : it) |
3150 | 0 | c->copy ((HBUINT16) g); |
3151 | 0 | } |
3152 | | |
3153 | | bool serialize (hb_serialize_context_t *c, |
3154 | | const hb_map_t *lookup_map, |
3155 | | const hb_map_t *backtrack_map, |
3156 | | const hb_map_t *input_map = nullptr, |
3157 | | const hb_map_t *lookahead_map = nullptr) const |
3158 | 0 | { |
3159 | 0 | TRACE_SERIALIZE (this); |
3160 | 0 |
|
3161 | 0 | const hb_map_t *mapping = backtrack_map; |
3162 | 0 | serialize_array (c, backtrack.len, + backtrack.iter () |
3163 | 0 | | hb_map (mapping)); |
3164 | 0 |
|
3165 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3166 | 0 | if (input_map) mapping = input_map; |
3167 | 0 | serialize_array (c, input.lenP1, + input.iter () |
3168 | 0 | | hb_map (mapping)); |
3169 | 0 |
|
3170 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3171 | 0 | if (lookahead_map) mapping = lookahead_map; |
3172 | 0 | serialize_array (c, lookahead.len, + lookahead.iter () |
3173 | 0 | | hb_map (mapping)); |
3174 | 0 |
|
3175 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3176 | 0 |
|
3177 | 0 | HBUINT16* lookupCount = c->embed (&(lookup.len)); |
3178 | 0 | if (!lookupCount) return_trace (false); |
3179 | 0 |
|
3180 | 0 | unsigned count = serialize_lookuprecord_array (c, lookup.as_array (), lookup_map); |
3181 | 0 | return_trace (c->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
3182 | 0 | } |
3183 | | |
3184 | | bool subset (hb_subset_context_t *c, |
3185 | | const hb_map_t *lookup_map, |
3186 | | const hb_map_t *backtrack_map = nullptr, |
3187 | | const hb_map_t *input_map = nullptr, |
3188 | | const hb_map_t *lookahead_map = nullptr) const |
3189 | 0 | { |
3190 | 0 | TRACE_SUBSET (this); |
3191 | 0 |
|
3192 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3193 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3194 | 0 |
|
3195 | 0 | if (!backtrack_map) |
3196 | 0 | { |
3197 | 0 | const hb_set_t &glyphset = *c->plan->glyphset_gsub (); |
3198 | 0 | if (!hb_all (backtrack, glyphset) || |
3199 | 0 | !hb_all (input, glyphset) || |
3200 | 0 | !hb_all (lookahead, glyphset)) |
3201 | 0 | return_trace (false); |
3202 | 0 |
|
3203 | 0 | serialize (c->serializer, lookup_map, c->plan->glyph_map); |
3204 | 0 | } |
3205 | 0 | else |
3206 | 0 | { |
3207 | 0 | if (!hb_all (backtrack, backtrack_map) || |
3208 | 0 | !hb_all (input, input_map) || |
3209 | 0 | !hb_all (lookahead, lookahead_map)) |
3210 | 0 | return_trace (false); |
3211 | 0 |
|
3212 | 0 | serialize (c->serializer, lookup_map, backtrack_map, input_map, lookahead_map); |
3213 | 0 | } |
3214 | 0 |
|
3215 | 0 | return_trace (true); |
3216 | 0 | } |
3217 | | |
3218 | | bool sanitize (hb_sanitize_context_t *c) const |
3219 | 0 | { |
3220 | 0 | TRACE_SANITIZE (this); |
3221 | | /* Hyper-optimized sanitized because this is really hot. */ |
3222 | 0 | if (unlikely (!backtrack.len.sanitize (c))) return_trace (false); |
3223 | 0 | hb_barrier (); |
3224 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3225 | 0 | if (unlikely (!input.lenP1.sanitize (c))) return_trace (false); |
3226 | 0 | hb_barrier (); |
3227 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3228 | 0 | if (unlikely (!lookahead.len.sanitize (c))) return_trace (false); |
3229 | 0 | hb_barrier (); |
3230 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3231 | 0 | return_trace (likely (lookup.sanitize (c))); |
3232 | 0 | } |
3233 | | |
3234 | | protected: |
3235 | | Array16Of<typename Types::HBUINT> |
3236 | | backtrack; /* Array of backtracking values |
3237 | | * (to be matched before the input |
3238 | | * sequence) */ |
3239 | | HeadlessArray16Of<typename Types::HBUINT> |
3240 | | inputX; /* Array of input values (start with |
3241 | | * second glyph) */ |
3242 | | Array16Of<typename Types::HBUINT> |
3243 | | lookaheadX; /* Array of lookahead values's (to be |
3244 | | * matched after the input sequence) */ |
3245 | | Array16Of<LookupRecord> |
3246 | | lookupX; /* Array of LookupRecords--in |
3247 | | * design order) */ |
3248 | | public: |
3249 | | DEFINE_SIZE_MIN (8); |
3250 | | }; |
3251 | | |
3252 | | template <typename Types> |
3253 | | struct ChainRuleSet |
3254 | | { |
3255 | | using ChainRule = OT::ChainRule<Types>; |
3256 | | |
3257 | | bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const |
3258 | 0 | { |
3259 | 0 | return |
3260 | 0 | + hb_iter (rule) |
3261 | 0 | | hb_map (hb_add (this)) |
3262 | 0 | | hb_map ([&] (const ChainRule &_) { return _.intersects (glyphs, lookup_context); }) |
3263 | 0 | | hb_any |
3264 | 0 | ; |
3265 | 0 | } |
3266 | | void closure (hb_closure_context_t *c, unsigned value, ChainContextClosureLookupContext &lookup_context) const |
3267 | 0 | { |
3268 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3269 | | |
3270 | 0 | return |
3271 | 0 | + hb_iter (rule) |
3272 | 0 | | hb_map (hb_add (this)) |
3273 | 0 | | hb_apply ([&] (const ChainRule &_) { _.closure (c, value, lookup_context); }) |
3274 | 0 | ; |
3275 | 0 | } |
3276 | | |
3277 | | void closure_lookups (hb_closure_lookups_context_t *c, |
3278 | | ChainContextClosureLookupContext &lookup_context) const |
3279 | 0 | { |
3280 | 0 | if (unlikely (c->lookup_limit_exceeded ())) return; |
3281 | 0 |
|
3282 | 0 | + hb_iter (rule) |
3283 | 0 | | hb_map (hb_add (this)) |
3284 | 0 | | hb_apply ([&] (const ChainRule &_) { _.closure_lookups (c, lookup_context); }) |
3285 | 0 | ; |
3286 | 0 | } |
3287 | | |
3288 | | void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const |
3289 | 0 | { |
3290 | 0 | return |
3291 | 0 | + hb_iter (rule) |
3292 | 0 | | hb_map (hb_add (this)) |
3293 | 0 | | hb_apply ([&] (const ChainRule &_) { _.collect_glyphs (c, lookup_context); }) |
3294 | 0 | ; |
3295 | 0 | } |
3296 | | |
3297 | | bool would_apply (hb_would_apply_context_t *c, |
3298 | | const ChainContextApplyLookupContext &lookup_context) const |
3299 | 0 | { |
3300 | 0 | return |
3301 | 0 | + hb_iter (rule) |
3302 | 0 | | hb_map (hb_add (this)) |
3303 | 0 | | hb_map ([&] (const ChainRule &_) { return _.would_apply (c, lookup_context); }) |
3304 | 0 | | hb_any |
3305 | 0 | ; |
3306 | 0 | } |
3307 | | |
3308 | | bool apply (hb_ot_apply_context_t *c, |
3309 | | const ChainContextApplyLookupContext &lookup_context) const |
3310 | 0 | { |
3311 | 0 | TRACE_APPLY (this); |
3312 | |
|
3313 | 0 | unsigned num_rules = rule.len; |
3314 | |
|
3315 | 0 | #ifndef HB_NO_OT_RULESETS_FAST_PATH |
3316 | 0 | if (HB_OPTIMIZE_SIZE_VAL || num_rules <= 4) |
3317 | 0 | #endif |
3318 | 0 | { |
3319 | 0 | slow: |
3320 | 0 | return_trace ( |
3321 | 0 | + hb_iter (rule) |
3322 | 0 | | hb_map (hb_add (this)) |
3323 | 0 | | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) |
3324 | 0 | | hb_any |
3325 | 0 | ) |
3326 | 0 | ; |
3327 | 0 | } |
3328 | | |
3329 | | /* This version is optimized for speed by matching the first & second |
3330 | | * components of the rule here, instead of calling into the matching code. |
3331 | | * |
3332 | | * Replicated from LigatureSet::apply(). */ |
3333 | | |
3334 | 0 | hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input; |
3335 | 0 | skippy_iter.reset (c->buffer->idx); |
3336 | 0 | skippy_iter.set_match_func (match_always, nullptr); |
3337 | 0 | skippy_iter.set_glyph_data ((HBUINT16 *) nullptr); |
3338 | 0 | unsigned unsafe_to = (unsigned) -1, unsafe_to1 = 0, unsafe_to2 = 0; |
3339 | 0 | hb_glyph_info_t *first = nullptr, *second = nullptr; |
3340 | 0 | bool matched = skippy_iter.next (); |
3341 | 0 | if (likely (matched)) |
3342 | 0 | { |
3343 | 0 | first = &c->buffer->info[skippy_iter.idx]; |
3344 | 0 | unsafe_to1 = skippy_iter.idx + 1; |
3345 | |
|
3346 | 0 | if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx])) |
3347 | 0 | { |
3348 | | /* Can't use the fast path if eg. the next char is a default-ignorable |
3349 | | * or other skippable. */ |
3350 | 0 | goto slow; |
3351 | 0 | } |
3352 | 0 | } |
3353 | 0 | else |
3354 | 0 | { |
3355 | | /* Failed to match a next glyph. Only try applying rules that have |
3356 | | * no further input and lookahead. */ |
3357 | 0 | return_trace ( |
3358 | 0 | + hb_iter (rule) |
3359 | 0 | | hb_map (hb_add (this)) |
3360 | 0 | | hb_filter ([&] (const ChainRule &_) |
3361 | 0 | { |
3362 | 0 | const auto &input = StructAfter<decltype (_.inputX)> (_.backtrack); |
3363 | 0 | const auto &lookahead = StructAfter<decltype (_.lookaheadX)> (input); |
3364 | 0 | return input.lenP1 <= 1 && lookahead.len == 0; |
3365 | 0 | }) |
3366 | 0 | | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); }) |
3367 | 0 | | hb_any |
3368 | 0 | ) |
3369 | 0 | ; |
3370 | 0 | } |
3371 | 0 | matched = skippy_iter.next (); |
3372 | 0 | if (likely (matched && !skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))) |
3373 | 0 | { |
3374 | 0 | second = &c->buffer->info[skippy_iter.idx]; |
3375 | 0 | unsafe_to2 = skippy_iter.idx + 1; |
3376 | 0 | } |
3377 | |
|
3378 | 0 | auto match_input = lookup_context.funcs.match[1]; |
3379 | 0 | auto match_lookahead = lookup_context.funcs.match[2]; |
3380 | 0 | auto *input_data = lookup_context.match_data[1]; |
3381 | 0 | auto *lookahead_data = lookup_context.match_data[2]; |
3382 | 0 | for (unsigned int i = 0; i < num_rules; i++) |
3383 | 0 | { |
3384 | 0 | const auto &r = this+rule.arrayZ[i]; |
3385 | |
|
3386 | 0 | const auto &input = StructAfter<decltype (r.inputX)> (r.backtrack); |
3387 | 0 | const auto &lookahead = StructAfter<decltype (r.lookaheadX)> (input); |
3388 | |
|
3389 | 0 | unsigned lenP1 = hb_max ((unsigned) input.lenP1, 1u); |
3390 | 0 | if (lenP1 > 1 ? |
3391 | 0 | (!match_input || |
3392 | 0 | match_input (*first, input.arrayZ[0], input_data)) |
3393 | 0 | : |
3394 | 0 | (!lookahead.len || !match_lookahead || |
3395 | 0 | match_lookahead (*first, lookahead.arrayZ[0], lookahead_data))) |
3396 | 0 | { |
3397 | 0 | if (!second || |
3398 | 0 | (lenP1 > 2 ? |
3399 | 0 | (!match_input || |
3400 | 0 | match_input (*second, input.arrayZ[1], input_data)) |
3401 | 0 | : |
3402 | 0 | (lookahead.len <= 2 - lenP1 || !match_lookahead || |
3403 | 0 | match_lookahead (*second, lookahead.arrayZ[2 - lenP1], lookahead_data)))) |
3404 | 0 | { |
3405 | 0 | if (r.apply (c, lookup_context)) |
3406 | 0 | { |
3407 | 0 | if (unsafe_to != (unsigned) -1) |
3408 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); |
3409 | 0 | return_trace (true); |
3410 | 0 | } |
3411 | 0 | } |
3412 | 0 | else |
3413 | 0 | unsafe_to = unsafe_to2; |
3414 | 0 | } |
3415 | 0 | else |
3416 | 0 | { |
3417 | 0 | if (unsafe_to == (unsigned) -1) |
3418 | 0 | unsafe_to = unsafe_to1; |
3419 | 0 | } |
3420 | 0 | } |
3421 | 0 | if (likely (unsafe_to != (unsigned) -1)) |
3422 | 0 | c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to); |
3423 | |
|
3424 | 0 | return_trace (false); |
3425 | 0 | } |
3426 | | |
3427 | | bool subset (hb_subset_context_t *c, |
3428 | | const hb_map_t *lookup_map, |
3429 | | const hb_map_t *backtrack_klass_map = nullptr, |
3430 | | const hb_map_t *input_klass_map = nullptr, |
3431 | | const hb_map_t *lookahead_klass_map = nullptr) const |
3432 | 0 | { |
3433 | 0 | TRACE_SUBSET (this); |
3434 | 0 |
|
3435 | 0 | auto snap = c->serializer->snapshot (); |
3436 | 0 | auto *out = c->serializer->start_embed (*this); |
3437 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
3438 | 0 |
|
3439 | 0 | for (const Offset16To<ChainRule>& _ : rule) |
3440 | 0 | { |
3441 | 0 | if (!_) continue; |
3442 | 0 | auto o_snap = c->serializer->snapshot (); |
3443 | 0 | auto *o = out->rule.serialize_append (c->serializer); |
3444 | 0 | if (unlikely (!o)) continue; |
3445 | 0 |
|
3446 | 0 | if (!o->serialize_subset (c, _, this, |
3447 | 0 | lookup_map, |
3448 | 0 | backtrack_klass_map, |
3449 | 0 | input_klass_map, |
3450 | 0 | lookahead_klass_map)) |
3451 | 0 | { |
3452 | 0 | out->rule.pop (); |
3453 | 0 | c->serializer->revert (o_snap); |
3454 | 0 | } |
3455 | 0 | } |
3456 | 0 |
|
3457 | 0 | bool ret = bool (out->rule); |
3458 | 0 | if (!ret) c->serializer->revert (snap); |
3459 | 0 |
|
3460 | 0 | return_trace (ret); |
3461 | 0 | } |
3462 | | |
3463 | | bool sanitize (hb_sanitize_context_t *c) const |
3464 | 0 | { |
3465 | 0 | TRACE_SANITIZE (this); |
3466 | 0 | return_trace (rule.sanitize (c, this)); |
3467 | 0 | } |
3468 | | |
3469 | | protected: |
3470 | | Array16OfOffset16To<ChainRule> |
3471 | | rule; /* Array of ChainRule tables |
3472 | | * ordered by preference */ |
3473 | | public: |
3474 | | DEFINE_SIZE_ARRAY (2, rule); |
3475 | | }; |
3476 | | |
3477 | | template <typename Types> |
3478 | | struct ChainContextFormat1_4 |
3479 | | { |
3480 | | using ChainRuleSet = OT::ChainRuleSet<Types>; |
3481 | | |
3482 | | bool intersects (const hb_set_t *glyphs) const |
3483 | 0 | { |
3484 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3485 | 0 | {intersects_glyph, intersected_glyph}, |
3486 | 0 | ContextFormat::SimpleContext, |
3487 | 0 | {nullptr, nullptr, nullptr} |
3488 | 0 | }; |
3489 | 0 |
|
3490 | 0 | return |
3491 | 0 | + hb_zip (this+coverage, ruleSet) |
3492 | 0 | | hb_filter (*glyphs, hb_first) |
3493 | 0 | | hb_map (hb_second) |
3494 | 0 | | hb_map (hb_add (this)) |
3495 | 0 | | hb_map ([&] (const ChainRuleSet &_) { return _.intersects (glyphs, lookup_context); }) |
3496 | 0 | | hb_any |
3497 | 0 | ; |
3498 | 0 | } |
3499 | | |
3500 | | bool may_have_non_1to1 () const |
3501 | 0 | { return true; } |
3502 | | |
3503 | | void closure (hb_closure_context_t *c) const |
3504 | 0 | { |
3505 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
3506 | 0 | if (unlikely (!cur_active_glyphs)) return; |
3507 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
3508 | 0 | *cur_active_glyphs); |
3509 | |
|
3510 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3511 | 0 | {intersects_glyph, intersected_glyph}, |
3512 | 0 | ContextFormat::SimpleContext, |
3513 | 0 | {nullptr, nullptr, nullptr} |
3514 | 0 | }; |
3515 | |
|
3516 | 0 | + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len)) |
3517 | 0 | | hb_filter ([&] (hb_codepoint_t _) { |
3518 | 0 | return c->previous_parent_active_glyphs ().has (_); |
3519 | 0 | }, hb_first) |
3520 | 0 | | hb_map ([&](const hb_pair_t<hb_codepoint_t, unsigned> _) { return hb_pair_t<unsigned, const ChainRuleSet&> (_.first, this+ruleSet[_.second]); }) |
3521 | 0 | | hb_apply ([&] (const hb_pair_t<unsigned, const ChainRuleSet&>& _) { _.second.closure (c, _.first, lookup_context); }) |
3522 | 0 | ; |
3523 | |
|
3524 | 0 | c->pop_cur_done_glyphs (); |
3525 | 0 | } |
3526 | | |
3527 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
3528 | 0 | { |
3529 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3530 | 0 | {intersects_glyph, nullptr}, |
3531 | 0 | ContextFormat::SimpleContext, |
3532 | 0 | {nullptr, nullptr, nullptr} |
3533 | 0 | }; |
3534 | 0 |
|
3535 | 0 | + hb_zip (this+coverage, ruleSet) |
3536 | 0 | | hb_filter (*c->glyphs, hb_first) |
3537 | 0 | | hb_map (hb_second) |
3538 | 0 | | hb_map (hb_add (this)) |
3539 | 0 | | hb_apply ([&] (const ChainRuleSet &_) { _.closure_lookups (c, lookup_context); }) |
3540 | 0 | ; |
3541 | 0 | } |
3542 | | |
3543 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
3544 | | |
3545 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
3546 | 0 | { |
3547 | 0 | (this+coverage).collect_coverage (c->input); |
3548 | |
|
3549 | 0 | struct ChainContextCollectGlyphsLookupContext lookup_context = { |
3550 | 0 | {collect_glyph}, |
3551 | 0 | {nullptr, nullptr, nullptr} |
3552 | 0 | }; |
3553 | |
|
3554 | 0 | + hb_iter (ruleSet) |
3555 | 0 | | hb_map (hb_add (this)) |
3556 | 0 | | hb_apply ([&] (const ChainRuleSet &_) { _.collect_glyphs (c, lookup_context); }) |
3557 | 0 | ; |
3558 | 0 | } |
3559 | | |
3560 | | bool would_apply (hb_would_apply_context_t *c) const |
3561 | 0 | { |
3562 | 0 | const ChainRuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyphs[0])]; |
3563 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3564 | 0 | {{match_glyph, match_glyph, match_glyph}}, |
3565 | 0 | {nullptr, nullptr, nullptr} |
3566 | 0 | }; |
3567 | 0 | return rule_set.would_apply (c, lookup_context); |
3568 | 0 | } |
3569 | | |
3570 | 0 | const Coverage &get_coverage () const { return this+coverage; } |
3571 | | |
3572 | | bool apply (hb_ot_apply_context_t *c) const |
3573 | 0 | { |
3574 | 0 | TRACE_APPLY (this); |
3575 | 0 | unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); |
3576 | 0 | if (likely (index == NOT_COVERED)) return_trace (false); |
3577 | | |
3578 | 0 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
3579 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3580 | 0 | {{match_glyph, match_glyph, match_glyph}}, |
3581 | 0 | {nullptr, nullptr, nullptr} |
3582 | 0 | }; |
3583 | 0 | return_trace (rule_set.apply (c, lookup_context)); |
3584 | 0 | } |
3585 | | |
3586 | | bool subset (hb_subset_context_t *c) const |
3587 | 0 | { |
3588 | 0 | TRACE_SUBSET (this); |
3589 | 0 | const hb_set_t &glyphset = *c->plan->glyphset_gsub (); |
3590 | 0 | const hb_map_t &glyph_map = *c->plan->glyph_map; |
3591 | 0 |
|
3592 | 0 | auto *out = c->serializer->start_embed (*this); |
3593 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
3594 | 0 | out->format = format; |
3595 | 0 |
|
3596 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
3597 | 0 | hb_sorted_vector_t<hb_codepoint_t> new_coverage; |
3598 | 0 | + hb_zip (this+coverage, ruleSet) |
3599 | 0 | | hb_filter (glyphset, hb_first) |
3600 | 0 | | hb_filter (subset_offset_array (c, out->ruleSet, this, lookup_map), hb_second) |
3601 | 0 | | hb_map (hb_first) |
3602 | 0 | | hb_map (glyph_map) |
3603 | 0 | | hb_sink (new_coverage) |
3604 | 0 | ; |
3605 | 0 |
|
3606 | 0 | out->coverage.serialize_serialize (c->serializer, new_coverage.iter ()); |
3607 | 0 | return_trace (bool (new_coverage)); |
3608 | 0 | } |
3609 | | |
3610 | | bool sanitize (hb_sanitize_context_t *c) const |
3611 | 0 | { |
3612 | 0 | TRACE_SANITIZE (this); |
3613 | 0 | return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); |
3614 | 0 | } |
3615 | | |
3616 | | protected: |
3617 | | HBUINT16 format; /* Format identifier--format = 1 */ |
3618 | | typename Types::template OffsetTo<Coverage> |
3619 | | coverage; /* Offset to Coverage table--from |
3620 | | * beginning of table */ |
3621 | | Array16Of<typename Types::template OffsetTo<ChainRuleSet>> |
3622 | | ruleSet; /* Array of ChainRuleSet tables |
3623 | | * ordered by Coverage Index */ |
3624 | | public: |
3625 | | DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ruleSet); |
3626 | | }; |
3627 | | |
3628 | | template <typename Types> |
3629 | | struct ChainContextFormat2_5 |
3630 | | { |
3631 | | using ChainRuleSet = OT::ChainRuleSet<SmallTypes>; |
3632 | | |
3633 | | bool intersects (const hb_set_t *glyphs) const |
3634 | 0 | { |
3635 | 0 | if (!(this+coverage).intersects (glyphs)) |
3636 | 0 | return false; |
3637 | 0 |
|
3638 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3639 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3640 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3641 | 0 |
|
3642 | 0 | hb_map_t caches[3] = {}; |
3643 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3644 | 0 | {intersects_class, nullptr}, |
3645 | 0 | ContextFormat::ClassBasedContext, |
3646 | 0 | {&backtrack_class_def, |
3647 | 0 | &input_class_def, |
3648 | 0 | &lookahead_class_def}, |
3649 | 0 | {&caches[0], &caches[1], &caches[2]} |
3650 | 0 | }; |
3651 | 0 |
|
3652 | 0 | hb_set_t retained_coverage_glyphs; |
3653 | 0 | (this+coverage).intersect_set (*glyphs, retained_coverage_glyphs); |
3654 | 0 |
|
3655 | 0 | hb_set_t coverage_glyph_classes; |
3656 | 0 | input_class_def.intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); |
3657 | 0 |
|
3658 | 0 | return |
3659 | 0 | + hb_iter (ruleSet) |
3660 | 0 | | hb_map (hb_add (this)) |
3661 | 0 | | hb_enumerate |
3662 | 0 | | hb_map ([&] (const hb_pair_t<unsigned, const ChainRuleSet &> p) |
3663 | 0 | { return input_class_def.intersects_class (glyphs, p.first) && |
3664 | 0 | coverage_glyph_classes.has (p.first) && |
3665 | 0 | p.second.intersects (glyphs, lookup_context); }) |
3666 | 0 | | hb_any |
3667 | 0 | ; |
3668 | 0 | } |
3669 | | |
3670 | | bool may_have_non_1to1 () const |
3671 | 0 | { return true; } |
3672 | | |
3673 | | void closure (hb_closure_context_t *c) const |
3674 | 0 | { |
3675 | 0 | if (!(this+coverage).intersects (c->glyphs)) |
3676 | 0 | return; |
3677 | | |
3678 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
3679 | 0 | if (unlikely (!cur_active_glyphs)) return; |
3680 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
3681 | 0 | *cur_active_glyphs); |
3682 | |
|
3683 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3684 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3685 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3686 | |
|
3687 | 0 | hb_map_t caches[3] = {}; |
3688 | 0 | intersected_class_cache_t intersected_cache; |
3689 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3690 | 0 | {intersects_class, intersected_class_glyphs}, |
3691 | 0 | ContextFormat::ClassBasedContext, |
3692 | 0 | {&backtrack_class_def, |
3693 | 0 | &input_class_def, |
3694 | 0 | &lookahead_class_def}, |
3695 | 0 | {&caches[0], &caches[1], &caches[2]}, |
3696 | 0 | &intersected_cache |
3697 | 0 | }; |
3698 | |
|
3699 | 0 | + hb_enumerate (ruleSet) |
3700 | 0 | | hb_filter ([&] (unsigned _) |
3701 | 0 | { return input_class_def.intersects_class (&c->parent_active_glyphs (), _); }, |
3702 | 0 | hb_first) |
3703 | 0 | | hb_apply ([&] (const hb_pair_t<unsigned, const typename Types::template OffsetTo<ChainRuleSet>&> _) |
3704 | 0 | { |
3705 | 0 | const ChainRuleSet& chainrule_set = this+_.second; |
3706 | 0 | chainrule_set.closure (c, _.first, lookup_context); |
3707 | 0 | }) |
3708 | 0 | ; |
3709 | |
|
3710 | 0 | c->pop_cur_done_glyphs (); |
3711 | 0 | } |
3712 | | |
3713 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
3714 | 0 | { |
3715 | 0 | if (!(this+coverage).intersects (c->glyphs)) |
3716 | 0 | return; |
3717 | 0 |
|
3718 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3719 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3720 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3721 | 0 |
|
3722 | 0 | hb_map_t caches[3] = {}; |
3723 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3724 | 0 | {intersects_class, nullptr}, |
3725 | 0 | ContextFormat::ClassBasedContext, |
3726 | 0 | {&backtrack_class_def, |
3727 | 0 | &input_class_def, |
3728 | 0 | &lookahead_class_def}, |
3729 | 0 | {&caches[0], &caches[1], &caches[2]} |
3730 | 0 | }; |
3731 | 0 |
|
3732 | 0 | + hb_iter (ruleSet) |
3733 | 0 | | hb_map (hb_add (this)) |
3734 | 0 | | hb_enumerate |
3735 | 0 | | hb_filter([&] (unsigned klass) |
3736 | 0 | { return input_class_def.intersects_class (c->glyphs, klass); }, hb_first) |
3737 | 0 | | hb_map (hb_second) |
3738 | 0 | | hb_apply ([&] (const ChainRuleSet &_) |
3739 | 0 | { _.closure_lookups (c, lookup_context); }) |
3740 | 0 | ; |
3741 | 0 | } |
3742 | | |
3743 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
3744 | | |
3745 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
3746 | 0 | { |
3747 | 0 | (this+coverage).collect_coverage (c->input); |
3748 | |
|
3749 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3750 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3751 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3752 | |
|
3753 | 0 | struct ChainContextCollectGlyphsLookupContext lookup_context = { |
3754 | 0 | {collect_class}, |
3755 | 0 | {&backtrack_class_def, |
3756 | 0 | &input_class_def, |
3757 | 0 | &lookahead_class_def} |
3758 | 0 | }; |
3759 | |
|
3760 | 0 | + hb_iter (ruleSet) |
3761 | 0 | | hb_map (hb_add (this)) |
3762 | 0 | | hb_apply ([&] (const ChainRuleSet &_) { _.collect_glyphs (c, lookup_context); }) |
3763 | 0 | ; |
3764 | 0 | } |
3765 | | |
3766 | | bool would_apply (hb_would_apply_context_t *c) const |
3767 | 0 | { |
3768 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3769 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3770 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3771 | |
|
3772 | 0 | unsigned int index = input_class_def.get_class (c->glyphs[0]); |
3773 | 0 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
3774 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3775 | 0 | {{match_class, match_class, match_class}}, |
3776 | 0 | {&backtrack_class_def, |
3777 | 0 | &input_class_def, |
3778 | 0 | &lookahead_class_def} |
3779 | 0 | }; |
3780 | 0 | return rule_set.would_apply (c, lookup_context); |
3781 | 0 | } |
3782 | | |
3783 | 0 | const Coverage &get_coverage () const { return this+coverage; } |
3784 | | |
3785 | | unsigned cache_cost () const |
3786 | 0 | { |
3787 | 0 | unsigned c = (this+lookaheadClassDef).cost () * ruleSet.len; |
3788 | 0 | return c >= 4 ? c : 0; |
3789 | 0 | } |
3790 | | bool cache_func (hb_ot_apply_context_t *c, bool enter) const |
3791 | 0 | { |
3792 | 0 | if (enter) |
3793 | 0 | { |
3794 | 0 | if (!HB_BUFFER_TRY_ALLOCATE_VAR (c->buffer, syllable)) |
3795 | 0 | return false; |
3796 | 0 | auto &info = c->buffer->info; |
3797 | 0 | unsigned count = c->buffer->len; |
3798 | 0 | for (unsigned i = 0; i < count; i++) |
3799 | 0 | info[i].syllable() = 255; |
3800 | 0 | c->new_syllables = 255; |
3801 | 0 | return true; |
3802 | 0 | } |
3803 | 0 | else |
3804 | 0 | { |
3805 | 0 | c->new_syllables = (unsigned) -1; |
3806 | 0 | HB_BUFFER_DEALLOCATE_VAR (c->buffer, syllable); |
3807 | 0 | return true; |
3808 | 0 | } |
3809 | 0 | } |
3810 | | |
3811 | 0 | bool apply_cached (hb_ot_apply_context_t *c) const { return _apply (c, true); } |
3812 | 0 | bool apply (hb_ot_apply_context_t *c) const { return _apply (c, false); } |
3813 | | bool _apply (hb_ot_apply_context_t *c, bool cached) const |
3814 | 0 | { |
3815 | 0 | TRACE_APPLY (this); |
3816 | 0 | unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); |
3817 | 0 | if (likely (index == NOT_COVERED)) return_trace (false); |
3818 | | |
3819 | 0 | const ClassDef &backtrack_class_def = this+backtrackClassDef; |
3820 | 0 | const ClassDef &input_class_def = this+inputClassDef; |
3821 | 0 | const ClassDef &lookahead_class_def = this+lookaheadClassDef; |
3822 | | |
3823 | | /* match_class_caches1 is slightly faster. Use it for lookahead, |
3824 | | * which is typically longer. */ |
3825 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
3826 | 0 | {{cached && &backtrack_class_def == &lookahead_class_def ? match_class_cached1 : match_class, |
3827 | 0 | cached ? match_class_cached2 : match_class, |
3828 | 0 | cached ? match_class_cached1 : match_class}}, |
3829 | 0 | {&backtrack_class_def, |
3830 | 0 | &input_class_def, |
3831 | 0 | &lookahead_class_def} |
3832 | 0 | }; |
3833 | | |
3834 | | // Note: Corresponds to match_class_cached2 |
3835 | 0 | if (cached && ((c->buffer->cur().syllable() & 0xF0) >> 4) < 15) |
3836 | 0 | index = (c->buffer->cur().syllable () & 0xF0) >> 4; |
3837 | 0 | else |
3838 | 0 | index = input_class_def.get_class (c->buffer->cur().codepoint); |
3839 | 0 | const ChainRuleSet &rule_set = this+ruleSet[index]; |
3840 | 0 | return_trace (rule_set.apply (c, lookup_context)); |
3841 | 0 | } |
3842 | | |
3843 | | bool subset (hb_subset_context_t *c) const |
3844 | 0 | { |
3845 | 0 | TRACE_SUBSET (this); |
3846 | 0 | auto *out = c->serializer->start_embed (*this); |
3847 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
3848 | 0 | out->format = format; |
3849 | 0 | out->coverage.serialize_subset (c, coverage, this); |
3850 | 0 |
|
3851 | 0 | hb_map_t backtrack_klass_map; |
3852 | 0 | hb_map_t input_klass_map; |
3853 | 0 | hb_map_t lookahead_klass_map; |
3854 | 0 |
|
3855 | 0 | out->backtrackClassDef.serialize_subset (c, backtrackClassDef, this, &backtrack_klass_map); |
3856 | 0 | // TODO: subset inputClassDef based on glyphs survived in Coverage subsetting |
3857 | 0 | out->inputClassDef.serialize_subset (c, inputClassDef, this, &input_klass_map); |
3858 | 0 | out->lookaheadClassDef.serialize_subset (c, lookaheadClassDef, this, &lookahead_klass_map); |
3859 | 0 |
|
3860 | 0 | if (unlikely (!c->serializer->propagate_error (backtrack_klass_map, |
3861 | 0 | input_klass_map, |
3862 | 0 | lookahead_klass_map))) |
3863 | 0 | return_trace (false); |
3864 | 0 |
|
3865 | 0 | const hb_set_t* glyphset = c->plan->glyphset_gsub (); |
3866 | 0 | hb_set_t retained_coverage_glyphs; |
3867 | 0 | (this+coverage).intersect_set (*glyphset, retained_coverage_glyphs); |
3868 | 0 |
|
3869 | 0 | hb_set_t coverage_glyph_classes; |
3870 | 0 | (this+inputClassDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes); |
3871 | 0 |
|
3872 | 0 | int non_zero_index = -1, index = 0; |
3873 | 0 | bool ret = true; |
3874 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
3875 | 0 | auto last_non_zero = c->serializer->snapshot (); |
3876 | 0 | for (const auto& _ : + hb_enumerate (ruleSet) |
3877 | 0 | | hb_filter (input_klass_map, hb_first)) |
3878 | 0 | { |
3879 | 0 | auto *o = out->ruleSet.serialize_append (c->serializer); |
3880 | 0 | if (unlikely (!o)) |
3881 | 0 | { |
3882 | 0 | ret = false; |
3883 | 0 | break; |
3884 | 0 | } |
3885 | 0 | if (coverage_glyph_classes.has (_.first) && |
3886 | 0 | o->serialize_subset (c, _.second, this, |
3887 | 0 | lookup_map, |
3888 | 0 | &backtrack_klass_map, |
3889 | 0 | &input_klass_map, |
3890 | 0 | &lookahead_klass_map)) |
3891 | 0 | { |
3892 | 0 | last_non_zero = c->serializer->snapshot (); |
3893 | 0 | non_zero_index = index; |
3894 | 0 | } |
3895 | 0 |
|
3896 | 0 | index++; |
3897 | 0 | } |
3898 | 0 |
|
3899 | 0 | if (!ret || non_zero_index == -1) return_trace (false); |
3900 | 0 |
|
3901 | 0 | // prune empty trailing ruleSets |
3902 | 0 | if (index > non_zero_index) { |
3903 | 0 | c->serializer->revert (last_non_zero); |
3904 | 0 | out->ruleSet.len = non_zero_index + 1; |
3905 | 0 | } |
3906 | 0 |
|
3907 | 0 | return_trace (bool (out->ruleSet)); |
3908 | 0 | } |
3909 | | |
3910 | | bool sanitize (hb_sanitize_context_t *c) const |
3911 | 0 | { |
3912 | 0 | TRACE_SANITIZE (this); |
3913 | 0 | return_trace (coverage.sanitize (c, this) && |
3914 | 0 | backtrackClassDef.sanitize (c, this) && |
3915 | 0 | inputClassDef.sanitize (c, this) && |
3916 | 0 | lookaheadClassDef.sanitize (c, this) && |
3917 | 0 | ruleSet.sanitize (c, this)); |
3918 | 0 | } |
3919 | | |
3920 | | protected: |
3921 | | HBUINT16 format; /* Format identifier--format = 2 */ |
3922 | | typename Types::template OffsetTo<Coverage> |
3923 | | coverage; /* Offset to Coverage table--from |
3924 | | * beginning of table */ |
3925 | | typename Types::template OffsetTo<ClassDef> |
3926 | | backtrackClassDef; /* Offset to glyph ClassDef table |
3927 | | * containing backtrack sequence |
3928 | | * data--from beginning of table */ |
3929 | | typename Types::template OffsetTo<ClassDef> |
3930 | | inputClassDef; /* Offset to glyph ClassDef |
3931 | | * table containing input sequence |
3932 | | * data--from beginning of table */ |
3933 | | typename Types::template OffsetTo<ClassDef> |
3934 | | lookaheadClassDef; /* Offset to glyph ClassDef table |
3935 | | * containing lookahead sequence |
3936 | | * data--from beginning of table */ |
3937 | | Array16Of<typename Types::template OffsetTo<ChainRuleSet>> |
3938 | | ruleSet; /* Array of ChainRuleSet tables |
3939 | | * ordered by class */ |
3940 | | public: |
3941 | | DEFINE_SIZE_ARRAY (4 + 4 * Types::size, ruleSet); |
3942 | | }; |
3943 | | |
3944 | | struct ChainContextFormat3 |
3945 | | { |
3946 | | using RuleSet = OT::RuleSet<SmallTypes>; |
3947 | | |
3948 | | bool intersects (const hb_set_t *glyphs) const |
3949 | 0 | { |
3950 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3951 | 0 |
|
3952 | 0 | if (!(this+input[0]).intersects (glyphs)) |
3953 | 0 | return false; |
3954 | 0 |
|
3955 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3956 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3957 | 0 | {intersects_coverage, nullptr}, |
3958 | 0 | ContextFormat::CoverageBasedContext, |
3959 | 0 | {this, this, this} |
3960 | 0 | }; |
3961 | 0 | return chain_context_intersects (glyphs, |
3962 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
3963 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
3964 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
3965 | 0 | lookup_context); |
3966 | 0 | } |
3967 | | |
3968 | | bool may_have_non_1to1 () const |
3969 | 0 | { return true; } |
3970 | | |
3971 | | void closure (hb_closure_context_t *c) const |
3972 | 0 | { |
3973 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
3974 | |
|
3975 | 0 | if (!(this+input[0]).intersects (c->glyphs)) |
3976 | 0 | return; |
3977 | | |
3978 | 0 | hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs (); |
3979 | 0 | if (unlikely (!cur_active_glyphs)) |
3980 | 0 | return; |
3981 | 0 | get_coverage ().intersect_set (c->previous_parent_active_glyphs (), |
3982 | 0 | *cur_active_glyphs); |
3983 | |
|
3984 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
3985 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
3986 | 0 | struct ChainContextClosureLookupContext lookup_context = { |
3987 | 0 | {intersects_coverage, intersected_coverage_glyphs}, |
3988 | 0 | ContextFormat::CoverageBasedContext, |
3989 | 0 | {this, this, this} |
3990 | 0 | }; |
3991 | 0 | chain_context_closure_lookup (c, |
3992 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
3993 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
3994 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
3995 | 0 | lookup.len, lookup.arrayZ, |
3996 | 0 | 0, lookup_context); |
3997 | |
|
3998 | 0 | c->pop_cur_done_glyphs (); |
3999 | 0 | } |
4000 | | |
4001 | | void closure_lookups (hb_closure_lookups_context_t *c) const |
4002 | 0 | { |
4003 | 0 | if (!intersects (c->glyphs)) |
4004 | 0 | return; |
4005 | 0 |
|
4006 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4007 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4008 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4009 | 0 | recurse_lookups (c, lookup.len, lookup.arrayZ); |
4010 | 0 | } |
4011 | | |
4012 | 0 | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {} |
4013 | | |
4014 | | void collect_glyphs (hb_collect_glyphs_context_t *c) const |
4015 | 0 | { |
4016 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4017 | |
|
4018 | 0 | (this+input[0]).collect_coverage (c->input); |
4019 | |
|
4020 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4021 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4022 | |
|
4023 | 0 | struct ChainContextCollectGlyphsLookupContext lookup_context = { |
4024 | 0 | {collect_coverage}, |
4025 | 0 | {this, this, this} |
4026 | 0 | }; |
4027 | 0 | chain_context_collect_glyphs_lookup (c, |
4028 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4029 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4030 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4031 | 0 | lookup.len, lookup.arrayZ, |
4032 | 0 | lookup_context); |
4033 | 0 | } |
4034 | | |
4035 | | bool would_apply (hb_would_apply_context_t *c) const |
4036 | 0 | { |
4037 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4038 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4039 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4040 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
4041 | 0 | {{match_coverage, match_coverage, match_coverage}}, |
4042 | 0 | {this, this, this} |
4043 | 0 | }; |
4044 | 0 | return chain_context_would_apply_lookup (c, |
4045 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4046 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4047 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4048 | 0 | lookup.len, lookup.arrayZ, lookup_context); |
4049 | 0 | } |
4050 | | |
4051 | | const Coverage &get_coverage () const |
4052 | 0 | { |
4053 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4054 | 0 | return this+input[0]; |
4055 | 0 | } |
4056 | | |
4057 | | bool apply (hb_ot_apply_context_t *c) const |
4058 | 0 | { |
4059 | 0 | TRACE_APPLY (this); |
4060 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4061 | |
|
4062 | 0 | unsigned int index = (this+input[0]).get_coverage (c->buffer->cur().codepoint); |
4063 | 0 | if (likely (index == NOT_COVERED)) return_trace (false); |
4064 | | |
4065 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4066 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4067 | 0 | struct ChainContextApplyLookupContext lookup_context = { |
4068 | 0 | {{match_coverage, match_coverage, match_coverage}}, |
4069 | 0 | {this, this, this} |
4070 | 0 | }; |
4071 | 0 | return_trace (chain_context_apply_lookup (c, |
4072 | 0 | backtrack.len, (const HBUINT16 *) backtrack.arrayZ, |
4073 | 0 | input.len, (const HBUINT16 *) input.arrayZ + 1, |
4074 | 0 | lookahead.len, (const HBUINT16 *) lookahead.arrayZ, |
4075 | 0 | lookup.len, lookup.arrayZ, lookup_context)); |
4076 | 0 | } |
4077 | | |
4078 | | template<typename Iterator, |
4079 | | hb_requires (hb_is_iterator (Iterator))> |
4080 | | bool serialize_coverage_offsets (hb_subset_context_t *c, Iterator it, const void* base) const |
4081 | 0 | { |
4082 | 0 | TRACE_SERIALIZE (this); |
4083 | 0 | auto *out = c->serializer->start_embed<Array16OfOffset16To<Coverage>> (); |
4084 | 0 |
|
4085 | 0 | if (unlikely (!c->serializer->allocate_size<HBUINT16> (HBUINT16::static_size))) |
4086 | 0 | return_trace (false); |
4087 | 0 |
|
4088 | 0 | for (auto& offset : it) { |
4089 | 0 | auto *o = out->serialize_append (c->serializer); |
4090 | 0 | if (unlikely (!o) || !o->serialize_subset (c, offset, base)) |
4091 | 0 | return_trace (false); |
4092 | 0 | } |
4093 | 0 |
|
4094 | 0 | return_trace (true); |
4095 | 0 | } |
4096 | | |
4097 | | bool subset (hb_subset_context_t *c) const |
4098 | 0 | { |
4099 | 0 | TRACE_SUBSET (this); |
4100 | 0 |
|
4101 | 0 | if (unlikely (!c->serializer->embed (this->format))) return_trace (false); |
4102 | 0 |
|
4103 | 0 | if (!serialize_coverage_offsets (c, backtrack.iter (), this)) |
4104 | 0 | return_trace (false); |
4105 | 0 |
|
4106 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4107 | 0 | if (!serialize_coverage_offsets (c, input.iter (), this)) |
4108 | 0 | return_trace (false); |
4109 | 0 |
|
4110 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4111 | 0 | if (!serialize_coverage_offsets (c, lookahead.iter (), this)) |
4112 | 0 | return_trace (false); |
4113 | 0 |
|
4114 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4115 | 0 | const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups; |
4116 | 0 |
|
4117 | 0 | HBUINT16 *lookupCount = c->serializer->copy<HBUINT16> (lookup.len); |
4118 | 0 | if (!lookupCount) return_trace (false); |
4119 | 0 |
|
4120 | 0 | unsigned count = serialize_lookuprecord_array (c->serializer, lookup.as_array (), lookup_map); |
4121 | 0 | return_trace (c->serializer->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW)); |
4122 | 0 | } |
4123 | | |
4124 | | bool sanitize (hb_sanitize_context_t *c) const |
4125 | 0 | { |
4126 | 0 | TRACE_SANITIZE (this); |
4127 | 0 | if (unlikely (!backtrack.sanitize (c, this))) return_trace (false); |
4128 | 0 | hb_barrier (); |
4129 | 0 | const auto &input = StructAfter<decltype (inputX)> (backtrack); |
4130 | 0 | if (unlikely (!input.sanitize (c, this))) return_trace (false); |
4131 | 0 | hb_barrier (); |
4132 | 0 | if (unlikely (!input.len)) return_trace (false); /* To be consistent with Context. */ |
4133 | 0 | const auto &lookahead = StructAfter<decltype (lookaheadX)> (input); |
4134 | 0 | if (unlikely (!lookahead.sanitize (c, this))) return_trace (false); |
4135 | 0 | hb_barrier (); |
4136 | 0 | const auto &lookup = StructAfter<decltype (lookupX)> (lookahead); |
4137 | 0 | return_trace (likely (lookup.sanitize (c))); |
4138 | 0 | } |
4139 | | |
4140 | | protected: |
4141 | | HBUINT16 format; /* Format identifier--format = 3 */ |
4142 | | Array16OfOffset16To<Coverage> |
4143 | | backtrack; /* Array of coverage tables |
4144 | | * in backtracking sequence, in glyph |
4145 | | * sequence order */ |
4146 | | Array16OfOffset16To<Coverage> |
4147 | | inputX ; /* Array of coverage |
4148 | | * tables in input sequence, in glyph |
4149 | | * sequence order */ |
4150 | | Array16OfOffset16To<Coverage> |
4151 | | lookaheadX; /* Array of coverage tables |
4152 | | * in lookahead sequence, in glyph |
4153 | | * sequence order */ |
4154 | | Array16Of<LookupRecord> |
4155 | | lookupX; /* Array of LookupRecords--in |
4156 | | * design order) */ |
4157 | | public: |
4158 | | DEFINE_SIZE_MIN (10); |
4159 | | }; |
4160 | | |
4161 | | struct ChainContext |
4162 | | { |
4163 | | template <typename context_t, typename ...Ts> |
4164 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
4165 | 0 | { |
4166 | 0 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); |
4167 | 0 | TRACE_DISPATCH (this, u.format); |
4168 | 0 | switch (u.format) { |
4169 | 0 | case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); |
4170 | 0 | case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...)); |
4171 | 0 | case 3: return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...)); |
4172 | | #ifndef HB_NO_BEYOND_64K |
4173 | | case 4: return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...)); |
4174 | | case 5: return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...)); |
4175 | | #endif |
4176 | 0 | default:return_trace (c->default_return_value ()); |
4177 | 0 | } |
4178 | 0 | } 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 Unexecuted instantiation: hb_sanitize_context_t::return_t OT::ChainContext::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const 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 Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::ChainContext::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::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 |
4179 | | |
4180 | | protected: |
4181 | | union { |
4182 | | HBUINT16 format; /* Format identifier */ |
4183 | | ChainContextFormat1_4<SmallTypes> format1; |
4184 | | ChainContextFormat2_5<SmallTypes> format2; |
4185 | | ChainContextFormat3 format3; |
4186 | | #ifndef HB_NO_BEYOND_64K |
4187 | | ChainContextFormat1_4<MediumTypes> format4; |
4188 | | ChainContextFormat2_5<MediumTypes> format5; |
4189 | | #endif |
4190 | | } u; |
4191 | | }; |
4192 | | |
4193 | | |
4194 | | template <typename T> |
4195 | | struct ExtensionFormat1 |
4196 | | { |
4197 | 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 |
4198 | | |
4199 | | template <typename X> |
4200 | | const X& get_subtable () const |
4201 | 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 |
4202 | | |
4203 | | template <typename context_t, typename ...Ts> |
4204 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
4205 | 0 | { |
4206 | 0 | if (unlikely (!c->may_dispatch (this, this))) return c->no_dispatch_return_value (); |
4207 | 0 | TRACE_DISPATCH (this, format); |
4208 | 0 | return_trace (get_subtable<typename T::SubTable> ().dispatch (c, get_type (), std::forward<Ts> (ds)...)); |
4209 | 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 |
4210 | | |
4211 | | void collect_variation_indices (hb_collect_variation_indices_context_t *c) const |
4212 | | { dispatch (c); } |
4213 | | |
4214 | | /* This is called from may_dispatch() above with hb_sanitize_context_t. */ |
4215 | | bool sanitize (hb_sanitize_context_t *c) const |
4216 | 0 | { |
4217 | 0 | TRACE_SANITIZE (this); |
4218 | 0 | return_trace (c->check_struct (this) && |
4219 | 0 | hb_barrier () && |
4220 | 0 | extensionLookupType != T::SubTable::Extension); |
4221 | 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 |
4222 | | |
4223 | | bool subset (hb_subset_context_t *c) const |
4224 | 0 | { |
4225 | 0 | TRACE_SUBSET (this); |
4226 | 0 |
|
4227 | 0 | auto *out = c->serializer->start_embed (this); |
4228 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
4229 | 0 |
|
4230 | 0 | out->format = format; |
4231 | 0 | out->extensionLookupType = extensionLookupType; |
4232 | 0 |
|
4233 | 0 | const auto& src_offset = |
4234 | 0 | reinterpret_cast<const Offset32To<typename T::SubTable> &> (extensionOffset); |
4235 | 0 | auto& dest_offset = |
4236 | 0 | reinterpret_cast<Offset32To<typename T::SubTable> &> (out->extensionOffset); |
4237 | 0 |
|
4238 | 0 | return_trace (dest_offset.serialize_subset (c, src_offset, this, get_type ())); |
4239 | 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 |
4240 | | |
4241 | | protected: |
4242 | | HBUINT16 format; /* Format identifier. Set to 1. */ |
4243 | | HBUINT16 extensionLookupType; /* Lookup type of subtable referenced |
4244 | | * by ExtensionOffset (i.e. the |
4245 | | * extension subtable). */ |
4246 | | Offset32 extensionOffset; /* Offset to the extension subtable, |
4247 | | * of lookup type subtable. */ |
4248 | | public: |
4249 | | DEFINE_SIZE_STATIC (8); |
4250 | | }; |
4251 | | |
4252 | | template <typename T> |
4253 | | struct Extension |
4254 | | { |
4255 | | unsigned int get_type () const |
4256 | 0 | { |
4257 | 0 | switch (u.format) { |
4258 | 0 | case 1: return u.format1.get_type (); |
4259 | 0 | default:return 0; |
4260 | 0 | } |
4261 | 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 |
4262 | | template <typename X> |
4263 | | const X& get_subtable () const |
4264 | | { |
4265 | | switch (u.format) { |
4266 | | case 1: return u.format1.template get_subtable<typename T::SubTable> (); |
4267 | | default:return Null (typename T::SubTable); |
4268 | | } |
4269 | | } |
4270 | | |
4271 | | // Specialization of dispatch for subset. dispatch() normally just |
4272 | | // dispatches to the sub table this points too, but for subset |
4273 | | // we need to run subset on this subtable too. |
4274 | | template <typename ...Ts> |
4275 | | typename hb_subset_context_t::return_t dispatch (hb_subset_context_t *c, Ts&&... ds) const |
4276 | 0 | { |
4277 | 0 | switch (u.format) { |
4278 | 0 | case 1: return u.format1.subset (c); |
4279 | 0 | default: return c->default_return_value (); |
4280 | 0 | } |
4281 | 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 |
4282 | | |
4283 | | template <typename context_t, typename ...Ts> |
4284 | | typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const |
4285 | 0 | { |
4286 | 0 | if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); |
4287 | 0 | TRACE_DISPATCH (this, u.format); |
4288 | 0 | switch (u.format) { |
4289 | 0 | case 1: return_trace (u.format1.dispatch (c, std::forward<Ts> (ds)...)); |
4290 | 0 | default:return_trace (c->default_return_value ()); |
4291 | 0 | } |
4292 | 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 |
4293 | | |
4294 | | protected: |
4295 | | union { |
4296 | | HBUINT16 format; /* Format identifier */ |
4297 | | ExtensionFormat1<T> format1; |
4298 | | } u; |
4299 | | }; |
4300 | | |
4301 | | |
4302 | | /* |
4303 | | * GSUB/GPOS Common |
4304 | | */ |
4305 | | |
4306 | | struct hb_ot_layout_lookup_accelerator_t |
4307 | | { |
4308 | | template <typename TLookup> |
4309 | | static hb_ot_layout_lookup_accelerator_t *create (const TLookup &lookup) |
4310 | 0 | { |
4311 | 0 | unsigned count = lookup.get_subtable_count (); |
4312 | |
|
4313 | 0 | unsigned size = sizeof (hb_ot_layout_lookup_accelerator_t) - |
4314 | 0 | HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) + |
4315 | 0 | count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t); |
4316 | | |
4317 | | /* The following is a calloc because when we are collecting subtables, |
4318 | | * some of them might be invalid and hence not collect; as a result, |
4319 | | * we might not fill in all the count entries of the subtables array. |
4320 | | * Zeroing it allows the set digest to gatekeep it without having to |
4321 | | * initialize it further. */ |
4322 | 0 | auto *thiz = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (1, size); |
4323 | 0 | if (unlikely (!thiz)) |
4324 | 0 | return nullptr; |
4325 | | |
4326 | 0 | hb_accelerate_subtables_context_t c_accelerate_subtables (thiz->subtables); |
4327 | 0 | lookup.dispatch (&c_accelerate_subtables); |
4328 | |
|
4329 | 0 | thiz->digest.init (); |
4330 | 0 | for (auto& subtable : hb_iter (thiz->subtables, count)) |
4331 | 0 | thiz->digest.add (subtable.digest); |
4332 | |
|
4333 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4334 | 0 | thiz->cache_user_idx = c_accelerate_subtables.cache_user_idx; |
4335 | 0 | for (unsigned i = 0; i < count; i++) |
4336 | 0 | if (i != thiz->cache_user_idx) |
4337 | 0 | thiz->subtables[i].apply_cached_func = thiz->subtables[i].apply_func; |
4338 | 0 | #endif |
4339 | |
|
4340 | 0 | return thiz; |
4341 | 0 | } Unexecuted instantiation: 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&) Unexecuted instantiation: 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&) |
4342 | | |
4343 | | bool may_have (hb_codepoint_t g) const |
4344 | 0 | { return digest.may_have (g); } |
4345 | | |
4346 | | #ifndef HB_OPTIMIZE_SIZE |
4347 | | HB_ALWAYS_INLINE |
4348 | | #endif |
4349 | | bool apply (hb_ot_apply_context_t *c, unsigned subtables_count, bool use_cache) const |
4350 | 0 | { |
4351 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4352 | 0 | if (use_cache) |
4353 | 0 | { |
4354 | 0 | return |
4355 | 0 | + hb_iter (hb_iter (subtables, subtables_count)) |
4356 | 0 | | hb_map ([&c] (const hb_accelerate_subtables_context_t::hb_applicable_t &_) { return _.apply_cached (c); }) |
4357 | 0 | | hb_any |
4358 | 0 | ; |
4359 | 0 | } |
4360 | 0 | else |
4361 | 0 | #endif |
4362 | 0 | { |
4363 | 0 | return |
4364 | 0 | + hb_iter (hb_iter (subtables, subtables_count)) |
4365 | 0 | | hb_map ([&c] (const hb_accelerate_subtables_context_t::hb_applicable_t &_) { return _.apply (c); }) |
4366 | 0 | | hb_any |
4367 | 0 | ; |
4368 | 0 | } |
4369 | 0 | return false; |
4370 | 0 | } |
4371 | | |
4372 | | bool cache_enter (hb_ot_apply_context_t *c) const |
4373 | 0 | { |
4374 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4375 | 0 | return cache_user_idx != (unsigned) -1 && |
4376 | 0 | subtables[cache_user_idx].cache_enter (c); |
4377 | | #else |
4378 | | return false; |
4379 | | #endif |
4380 | 0 | } |
4381 | | void cache_leave (hb_ot_apply_context_t *c) const |
4382 | 0 | { |
4383 | 0 | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4384 | 0 | subtables[cache_user_idx].cache_leave (c); |
4385 | 0 | #endif |
4386 | 0 | } |
4387 | | |
4388 | | |
4389 | | hb_set_digest_t digest; |
4390 | | private: |
4391 | | #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE |
4392 | | unsigned cache_user_idx = (unsigned) -1; |
4393 | | #endif |
4394 | | hb_accelerate_subtables_context_t::hb_applicable_t subtables[HB_VAR_ARRAY]; |
4395 | | }; |
4396 | | |
4397 | | template <typename Types> |
4398 | | struct GSUBGPOSVersion1_2 |
4399 | | { |
4400 | | friend struct GSUBGPOS; |
4401 | | |
4402 | | protected: |
4403 | | FixedVersion<>version; /* Version of the GSUB/GPOS table--initially set |
4404 | | * to 0x00010000u */ |
4405 | | typename Types:: template OffsetTo<ScriptList> |
4406 | | scriptList; /* ScriptList table */ |
4407 | | typename Types::template OffsetTo<FeatureList> |
4408 | | featureList; /* FeatureList table */ |
4409 | | typename Types::template OffsetTo<LookupList<Types>> |
4410 | | lookupList; /* LookupList table */ |
4411 | | Offset32To<FeatureVariations> |
4412 | | featureVars; /* Offset to Feature Variations |
4413 | | table--from beginning of table |
4414 | | * (may be NULL). Introduced |
4415 | | * in version 0x00010001. */ |
4416 | | public: |
4417 | | DEFINE_SIZE_MIN (4 + 3 * Types::size); |
4418 | | |
4419 | | unsigned int get_size () const |
4420 | 0 | { |
4421 | 0 | return min_size + |
4422 | 0 | (version.to_int () >= 0x00010001u ? featureVars.static_size : 0); |
4423 | 0 | } |
4424 | | |
4425 | | const typename Types::template OffsetTo<LookupList<Types>>* get_lookup_list_offset () const |
4426 | | { |
4427 | | return &lookupList; |
4428 | | } |
4429 | | |
4430 | | template <typename TLookup> |
4431 | | bool sanitize (hb_sanitize_context_t *c) const |
4432 | 0 | { |
4433 | 0 | TRACE_SANITIZE (this); |
4434 | 0 | typedef List16OfOffsetTo<TLookup, typename Types::HBUINT> TLookupList; |
4435 | 0 | if (unlikely (!(scriptList.sanitize (c, this) && |
4436 | 0 | featureList.sanitize (c, this) && |
4437 | 0 | reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList).sanitize (c, this)))) |
4438 | 0 | return_trace (false); |
4439 | | |
4440 | 0 | #ifndef HB_NO_VAR |
4441 | 0 | if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this)))) |
4442 | 0 | return_trace (false); |
4443 | 0 | #endif |
4444 | | |
4445 | 0 | return_trace (true); |
4446 | 0 | } Unexecuted instantiation: bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::sanitize<OT::Layout::GPOS_impl::PosLookup>(hb_sanitize_context_t*) const Unexecuted instantiation: bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::sanitize<OT::Layout::GSUB_impl::SubstLookup>(hb_sanitize_context_t*) const |
4447 | | |
4448 | | template <typename TLookup> |
4449 | | bool subset (hb_subset_layout_context_t *c) const |
4450 | 0 | { |
4451 | 0 | TRACE_SUBSET (this); |
4452 | 0 |
|
4453 | 0 | auto *out = c->subset_context->serializer->start_embed (this); |
4454 | 0 | if (unlikely (!c->subset_context->serializer->extend_min (out))) return_trace (false); |
4455 | 0 |
|
4456 | 0 | out->version = version; |
4457 | 0 |
|
4458 | 0 | typedef LookupOffsetList<TLookup, typename Types::HBUINT> TLookupList; |
4459 | 0 | reinterpret_cast<typename Types::template OffsetTo<TLookupList> &> (out->lookupList) |
4460 | 0 | .serialize_subset (c->subset_context, |
4461 | 0 | reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList), |
4462 | 0 | this, |
4463 | 0 | c); |
4464 | 0 |
|
4465 | 0 | reinterpret_cast<typename Types::template OffsetTo<RecordListOfFeature> &> (out->featureList) |
4466 | 0 | .serialize_subset (c->subset_context, |
4467 | 0 | reinterpret_cast<const typename Types::template OffsetTo<RecordListOfFeature> &> (featureList), |
4468 | 0 | this, |
4469 | 0 | c); |
4470 | 0 |
|
4471 | 0 | out->scriptList.serialize_subset (c->subset_context, |
4472 | 0 | scriptList, |
4473 | 0 | this, |
4474 | 0 | c); |
4475 | 0 |
|
4476 | 0 | #ifndef HB_NO_VAR |
4477 | 0 | if (version.to_int () >= 0x00010001u) |
4478 | 0 | { |
4479 | 0 | auto snapshot = c->subset_context->serializer->snapshot (); |
4480 | 0 | if (!c->subset_context->serializer->extend_min (&out->featureVars)) |
4481 | 0 | return_trace (false); |
4482 | 0 |
|
4483 | 0 | // if all axes are pinned all feature vars are dropped. |
4484 | 0 | bool ret = !c->subset_context->plan->all_axes_pinned |
4485 | 0 | && out->featureVars.serialize_subset (c->subset_context, featureVars, this, c); |
4486 | 0 | if (!ret && version.major == 1) |
4487 | 0 | { |
4488 | 0 | c->subset_context->serializer->revert (snapshot); |
4489 | 0 | out->version.major = 1; |
4490 | 0 | out->version.minor = 0; |
4491 | 0 | } |
4492 | 0 | } |
4493 | 0 | #endif |
4494 | 0 |
|
4495 | 0 | return_trace (true); |
4496 | 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 |
4497 | | }; |
4498 | | |
4499 | | struct GSUBGPOS |
4500 | | { |
4501 | | unsigned int get_size () const |
4502 | 0 | { |
4503 | 0 | switch (u.version.major) { |
4504 | 0 | case 1: return u.version1.get_size (); |
4505 | 0 | #ifndef HB_NO_BEYOND_64K |
4506 | 0 | case 2: return u.version2.get_size (); |
4507 | 0 | #endif |
4508 | 0 | default: return u.version.static_size; |
4509 | 0 | } |
4510 | 0 | } |
4511 | | |
4512 | | template <typename TLookup> |
4513 | | bool sanitize (hb_sanitize_context_t *c) const |
4514 | 0 | { |
4515 | 0 | TRACE_SANITIZE (this); |
4516 | 0 | if (unlikely (!u.version.sanitize (c))) return_trace (false); |
4517 | 0 | hb_barrier (); |
4518 | 0 | switch (u.version.major) { |
4519 | 0 | case 1: return_trace (u.version1.sanitize<TLookup> (c)); |
4520 | | #ifndef HB_NO_BEYOND_64K |
4521 | | case 2: return_trace (u.version2.sanitize<TLookup> (c)); |
4522 | | #endif |
4523 | 0 | default: return_trace (true); |
4524 | 0 | } |
4525 | 0 | } Unexecuted instantiation: bool OT::GSUBGPOS::sanitize<OT::Layout::GPOS_impl::PosLookup>(hb_sanitize_context_t*) const Unexecuted instantiation: bool OT::GSUBGPOS::sanitize<OT::Layout::GSUB_impl::SubstLookup>(hb_sanitize_context_t*) const |
4526 | | |
4527 | | template <typename TLookup> |
4528 | | bool subset (hb_subset_layout_context_t *c) const |
4529 | 0 | { |
4530 | 0 | switch (u.version.major) { |
4531 | 0 | case 1: return u.version1.subset<TLookup> (c); |
4532 | 0 | #ifndef HB_NO_BEYOND_64K |
4533 | 0 | case 2: return u.version2.subset<TLookup> (c); |
4534 | 0 | #endif |
4535 | 0 | default: return false; |
4536 | 0 | } |
4537 | 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 |
4538 | | |
4539 | | const ScriptList &get_script_list () const |
4540 | 0 | { |
4541 | 0 | switch (u.version.major) { |
4542 | 0 | case 1: return this+u.version1.scriptList; |
4543 | | #ifndef HB_NO_BEYOND_64K |
4544 | | case 2: return this+u.version2.scriptList; |
4545 | | #endif |
4546 | 0 | default: return Null (ScriptList); |
4547 | 0 | } |
4548 | 0 | } |
4549 | | const FeatureList &get_feature_list () const |
4550 | 0 | { |
4551 | 0 | switch (u.version.major) { |
4552 | 0 | case 1: return this+u.version1.featureList; |
4553 | | #ifndef HB_NO_BEYOND_64K |
4554 | | case 2: return this+u.version2.featureList; |
4555 | | #endif |
4556 | 0 | default: return Null (FeatureList); |
4557 | 0 | } |
4558 | 0 | } |
4559 | | unsigned int get_lookup_count () const |
4560 | 0 | { |
4561 | 0 | switch (u.version.major) { |
4562 | 0 | case 1: return (this+u.version1.lookupList).len; |
4563 | | #ifndef HB_NO_BEYOND_64K |
4564 | | case 2: return (this+u.version2.lookupList).len; |
4565 | | #endif |
4566 | 0 | default: return 0; |
4567 | 0 | } |
4568 | 0 | } |
4569 | | const Lookup& get_lookup (unsigned int i) const |
4570 | 0 | { |
4571 | 0 | switch (u.version.major) { |
4572 | 0 | case 1: return (this+u.version1.lookupList)[i]; |
4573 | | #ifndef HB_NO_BEYOND_64K |
4574 | | case 2: return (this+u.version2.lookupList)[i]; |
4575 | | #endif |
4576 | 0 | default: return Null (Lookup); |
4577 | 0 | } |
4578 | 0 | } |
4579 | | const FeatureVariations &get_feature_variations () const |
4580 | 0 | { |
4581 | 0 | switch (u.version.major) { |
4582 | 0 | case 1: return (u.version.to_int () >= 0x00010001u ? this+u.version1.featureVars : Null (FeatureVariations)); |
4583 | | #ifndef HB_NO_BEYOND_64K |
4584 | | case 2: return this+u.version2.featureVars; |
4585 | | #endif |
4586 | 0 | default: return Null (FeatureVariations); |
4587 | 0 | } |
4588 | 0 | } |
4589 | | |
4590 | 0 | bool has_data () const { return u.version.to_int (); } |
4591 | | unsigned int get_script_count () const |
4592 | 0 | { return get_script_list ().len; } |
4593 | | const Tag& get_script_tag (unsigned int i) const |
4594 | 0 | { return get_script_list ().get_tag (i); } |
4595 | | unsigned int get_script_tags (unsigned int start_offset, |
4596 | | unsigned int *script_count /* IN/OUT */, |
4597 | | hb_tag_t *script_tags /* OUT */) const |
4598 | 0 | { return get_script_list ().get_tags (start_offset, script_count, script_tags); } |
4599 | | const Script& get_script (unsigned int i) const |
4600 | 0 | { return get_script_list ()[i]; } |
4601 | | bool find_script_index (hb_tag_t tag, unsigned int *index) const |
4602 | 0 | { return get_script_list ().find_index (tag, index); } |
4603 | | |
4604 | | unsigned int get_feature_count () const |
4605 | 0 | { return get_feature_list ().len; } |
4606 | | hb_tag_t get_feature_tag (unsigned int i) const |
4607 | 0 | { return i == Index::NOT_FOUND_INDEX ? HB_TAG_NONE : get_feature_list ().get_tag (i); } |
4608 | | unsigned int get_feature_tags (unsigned int start_offset, |
4609 | | unsigned int *feature_count /* IN/OUT */, |
4610 | | hb_tag_t *feature_tags /* OUT */) const |
4611 | 0 | { return get_feature_list ().get_tags (start_offset, feature_count, feature_tags); } |
4612 | | const Feature& get_feature (unsigned int i) const |
4613 | 0 | { return get_feature_list ()[i]; } |
4614 | | bool find_feature_index (hb_tag_t tag, unsigned int *index) const |
4615 | 0 | { return get_feature_list ().find_index (tag, index); } |
4616 | | |
4617 | | bool find_variations_index (const int *coords, unsigned int num_coords, |
4618 | | unsigned int *index) const |
4619 | 0 | { |
4620 | | #ifdef HB_NO_VAR |
4621 | | *index = FeatureVariations::NOT_FOUND_INDEX; |
4622 | | return false; |
4623 | | #endif |
4624 | 0 | return get_feature_variations ().find_index (coords, num_coords, index); |
4625 | 0 | } |
4626 | | const Feature& get_feature_variation (unsigned int feature_index, |
4627 | | unsigned int variations_index) const |
4628 | 0 | { |
4629 | 0 | #ifndef HB_NO_VAR |
4630 | 0 | if (FeatureVariations::NOT_FOUND_INDEX != variations_index && |
4631 | 0 | u.version.to_int () >= 0x00010001u) |
4632 | 0 | { |
4633 | 0 | const Feature *feature = get_feature_variations ().find_substitute (variations_index, |
4634 | 0 | feature_index); |
4635 | 0 | if (feature) |
4636 | 0 | return *feature; |
4637 | 0 | } |
4638 | 0 | #endif |
4639 | 0 | return get_feature (feature_index); |
4640 | 0 | } |
4641 | | |
4642 | | void feature_variation_collect_lookups (const hb_set_t *feature_indexes, |
4643 | | const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map, |
4644 | | hb_set_t *lookup_indexes /* OUT */) const |
4645 | 0 | { |
4646 | 0 | #ifndef HB_NO_VAR |
4647 | 0 | get_feature_variations ().collect_lookups (feature_indexes, feature_record_cond_idx_map, lookup_indexes); |
4648 | 0 | #endif |
4649 | 0 | } |
4650 | | |
4651 | | #ifndef HB_NO_VAR |
4652 | | void collect_feature_substitutes_with_variations (hb_collect_feature_substitutes_with_var_context_t *c) const |
4653 | 0 | { get_feature_variations ().collect_feature_substitutes_with_variations (c); } |
4654 | | #endif |
4655 | | |
4656 | | template <typename TLookup> |
4657 | | void closure_lookups (hb_face_t *face, |
4658 | | const hb_set_t *glyphs, |
4659 | | hb_set_t *lookup_indexes /* IN/OUT */) const |
4660 | 0 | { |
4661 | 0 | hb_set_t visited_lookups, inactive_lookups; |
4662 | 0 | hb_closure_lookups_context_t c (face, glyphs, &visited_lookups, &inactive_lookups); |
4663 | 0 |
|
4664 | 0 | c.set_recurse_func (TLookup::template dispatch_recurse_func<hb_closure_lookups_context_t>); |
4665 | 0 |
|
4666 | 0 | for (unsigned lookup_index : *lookup_indexes) |
4667 | 0 | reinterpret_cast<const TLookup &> (get_lookup (lookup_index)).closure_lookups (&c, lookup_index); |
4668 | 0 |
|
4669 | 0 | hb_set_union (lookup_indexes, &visited_lookups); |
4670 | 0 | hb_set_subtract (lookup_indexes, &inactive_lookups); |
4671 | 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 |
4672 | | |
4673 | | void prune_langsys (const hb_map_t *duplicate_feature_map, |
4674 | | const hb_set_t *layout_scripts, |
4675 | | hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *script_langsys_map, |
4676 | | hb_set_t *new_feature_indexes /* OUT */) const |
4677 | 0 | { |
4678 | 0 | hb_prune_langsys_context_t c (this, script_langsys_map, duplicate_feature_map, new_feature_indexes); |
4679 | 0 |
|
4680 | 0 | unsigned count = get_script_count (); |
4681 | 0 | for (unsigned script_index = 0; script_index < count; script_index++) |
4682 | 0 | { |
4683 | 0 | const Tag& tag = get_script_tag (script_index); |
4684 | 0 | if (!layout_scripts->has (tag)) continue; |
4685 | 0 | const Script& s = get_script (script_index); |
4686 | 0 | s.prune_langsys (&c, script_index); |
4687 | 0 | } |
4688 | 0 | } |
4689 | | |
4690 | | void prune_features (const hb_map_t *lookup_indices, /* IN */ |
4691 | | const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map, /* IN */ |
4692 | | const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map, /* IN */ |
4693 | | hb_set_t *feature_indices /* IN/OUT */) const |
4694 | 0 | { |
4695 | 0 | #ifndef HB_NO_VAR |
4696 | 0 | // This is the set of feature indices which have alternate versions defined |
4697 | 0 | // if the FeatureVariation's table and the alternate version(s) intersect the |
4698 | 0 | // set of lookup indices. |
4699 | 0 | hb_set_t alternate_feature_indices; |
4700 | 0 | get_feature_variations ().closure_features (lookup_indices, feature_record_cond_idx_map, &alternate_feature_indices); |
4701 | 0 | if (unlikely (alternate_feature_indices.in_error())) |
4702 | 0 | { |
4703 | 0 | feature_indices->err (); |
4704 | 0 | return; |
4705 | 0 | } |
4706 | 0 | #endif |
4707 | 0 |
|
4708 | 0 | for (unsigned i : hb_iter (feature_indices)) |
4709 | 0 | { |
4710 | 0 | hb_tag_t tag = get_feature_tag (i); |
4711 | 0 | if (tag == HB_TAG ('p', 'r', 'e', 'f')) |
4712 | 0 | // Note: Never ever drop feature 'pref', even if it's empty. |
4713 | 0 | // HarfBuzz chooses shaper for Khmer based on presence of this |
4714 | 0 | // feature. See thread at: |
4715 | 0 | // http://lists.freedesktop.org/archives/harfbuzz/2012-November/002660.html |
4716 | 0 | continue; |
4717 | 0 |
|
4718 | 0 |
|
4719 | 0 | const Feature *f = &(get_feature (i)); |
4720 | 0 | const Feature** p = nullptr; |
4721 | 0 | if (feature_substitutes_map->has (i, &p)) |
4722 | 0 | f = *p; |
4723 | 0 |
|
4724 | 0 | if (!f->featureParams.is_null () && |
4725 | 0 | tag == HB_TAG ('s', 'i', 'z', 'e')) |
4726 | 0 | continue; |
4727 | 0 |
|
4728 | 0 | if (!f->intersects_lookup_indexes (lookup_indices) |
4729 | 0 | #ifndef HB_NO_VAR |
4730 | 0 | && !alternate_feature_indices.has (i) |
4731 | 0 | #endif |
4732 | 0 | ) |
4733 | 0 | feature_indices->del (i); |
4734 | 0 | } |
4735 | 0 | } |
4736 | | |
4737 | | void collect_name_ids (const hb_map_t *feature_index_map, |
4738 | | hb_set_t *nameids_to_retain /* OUT */) const |
4739 | 0 | { |
4740 | 0 | unsigned count = get_feature_count (); |
4741 | 0 | for (unsigned i = 0 ; i < count; i++) |
4742 | 0 | { |
4743 | 0 | if (!feature_index_map->has (i)) continue; |
4744 | 0 | hb_tag_t tag = get_feature_tag (i); |
4745 | 0 | get_feature (i).collect_name_ids (tag, nameids_to_retain); |
4746 | 0 | } |
4747 | 0 | } |
4748 | | |
4749 | | template <typename T> |
4750 | | struct accelerator_t |
4751 | | { |
4752 | | accelerator_t (hb_face_t *face) |
4753 | 0 | { |
4754 | 0 | hb_sanitize_context_t sc; |
4755 | 0 | sc.lazy_some_gpos = true; |
4756 | 0 | this->table = sc.reference_table<T> (face); |
4757 | |
|
4758 | 0 | if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face))) |
4759 | 0 | { |
4760 | 0 | hb_blob_destroy (this->table.get_blob ()); |
4761 | 0 | this->table = hb_blob_get_empty (); |
4762 | 0 | } |
4763 | |
|
4764 | 0 | this->lookup_count = table->get_lookup_count (); |
4765 | |
|
4766 | 0 | this->accels = (hb_atomic_ptr_t<hb_ot_layout_lookup_accelerator_t> *) hb_calloc (this->lookup_count, sizeof (*accels)); |
4767 | 0 | if (unlikely (!this->accels)) |
4768 | 0 | { |
4769 | 0 | this->lookup_count = 0; |
4770 | 0 | this->table.destroy (); |
4771 | 0 | this->table = hb_blob_get_empty (); |
4772 | 0 | } |
4773 | 0 | } Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::accelerator_t(hb_face_t*) Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::accelerator_t(hb_face_t*) |
4774 | | ~accelerator_t () |
4775 | 0 | { |
4776 | 0 | for (unsigned int i = 0; i < this->lookup_count; i++) |
4777 | 0 | hb_free (this->accels[i]); |
4778 | 0 | hb_free (this->accels); |
4779 | 0 | this->table.destroy (); |
4780 | 0 | } Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::~accelerator_t() Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::~accelerator_t() |
4781 | | |
4782 | 0 | hb_blob_t *get_blob () const { return table.get_blob (); }Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::get_blob() const Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::get_blob() const |
4783 | | |
4784 | | hb_ot_layout_lookup_accelerator_t *get_accel (unsigned lookup_index) const |
4785 | 0 | { |
4786 | 0 | if (unlikely (lookup_index >= lookup_count)) return nullptr; |
4787 | | |
4788 | 0 | retry: |
4789 | 0 | auto *accel = accels[lookup_index].get_acquire (); |
4790 | 0 | if (unlikely (!accel)) |
4791 | 0 | { |
4792 | 0 | accel = hb_ot_layout_lookup_accelerator_t::create (table->get_lookup (lookup_index)); |
4793 | 0 | if (unlikely (!accel)) |
4794 | 0 | return nullptr; |
4795 | | |
4796 | 0 | if (unlikely (!accels[lookup_index].cmpexch (nullptr, accel))) |
4797 | 0 | { |
4798 | 0 | hb_free (accel); |
4799 | 0 | goto retry; |
4800 | 0 | } |
4801 | 0 | } |
4802 | | |
4803 | 0 | return accel; |
4804 | 0 | } Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::get_accel(unsigned int) const Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::get_accel(unsigned int) const |
4805 | | |
4806 | | hb_blob_ptr_t<T> table; |
4807 | | unsigned int lookup_count; |
4808 | | hb_atomic_ptr_t<hb_ot_layout_lookup_accelerator_t> *accels; |
4809 | | }; |
4810 | | |
4811 | | protected: |
4812 | | union { |
4813 | | FixedVersion<> version; /* Version identifier */ |
4814 | | GSUBGPOSVersion1_2<SmallTypes> version1; |
4815 | | #ifndef HB_NO_BEYOND_64K |
4816 | | GSUBGPOSVersion1_2<MediumTypes> version2; |
4817 | | #endif |
4818 | | } u; |
4819 | | public: |
4820 | | DEFINE_SIZE_MIN (4); |
4821 | | }; |
4822 | | |
4823 | | |
4824 | | } /* namespace OT */ |
4825 | | |
4826 | | |
4827 | | #endif /* HB_OT_LAYOUT_GSUBGPOS_HH */ |