/work/workdir/UnpackedTarball/harfbuzz/src/hb-aat-layout-common.hh
Line | Count | Source |
1 | | /* |
2 | | * Copyright © 2017 Google, Inc. |
3 | | * |
4 | | * This is part of HarfBuzz, a text shaping library. |
5 | | * |
6 | | * Permission is hereby granted, without written agreement and without |
7 | | * license or royalty fees, to use, copy, modify, and distribute this |
8 | | * software and its documentation for any purpose, provided that the |
9 | | * above copyright notice and the following two paragraphs appear in |
10 | | * all copies of this software. |
11 | | * |
12 | | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
13 | | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
14 | | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
15 | | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
16 | | * DAMAGE. |
17 | | * |
18 | | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
19 | | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
20 | | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
21 | | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
22 | | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
23 | | * |
24 | | * Google Author(s): Behdad Esfahbod |
25 | | */ |
26 | | |
27 | | #ifndef HB_AAT_LAYOUT_COMMON_HH |
28 | | #define HB_AAT_LAYOUT_COMMON_HH |
29 | | |
30 | | #include "hb-aat-layout.hh" |
31 | | #include "hb-aat-map.hh" |
32 | | #include "hb-ot-layout-common.hh" |
33 | | #include "hb-ot-layout-gdef-table.hh" |
34 | | #include "hb-open-type.hh" |
35 | | #include "hb-cache.hh" |
36 | | #include "hb-bit-set.hh" |
37 | | #include "hb-bit-page.hh" |
38 | | |
39 | | |
40 | | namespace OT { |
41 | | struct GDEF; |
42 | | }; |
43 | | |
44 | | namespace AAT { |
45 | | |
46 | | using namespace OT; |
47 | | |
48 | | struct ankr; |
49 | | |
50 | | using hb_aat_class_cache_t = hb_ot_layout_mapping_cache_t; |
51 | | |
52 | | /* The state-machine subtables' transition functions are called once per |
53 | | * transition from the drive loop, but are big enough that the compiler |
54 | | * declines to inline them, leaving a call in the hottest loop of AAT |
55 | | * shaping. Forcing them inline is worth 3-10% instructions on |
56 | | * morx/kerx-heavy fonts, for about 16KB of code. */ |
57 | | #ifndef HB_OPTIMIZE_SIZE |
58 | | #define HB_AAT_TRANSITION_INLINE HB_ALWAYS_INLINE |
59 | | #else |
60 | | #define HB_AAT_TRANSITION_INLINE |
61 | | #endif |
62 | | |
63 | | struct hb_aat_scratch_t |
64 | | { |
65 | 72.2k | hb_aat_scratch_t () = default; |
66 | | hb_aat_scratch_t (const hb_aat_scratch_t &) = delete; |
67 | | |
68 | | hb_aat_scratch_t (hb_aat_scratch_t &&o) |
69 | 0 | { |
70 | 0 | buffer_glyph_set.set_relaxed (o.buffer_glyph_set.get_relaxed ()); |
71 | 0 | o.buffer_glyph_set.set_relaxed (nullptr); |
72 | 0 | } |
73 | | hb_aat_scratch_t & operator = (hb_aat_scratch_t &&o) |
74 | 18.0k | { |
75 | 18.0k | buffer_glyph_set.set_relaxed (o.buffer_glyph_set.get_relaxed ()); |
76 | 18.0k | o.buffer_glyph_set.set_relaxed (nullptr); |
77 | 18.0k | return *this; |
78 | 18.0k | } |
79 | | ~hb_aat_scratch_t () |
80 | 71.9k | { |
81 | 71.9k | auto *s = buffer_glyph_set.get_relaxed (); |
82 | 71.9k | if (unlikely (!s)) |
83 | 71.4k | return; |
84 | 418 | s->fini (); |
85 | 418 | hb_free (s); |
86 | 418 | } |
87 | | |
88 | | hb_bit_set_t *create_buffer_glyph_set () const |
89 | 18.2M | { |
90 | 18.2M | hb_bit_set_t *s = buffer_glyph_set.get_acquire (); |
91 | 18.2M | if (s && buffer_glyph_set.cmpexch (s, nullptr)) |
92 | 18.2M | { |
93 | 18.2M | s->clear (); |
94 | 18.2M | return s; |
95 | 18.2M | } |
96 | | |
97 | 470 | s = (hb_bit_set_t *) hb_calloc (1, sizeof (hb_bit_set_t)); |
98 | 470 | if (unlikely (!s)) |
99 | 0 | return nullptr; |
100 | 470 | s->init (); |
101 | | |
102 | 470 | return s; |
103 | 470 | } |
104 | | void destroy_buffer_glyph_set (hb_bit_set_t *s) const |
105 | 18.2M | { |
106 | 18.2M | if (unlikely (!s)) |
107 | 0 | return; |
108 | 18.2M | if (buffer_glyph_set.cmpexch (nullptr, s)) |
109 | 18.2M | return; |
110 | 0 | s->fini (); |
111 | 0 | hb_free (s); |
112 | 0 | } |
113 | | |
114 | | mutable hb_atomic_t<hb_bit_set_t *> buffer_glyph_set; |
115 | | }; |
116 | | |
117 | | enum { DELETED_GLYPH = 0xFFFF }; |
118 | | |
119 | 0 | #define HB_BUFFER_SCRATCH_FLAG_AAT_HAS_DELETED HB_BUFFER_SCRATCH_FLAG_SHAPER0 |
120 | | |
121 | | struct hb_aat_apply_context_t : |
122 | | hb_dispatch_context_t<hb_aat_apply_context_t, bool, HB_DEBUG_APPLY> |
123 | | { |
124 | 0 | const char *get_name () { return "APPLY"; } |
125 | | template <typename T, typename ...Ts> |
126 | | return_t dispatch (const T &obj, Ts&&... ds) |
127 | 21.7M | { return obj.apply (this, std::forward<Ts> (ds)...); }Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::RearrangementSubtable<AAT::ExtendedTypes>>(AAT::RearrangementSubtable<AAT::ExtendedTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::ContextualSubtable<AAT::ExtendedTypes>>(AAT::ContextualSubtable<AAT::ExtendedTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::LigatureSubtable<AAT::ExtendedTypes>>(AAT::LigatureSubtable<AAT::ExtendedTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::NoncontextualSubtable<AAT::ExtendedTypes>>(AAT::NoncontextualSubtable<AAT::ExtendedTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::InsertionSubtable<AAT::ExtendedTypes>>(AAT::InsertionSubtable<AAT::ExtendedTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::RearrangementSubtable<AAT::ObsoleteTypes>>(AAT::RearrangementSubtable<AAT::ObsoleteTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::ContextualSubtable<AAT::ObsoleteTypes>>(AAT::ContextualSubtable<AAT::ObsoleteTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::LigatureSubtable<AAT::ObsoleteTypes>>(AAT::LigatureSubtable<AAT::ObsoleteTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::NoncontextualSubtable<AAT::ObsoleteTypes>>(AAT::NoncontextualSubtable<AAT::ObsoleteTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::InsertionSubtable<AAT::ObsoleteTypes>>(AAT::InsertionSubtable<AAT::ObsoleteTypes> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat0<AAT::KerxSubTableHeader>>(AAT::KerxSubTableFormat0<AAT::KerxSubTableHeader> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader>>(AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat2<AAT::KerxSubTableHeader>>(AAT::KerxSubTableFormat2<AAT::KerxSubTableHeader> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>>(AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat6<AAT::KerxSubTableHeader>>(AAT::KerxSubTableFormat6<AAT::KerxSubTableHeader> const&) bool AAT::hb_aat_apply_context_t::dispatch<OT::KernOT, AAT::kern_accelerator_data_t const&>(OT::KernOT const&, AAT::kern_accelerator_data_t const&) Line | Count | Source | 127 | 18.2M | { return obj.apply (this, std::forward<Ts> (ds)...); } |
bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat0<OT::KernOTSubTableHeader>>(AAT::KerxSubTableFormat0<OT::KernOTSubTableHeader> const&) Line | Count | Source | 127 | 3.44M | { return obj.apply (this, std::forward<Ts> (ds)...); } |
Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader>>(AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader> const&) bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat2<OT::KernOTSubTableHeader>>(AAT::KerxSubTableFormat2<OT::KernOTSubTableHeader> const&) Line | Count | Source | 127 | 4 | { return obj.apply (this, std::forward<Ts> (ds)...); } |
bool AAT::hb_aat_apply_context_t::dispatch<OT::KernSubTableFormat3<OT::KernOTSubTableHeader>>(OT::KernSubTableFormat3<OT::KernOTSubTableHeader> const&) Line | Count | Source | 127 | 8 | { return obj.apply (this, std::forward<Ts> (ds)...); } |
bool AAT::hb_aat_apply_context_t::dispatch<OT::KernAAT, AAT::kern_accelerator_data_t const&>(OT::KernAAT const&, AAT::kern_accelerator_data_t const&) Line | Count | Source | 127 | 113 | { return obj.apply (this, std::forward<Ts> (ds)...); } |
Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat0<OT::KernAATSubTableHeader>>(AAT::KerxSubTableFormat0<OT::KernAATSubTableHeader> const&) Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader>>(AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader> const&) bool AAT::hb_aat_apply_context_t::dispatch<AAT::KerxSubTableFormat2<OT::KernAATSubTableHeader>>(AAT::KerxSubTableFormat2<OT::KernAATSubTableHeader> const&) Line | Count | Source | 127 | 4 | { return obj.apply (this, std::forward<Ts> (ds)...); } |
Unexecuted instantiation: bool AAT::hb_aat_apply_context_t::dispatch<OT::KernSubTableFormat3<OT::KernAATSubTableHeader>>(OT::KernSubTableFormat3<OT::KernAATSubTableHeader> const&) |
128 | 1.29k | static return_t default_return_value () { return false; } |
129 | 0 | bool stop_sublookup_iteration (return_t r) const { return r; } |
130 | | |
131 | | const hb_ot_shape_plan_t *plan; |
132 | | hb_font_t *font; |
133 | | hb_face_t *face; |
134 | | hb_buffer_t *buffer; |
135 | | hb_sanitize_context_t sanitizer; |
136 | | const ankr *ankr_table; |
137 | | const OT::GDEF &gdef; |
138 | | bool has_glyph_classes; |
139 | | const hb_sorted_vector_t<hb_aat_map_t::range_flags_t> *range_flags = nullptr; |
140 | | hb_mask_t subtable_flags = 0; |
141 | | bool buffer_is_reversed = false; |
142 | | // Caches |
143 | | bool using_buffer_glyph_set = false; |
144 | | hb_bit_set_t *buffer_glyph_set = nullptr; |
145 | | const hb_bit_set_t *first_set = nullptr; |
146 | | const hb_bit_set_t *second_set = nullptr; |
147 | | hb_aat_class_cache_t *machine_class_cache = nullptr; |
148 | | |
149 | | /* Unused. For debug tracing only. */ |
150 | | unsigned int lookup_index; |
151 | | |
152 | | HB_INTERNAL hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_, |
153 | | hb_font_t *font_, |
154 | | hb_buffer_t *buffer_, |
155 | | hb_blob_t *blob = const_cast<hb_blob_t *> (&Null (hb_blob_t))); |
156 | | |
157 | | HB_INTERNAL ~hb_aat_apply_context_t (); |
158 | | |
159 | | HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_); |
160 | | |
161 | 36.5M | void set_lookup_index (unsigned int i) { lookup_index = i; } |
162 | | |
163 | | void reverse_buffer () |
164 | 37.7k | { |
165 | 37.7k | buffer->reverse (); |
166 | 37.7k | buffer_is_reversed = !buffer_is_reversed; |
167 | 37.7k | } |
168 | | |
169 | | void setup_buffer_glyph_set () |
170 | 18.2M | { |
171 | 18.2M | using_buffer_glyph_set = buffer->len >= 4 && buffer_glyph_set; |
172 | | |
173 | 18.2M | if (likely (using_buffer_glyph_set)) |
174 | 3.01M | buffer->collect_codepoints (*buffer_glyph_set); |
175 | 18.2M | } |
176 | | bool buffer_intersects_machine () const |
177 | 18.0M | { |
178 | 18.0M | if (likely (using_buffer_glyph_set)) |
179 | 2.97M | return buffer_glyph_set->intersects (*first_set); |
180 | | |
181 | | // Faster for shorter buffers. |
182 | 31.4M | for (unsigned i = 0; i < buffer->len; i++) |
183 | 18.7M | if (first_set->has (buffer->info[i].codepoint)) |
184 | 2.47M | return true; |
185 | 12.6M | return false; |
186 | 15.1M | } |
187 | | |
188 | | template <typename T> |
189 | | HB_NODISCARD bool output_glyphs (unsigned int count, |
190 | | const T *glyphs) |
191 | 0 | { |
192 | 0 | if (likely (using_buffer_glyph_set)) |
193 | 0 | buffer_glyph_set->add_array (glyphs, count); |
194 | 0 | for (unsigned int i = 0; i < count; i++) |
195 | 0 | { |
196 | 0 | bool at_end_of_text = buffer->idx == buffer->len; |
197 | 0 | if (at_end_of_text) |
198 | 0 | if (unlikely (!buffer->output_glyph (glyphs[i]))) return false; |
199 | | |
200 | 0 | hb_glyph_info_t &info = at_end_of_text ? buffer->prev () : buffer->cur (); |
201 | 0 | if (glyphs[i] == DELETED_GLYPH) |
202 | 0 | { |
203 | 0 | buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_AAT_HAS_DELETED; |
204 | 0 | _hb_glyph_info_set_aat_deleted (&info); |
205 | 0 | } |
206 | 0 | else |
207 | 0 | { |
208 | 0 | #ifndef HB_NO_OT_LAYOUT |
209 | 0 | if (has_glyph_classes) |
210 | 0 | _hb_glyph_info_set_glyph_props (&info, |
211 | 0 | gdef.get_glyph_props (glyphs[i])); |
212 | 0 | #endif |
213 | 0 | } |
214 | 0 | if (!at_end_of_text) |
215 | 0 | if (unlikely (!buffer->output_glyph (glyphs[i]))) return false; |
216 | 0 | } |
217 | 0 | return true; |
218 | 0 | } |
219 | | |
220 | | HB_NODISCARD bool replace_glyph (hb_codepoint_t glyph) |
221 | 0 | { |
222 | 0 | if (glyph == DELETED_GLYPH) |
223 | 0 | { |
224 | 0 | buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_AAT_HAS_DELETED; |
225 | 0 | _hb_glyph_info_set_aat_deleted (&buffer->cur()); |
226 | 0 | } |
227 | |
|
228 | 0 | if (likely (using_buffer_glyph_set)) |
229 | 0 | buffer_glyph_set->add (glyph); |
230 | 0 | #ifndef HB_NO_OT_LAYOUT |
231 | 0 | if (has_glyph_classes) |
232 | 0 | _hb_glyph_info_set_glyph_props (&buffer->cur(), |
233 | 0 | gdef.get_glyph_props (glyph)); |
234 | 0 | #endif |
235 | 0 | return buffer->replace_glyph (glyph); |
236 | 0 | } |
237 | | |
238 | | HB_NODISCARD bool delete_glyph () |
239 | 0 | { |
240 | 0 | buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_AAT_HAS_DELETED; |
241 | 0 | _hb_glyph_info_set_aat_deleted (&buffer->cur()); |
242 | 0 | if (likely (using_buffer_glyph_set)) |
243 | 0 | buffer_glyph_set->add (DELETED_GLYPH); |
244 | 0 | return buffer->replace_glyph (DELETED_GLYPH); |
245 | 0 | } |
246 | | |
247 | | void replace_glyph_inplace (unsigned i, hb_codepoint_t glyph) |
248 | 0 | { |
249 | 0 | buffer->info[i].codepoint = glyph; |
250 | 0 | if (glyph == DELETED_GLYPH) |
251 | 0 | { |
252 | 0 | buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_AAT_HAS_DELETED; |
253 | 0 | _hb_glyph_info_set_aat_deleted (&buffer->info[i]); |
254 | 0 | } |
255 | 0 | if (likely (using_buffer_glyph_set)) |
256 | 0 | buffer_glyph_set->add (glyph); |
257 | 0 | #ifndef HB_NO_OT_LAYOUT |
258 | 0 | if (has_glyph_classes) |
259 | 0 | _hb_glyph_info_set_glyph_props (&buffer->info[i], |
260 | 0 | gdef.get_glyph_props (glyph)); |
261 | 0 | #endif |
262 | 0 | } |
263 | | }; |
264 | | |
265 | | |
266 | | /* |
267 | | * Lookup Table |
268 | | */ |
269 | | |
270 | | template <typename T> struct Lookup; |
271 | | |
272 | | template <typename T> |
273 | | struct LookupFormat0 |
274 | | { |
275 | | friend struct Lookup<T>; |
276 | | |
277 | | private: |
278 | | const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const |
279 | 0 | { |
280 | 0 | if (unlikely (glyph_id >= num_glyphs)) return nullptr; |
281 | 0 | return &arrayZ[glyph_id]; |
282 | 0 | } Unexecuted instantiation: AAT::LookupFormat0<OT::NumType<true, unsigned short, 2u> >::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::LookupFormat0<OT::HBGlyphID16>::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::LookupFormat0<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::LookupFormat0<OT::NumType<true, unsigned int, 4u> >::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::LookupFormat0<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::get_value(unsigned int, unsigned int) const |
283 | | |
284 | | template <typename set_t> |
285 | | void collect_glyphs (set_t &glyphs, unsigned num_glyphs) const |
286 | 0 | { |
287 | 0 | glyphs.add_range (0, num_glyphs - 1); |
288 | 0 | } Unexecuted instantiation: void AAT::LookupFormat0<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const Unexecuted instantiation: void AAT::LookupFormat0<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const Unexecuted instantiation: void AAT::LookupFormat0<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const |
289 | | template <typename set_t, typename filter_t> |
290 | | void collect_glyphs_filtered (set_t &glyphs, unsigned num_glyphs, const filter_t &filter) const |
291 | 0 | { |
292 | 0 | for (unsigned i = 0; i < num_glyphs; i++) |
293 | 0 | if (filter (arrayZ[i])) |
294 | 0 | glyphs.add (i); |
295 | 0 | } |
296 | | |
297 | | bool sanitize (hb_sanitize_context_t *c) const |
298 | 0 | { |
299 | 0 | TRACE_SANITIZE (this); |
300 | 0 | return_trace (arrayZ.sanitize (c, c->get_num_glyphs ())); |
301 | 0 | } Unexecuted instantiation: AAT::LookupFormat0<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat0<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat0<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
302 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
303 | 0 | { |
304 | 0 | TRACE_SANITIZE (this); |
305 | 0 | return_trace (arrayZ.sanitize (c, c->get_num_glyphs (), base)); |
306 | 0 | } Unexecuted instantiation: AAT::LookupFormat0<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat0<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat0<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
307 | | |
308 | | protected: |
309 | | HBUINT16 format; /* Format identifier--format = 0 */ |
310 | | UnsizedArrayOf<T> |
311 | | arrayZ; /* Array of lookup values, indexed by glyph index. */ |
312 | | public: |
313 | | DEFINE_SIZE_UNBOUNDED (2); |
314 | | }; |
315 | | |
316 | | |
317 | | template <typename T> |
318 | | struct LookupSegmentSingle |
319 | | { |
320 | | static constexpr unsigned TerminationWordCount = 2u; |
321 | | |
322 | | int cmp (hb_codepoint_t g) const |
323 | 0 | { return g < first ? -1 : g <= last ? 0 : +1 ; }Unexecuted instantiation: AAT::LookupSegmentSingle<OT::NumType<true, unsigned short, 2u> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::HBGlyphID16>::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::NumType<true, unsigned int, 4u> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::cmp(unsigned int) const |
324 | | |
325 | | template <typename set_t> |
326 | | void collect_glyphs (set_t &glyphs) const |
327 | 0 | { |
328 | 0 | if (first == DELETED_GLYPH) return; |
329 | 0 | glyphs.add_range (first, last); |
330 | 0 | } Unexecuted instantiation: void AAT::LookupSegmentSingle<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupSegmentSingle<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupSegmentSingle<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
331 | | template <typename set_t, typename filter_t> |
332 | | void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const |
333 | 0 | { |
334 | 0 | if (first == DELETED_GLYPH) return; |
335 | 0 | if (!filter (value)) return; |
336 | 0 | glyphs.add_range (first, last); |
337 | 0 | } |
338 | | |
339 | | bool sanitize (hb_sanitize_context_t *c) const |
340 | 0 | { |
341 | 0 | TRACE_SANITIZE (this); |
342 | 0 | return_trace (c->check_struct (this) && value.sanitize (c)); |
343 | 0 | } Unexecuted instantiation: AAT::LookupSegmentSingle<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
344 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
345 | 0 | { |
346 | 0 | TRACE_SANITIZE (this); |
347 | 0 | return_trace (c->check_struct (this) && value.sanitize (c, base)); |
348 | 0 | } Unexecuted instantiation: AAT::LookupSegmentSingle<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupSegmentSingle<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
349 | | |
350 | | HBGlyphID16 last; /* Last GlyphID in this segment */ |
351 | | HBGlyphID16 first; /* First GlyphID in this segment */ |
352 | | T value; /* The lookup value (only one) */ |
353 | | public: |
354 | | DEFINE_SIZE_STATIC (4 + T::static_size); |
355 | | }; |
356 | | |
357 | | template <typename T> |
358 | | struct LookupFormat2 |
359 | | { |
360 | | friend struct Lookup<T>; |
361 | | |
362 | | private: |
363 | | const T* get_value (hb_codepoint_t glyph_id) const |
364 | 0 | { |
365 | 0 | const LookupSegmentSingle<T> *v = segments.bsearch (glyph_id); |
366 | 0 | return v ? &v->value : nullptr; |
367 | 0 | } Unexecuted instantiation: AAT::LookupFormat2<OT::NumType<true, unsigned short, 2u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat2<OT::HBGlyphID16>::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat2<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat2<OT::NumType<true, unsigned int, 4u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat2<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::get_value(unsigned int) const |
368 | | |
369 | | template <typename set_t> |
370 | | void collect_glyphs (set_t &glyphs) const |
371 | 0 | { |
372 | 0 | unsigned count = segments.get_length (); |
373 | 0 | for (unsigned int i = 0; i < count; i++) |
374 | 0 | segments[i].collect_glyphs (glyphs); |
375 | 0 | } Unexecuted instantiation: void AAT::LookupFormat2<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat2<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat2<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
376 | | template <typename set_t, typename filter_t> |
377 | | void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const |
378 | 0 | { |
379 | 0 | unsigned count = segments.get_length (); |
380 | 0 | for (unsigned int i = 0; i < count; i++) |
381 | 0 | segments[i].collect_glyphs_filtered (glyphs, filter); |
382 | 0 | } |
383 | | |
384 | | bool sanitize (hb_sanitize_context_t *c) const |
385 | 0 | { |
386 | 0 | TRACE_SANITIZE (this); |
387 | 0 | return_trace (segments.sanitize (c)); |
388 | 0 | } Unexecuted instantiation: AAT::LookupFormat2<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat2<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat2<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
389 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
390 | 0 | { |
391 | 0 | TRACE_SANITIZE (this); |
392 | 0 | return_trace (segments.sanitize (c, base)); |
393 | 0 | } Unexecuted instantiation: AAT::LookupFormat2<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat2<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat2<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
394 | | |
395 | | protected: |
396 | | HBUINT16 format; /* Format identifier--format = 2 */ |
397 | | VarSizedBinSearchArrayOf<LookupSegmentSingle<T>> |
398 | | segments; /* The actual segments. These must already be sorted, |
399 | | * according to the first word in each one (the last |
400 | | * glyph in each segment). */ |
401 | | public: |
402 | | DEFINE_SIZE_ARRAY (8, segments); |
403 | | }; |
404 | | |
405 | | template <typename T> |
406 | | struct LookupSegmentArray |
407 | | { |
408 | | static constexpr unsigned TerminationWordCount = 2u; |
409 | | |
410 | | const T* get_value (hb_codepoint_t glyph_id, const void *base) const |
411 | 0 | { |
412 | 0 | return first <= glyph_id && glyph_id <= last ? &(base+valuesZ)[glyph_id - first] : nullptr; |
413 | 0 | } Unexecuted instantiation: AAT::LookupSegmentArray<OT::NumType<true, unsigned short, 2u> >::get_value(unsigned int, void const*) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::HBGlyphID16>::get_value(unsigned int, void const*) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::get_value(unsigned int, void const*) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::NumType<true, unsigned int, 4u> >::get_value(unsigned int, void const*) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::get_value(unsigned int, void const*) const |
414 | | |
415 | | template <typename set_t> |
416 | | void collect_glyphs (set_t &glyphs) const |
417 | 0 | { |
418 | 0 | if (first == DELETED_GLYPH) return; |
419 | 0 | glyphs.add_range (first, last); |
420 | 0 | } Unexecuted instantiation: void AAT::LookupSegmentArray<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupSegmentArray<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupSegmentArray<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
421 | | template <typename set_t, typename filter_t> |
422 | | void collect_glyphs_filtered (set_t &glyphs, const void *base, const filter_t &filter) const |
423 | 0 | { |
424 | 0 | if (first == DELETED_GLYPH) return; |
425 | 0 | const auto &values = base+valuesZ; |
426 | 0 | for (hb_codepoint_t i = first; i <= last; i++) |
427 | 0 | if (filter (values[i - first])) |
428 | 0 | glyphs.add (i); |
429 | 0 | } |
430 | | |
431 | | int cmp (hb_codepoint_t g) const |
432 | 0 | { return g < first ? -1 : g <= last ? 0 : +1; }Unexecuted instantiation: AAT::LookupSegmentArray<OT::NumType<true, unsigned short, 2u> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::HBGlyphID16>::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::NumType<true, unsigned int, 4u> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::cmp(unsigned int) const |
433 | | |
434 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
435 | 0 | { |
436 | 0 | TRACE_SANITIZE (this); |
437 | 0 | return_trace (c->check_struct (this) && |
438 | 0 | hb_barrier () && |
439 | 0 | first <= last && |
440 | 0 | valuesZ.sanitize (c, base, last - first + 1)); |
441 | 0 | } Unexecuted instantiation: AAT::LookupSegmentArray<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupSegmentArray<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*, void const*) const |
442 | | template <typename ...Ts> |
443 | | bool sanitize (hb_sanitize_context_t *c, const void *base, Ts&&... ds) const |
444 | 0 | { |
445 | 0 | TRACE_SANITIZE (this); |
446 | 0 | return_trace (c->check_struct (this) && |
447 | 0 | hb_barrier () && |
448 | 0 | first <= last && |
449 | 0 | valuesZ.sanitize (c, base, last - first + 1, std::forward<Ts> (ds)...)); |
450 | 0 | } Unexecuted instantiation: bool AAT::LookupSegmentArray<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize<void const*&>(hb_sanitize_context_t*, void const*, void const*&) const Unexecuted instantiation: bool AAT::LookupSegmentArray<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize<void const*&>(hb_sanitize_context_t*, void const*, void const*&) const Unexecuted instantiation: bool AAT::LookupSegmentArray<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize<void const*&>(hb_sanitize_context_t*, void const*, void const*&) const |
451 | | |
452 | | HBGlyphID16 last; /* Last GlyphID in this segment */ |
453 | | HBGlyphID16 first; /* First GlyphID in this segment */ |
454 | | NNOffset16To<UnsizedArrayOf<T>> |
455 | | valuesZ; /* A 16-bit offset from the start of |
456 | | * the table to the data. */ |
457 | | public: |
458 | | DEFINE_SIZE_STATIC (6); |
459 | | }; |
460 | | |
461 | | template <typename T> |
462 | | struct LookupFormat4 |
463 | | { |
464 | | friend struct Lookup<T>; |
465 | | |
466 | | private: |
467 | | const T* get_value (hb_codepoint_t glyph_id) const |
468 | 0 | { |
469 | 0 | const LookupSegmentArray<T> *v = segments.bsearch (glyph_id); |
470 | 0 | return v ? v->get_value (glyph_id, this) : nullptr; |
471 | 0 | } Unexecuted instantiation: AAT::LookupFormat4<OT::NumType<true, unsigned short, 2u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat4<OT::HBGlyphID16>::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat4<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat4<OT::NumType<true, unsigned int, 4u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat4<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::get_value(unsigned int) const |
472 | | |
473 | | template <typename set_t> |
474 | | void collect_glyphs (set_t &glyphs) const |
475 | 0 | { |
476 | 0 | unsigned count = segments.get_length (); |
477 | 0 | for (unsigned i = 0; i < count; i++) |
478 | 0 | segments[i].collect_glyphs (glyphs); |
479 | 0 | } Unexecuted instantiation: void AAT::LookupFormat4<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat4<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat4<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
480 | | template <typename set_t, typename filter_t> |
481 | | void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const |
482 | 0 | { |
483 | 0 | unsigned count = segments.get_length (); |
484 | 0 | for (unsigned i = 0; i < count; i++) |
485 | 0 | segments[i].collect_glyphs_filtered (glyphs, this, filter); |
486 | 0 | } |
487 | | |
488 | | bool sanitize (hb_sanitize_context_t *c) const |
489 | 0 | { |
490 | 0 | TRACE_SANITIZE (this); |
491 | 0 | return_trace (segments.sanitize (c, this)); |
492 | 0 | } Unexecuted instantiation: AAT::LookupFormat4<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat4<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat4<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
493 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
494 | 0 | { |
495 | 0 | TRACE_SANITIZE (this); |
496 | 0 | return_trace (segments.sanitize (c, this, base)); |
497 | 0 | } Unexecuted instantiation: AAT::LookupFormat4<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat4<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat4<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
498 | | |
499 | | protected: |
500 | | HBUINT16 format; /* Format identifier--format = 4 */ |
501 | | VarSizedBinSearchArrayOf<LookupSegmentArray<T>> |
502 | | segments; /* The actual segments. These must already be sorted, |
503 | | * according to the first word in each one (the last |
504 | | * glyph in each segment). */ |
505 | | public: |
506 | | DEFINE_SIZE_ARRAY (8, segments); |
507 | | }; |
508 | | |
509 | | template <typename T> |
510 | | struct LookupSingle |
511 | | { |
512 | | static constexpr unsigned TerminationWordCount = 1u; |
513 | | |
514 | 0 | int cmp (hb_codepoint_t g) const { return glyph.cmp (g); }Unexecuted instantiation: AAT::LookupSingle<OT::NumType<true, unsigned short, 2u> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSingle<OT::HBGlyphID16>::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSingle<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSingle<OT::NumType<true, unsigned int, 4u> >::cmp(unsigned int) const Unexecuted instantiation: AAT::LookupSingle<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::cmp(unsigned int) const |
515 | | |
516 | | template <typename set_t> |
517 | | void collect_glyphs (set_t &glyphs) const |
518 | 0 | { |
519 | 0 | if (glyph == DELETED_GLYPH) return; |
520 | 0 | glyphs.add (glyph); |
521 | 0 | } Unexecuted instantiation: void AAT::LookupSingle<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupSingle<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupSingle<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
522 | | template <typename set_t, typename filter_t> |
523 | | void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const |
524 | 0 | { |
525 | 0 | if (glyph == DELETED_GLYPH) return; |
526 | 0 | if (!filter (value)) return; |
527 | 0 | glyphs.add (glyph); |
528 | 0 | } |
529 | | |
530 | | bool sanitize (hb_sanitize_context_t *c) const |
531 | 0 | { |
532 | 0 | TRACE_SANITIZE (this); |
533 | 0 | return_trace (c->check_struct (this) && value.sanitize (c)); |
534 | 0 | } Unexecuted instantiation: AAT::LookupSingle<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupSingle<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupSingle<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
535 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
536 | 0 | { |
537 | 0 | TRACE_SANITIZE (this); |
538 | 0 | return_trace (c->check_struct (this) && value.sanitize (c, base)); |
539 | 0 | } Unexecuted instantiation: AAT::LookupSingle<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupSingle<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupSingle<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
540 | | |
541 | | HBGlyphID16 glyph; /* Last GlyphID */ |
542 | | T value; /* The lookup value (only one) */ |
543 | | public: |
544 | | DEFINE_SIZE_STATIC (2 + T::static_size); |
545 | | }; |
546 | | |
547 | | template <typename T> |
548 | | struct LookupFormat6 |
549 | | { |
550 | | friend struct Lookup<T>; |
551 | | |
552 | | private: |
553 | | const T* get_value (hb_codepoint_t glyph_id) const |
554 | 0 | { |
555 | 0 | const LookupSingle<T> *v = entries.bsearch (glyph_id); |
556 | 0 | return v ? &v->value : nullptr; |
557 | 0 | } Unexecuted instantiation: AAT::LookupFormat6<OT::NumType<true, unsigned short, 2u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat6<OT::HBGlyphID16>::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat6<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat6<OT::NumType<true, unsigned int, 4u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat6<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::get_value(unsigned int) const |
558 | | |
559 | | template <typename set_t> |
560 | | void collect_glyphs (set_t &glyphs) const |
561 | 0 | { |
562 | 0 | unsigned count = entries.get_length (); |
563 | 0 | for (unsigned i = 0; i < count; i++) |
564 | 0 | entries[i].collect_glyphs (glyphs); |
565 | 0 | } Unexecuted instantiation: void AAT::LookupFormat6<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat6<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat6<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
566 | | template <typename set_t, typename filter_t> |
567 | | void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const |
568 | 0 | { |
569 | 0 | unsigned count = entries.get_length (); |
570 | 0 | for (unsigned i = 0; i < count; i++) |
571 | 0 | entries[i].collect_glyphs_filtered (glyphs, filter); |
572 | 0 | } |
573 | | |
574 | | bool sanitize (hb_sanitize_context_t *c) const |
575 | 0 | { |
576 | 0 | TRACE_SANITIZE (this); |
577 | 0 | return_trace (entries.sanitize (c)); |
578 | 0 | } Unexecuted instantiation: AAT::LookupFormat6<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat6<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat6<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
579 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
580 | 0 | { |
581 | 0 | TRACE_SANITIZE (this); |
582 | 0 | return_trace (entries.sanitize (c, base)); |
583 | 0 | } Unexecuted instantiation: AAT::LookupFormat6<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat6<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat6<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
584 | | |
585 | | protected: |
586 | | HBUINT16 format; /* Format identifier--format = 6 */ |
587 | | VarSizedBinSearchArrayOf<LookupSingle<T>> |
588 | | entries; /* The actual entries, sorted by glyph index. */ |
589 | | public: |
590 | | DEFINE_SIZE_ARRAY (8, entries); |
591 | | }; |
592 | | |
593 | | template <typename T> |
594 | | struct LookupFormat8 |
595 | | { |
596 | | friend struct Lookup<T>; |
597 | | |
598 | | private: |
599 | | const T* get_value (hb_codepoint_t glyph_id) const |
600 | 0 | { |
601 | 0 | return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? |
602 | 0 | &valueArrayZ[glyph_id - firstGlyph] : nullptr; |
603 | 0 | } Unexecuted instantiation: AAT::LookupFormat8<OT::NumType<true, unsigned short, 2u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat8<OT::HBGlyphID16>::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat8<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat8<OT::NumType<true, unsigned int, 4u> >::get_value(unsigned int) const Unexecuted instantiation: AAT::LookupFormat8<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::get_value(unsigned int) const |
604 | | |
605 | | template <typename set_t> |
606 | | void collect_glyphs (set_t &glyphs) const |
607 | 0 | { |
608 | 0 | if (unlikely (!glyphCount)) return; |
609 | 0 | if (firstGlyph == DELETED_GLYPH) return; |
610 | 0 | glyphs.add_range (firstGlyph, firstGlyph + glyphCount - 1); |
611 | 0 | } Unexecuted instantiation: void AAT::LookupFormat8<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat8<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat8<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
612 | | template <typename set_t, typename filter_t> |
613 | | void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const |
614 | 0 | { |
615 | 0 | if (unlikely (!glyphCount)) return; |
616 | 0 | if (firstGlyph == DELETED_GLYPH) return; |
617 | 0 | const T *p = valueArrayZ.arrayZ; |
618 | 0 | for (unsigned i = 0; i < glyphCount; i++) |
619 | 0 | if (filter (p[i])) |
620 | 0 | glyphs.add (firstGlyph + i); |
621 | 0 | } |
622 | | |
623 | | bool sanitize (hb_sanitize_context_t *c) const |
624 | 0 | { |
625 | 0 | TRACE_SANITIZE (this); |
626 | 0 | return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount)); |
627 | 0 | } Unexecuted instantiation: AAT::LookupFormat8<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat8<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat8<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
628 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
629 | 0 | { |
630 | 0 | TRACE_SANITIZE (this); |
631 | 0 | return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount, base)); |
632 | 0 | } Unexecuted instantiation: AAT::LookupFormat8<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat8<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::LookupFormat8<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
633 | | |
634 | | protected: |
635 | | HBUINT16 format; /* Format identifier--format = 8 */ |
636 | | HBGlyphID16 firstGlyph; /* First glyph index included in the trimmed array. */ |
637 | | HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last |
638 | | * glyph minus the value of firstGlyph plus 1). */ |
639 | | UnsizedArrayOf<T> |
640 | | valueArrayZ; /* The lookup values (indexed by the glyph index |
641 | | * minus the value of firstGlyph). */ |
642 | | public: |
643 | | DEFINE_SIZE_ARRAY (6, valueArrayZ); |
644 | | }; |
645 | | |
646 | | template <typename T> |
647 | | struct LookupFormat10 |
648 | | { |
649 | | friend struct Lookup<T>; |
650 | | |
651 | | private: |
652 | | const typename T::type get_value_or_null (hb_codepoint_t glyph_id) const |
653 | 0 | { |
654 | 0 | if (!(firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount)) |
655 | 0 | return Null (T); |
656 | | |
657 | 0 | const HBUINT8 *p = &valueArrayZ[(glyph_id - firstGlyph) * valueSize]; |
658 | |
|
659 | 0 | unsigned int v = 0; |
660 | 0 | unsigned int count = valueSize; |
661 | 0 | for (unsigned int i = 0; i < count; i++) |
662 | 0 | v = (v << 8) | *p++; |
663 | |
|
664 | 0 | return v; |
665 | 0 | } Unexecuted instantiation: AAT::LookupFormat10<OT::NumType<true, unsigned int, 4u> >::get_value_or_null(unsigned int) const Unexecuted instantiation: AAT::LookupFormat10<OT::NumType<true, unsigned short, 2u> >::get_value_or_null(unsigned int) const |
666 | | |
667 | | template <typename set_t> |
668 | | void collect_glyphs (set_t &glyphs) const |
669 | 0 | { |
670 | 0 | if (unlikely (!glyphCount)) return; |
671 | 0 | if (firstGlyph == DELETED_GLYPH) return; |
672 | 0 | glyphs.add_range (firstGlyph, firstGlyph + glyphCount - 1); |
673 | 0 | } Unexecuted instantiation: void AAT::LookupFormat10<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat10<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const Unexecuted instantiation: void AAT::LookupFormat10<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&) const |
674 | | |
675 | | template <typename set_t, typename filter_t> |
676 | | void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const |
677 | 0 | { |
678 | 0 | if (unlikely (!glyphCount)) return; |
679 | 0 | if (firstGlyph == DELETED_GLYPH) return; |
680 | 0 | const HBUINT8 *p = valueArrayZ.arrayZ; |
681 | 0 | for (unsigned i = 0; i < glyphCount; i++) |
682 | 0 | { |
683 | 0 | unsigned int v = 0; |
684 | 0 | unsigned int count = valueSize; |
685 | 0 | for (unsigned int j = 0; j < count; j++) |
686 | 0 | v = (v << 8) | *p++; |
687 | 0 | if (filter (v)) |
688 | 0 | glyphs.add (firstGlyph + i); |
689 | 0 | } |
690 | 0 | } |
691 | | |
692 | | bool sanitize (hb_sanitize_context_t *c) const |
693 | 0 | { |
694 | 0 | TRACE_SANITIZE (this); |
695 | 0 | return_trace (c->check_struct (this) && |
696 | 0 | hb_barrier () && |
697 | 0 | valueSize <= 4 && |
698 | 0 | valueArrayZ.sanitize (c, glyphCount * valueSize)); |
699 | 0 | } Unexecuted instantiation: AAT::LookupFormat10<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat10<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::LookupFormat10<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
700 | | |
701 | | protected: |
702 | | HBUINT16 format; /* Format identifier--format = 8 */ |
703 | | HBUINT16 valueSize; /* Byte size of each value. */ |
704 | | HBGlyphID16 firstGlyph; /* First glyph index included in the trimmed array. */ |
705 | | HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last |
706 | | * glyph minus the value of firstGlyph plus 1). */ |
707 | | UnsizedArrayOf<HBUINT8> |
708 | | valueArrayZ; /* The lookup values (indexed by the glyph index |
709 | | * minus the value of firstGlyph). */ |
710 | | public: |
711 | | DEFINE_SIZE_ARRAY (8, valueArrayZ); |
712 | | }; |
713 | | |
714 | | template <typename T> |
715 | | struct Lookup |
716 | | { |
717 | | const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const |
718 | 0 | { |
719 | 0 | switch (u.format.v) { |
720 | 0 | case 0: hb_barrier (); return u.format0.get_value (glyph_id, num_glyphs); |
721 | 0 | case 2: hb_barrier (); return u.format2.get_value (glyph_id); |
722 | 0 | case 4: hb_barrier (); return u.format4.get_value (glyph_id); |
723 | 0 | case 6: hb_barrier (); return u.format6.get_value (glyph_id); |
724 | 0 | case 8: hb_barrier (); return u.format8.get_value (glyph_id); |
725 | 0 | default:return nullptr; |
726 | 0 | } |
727 | 0 | } Unexecuted instantiation: AAT::Lookup<OT::NumType<true, unsigned short, 2u> >::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::Lookup<OT::HBGlyphID16>::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::Lookup<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::Lookup<OT::NumType<true, unsigned int, 4u> >::get_value(unsigned int, unsigned int) const Unexecuted instantiation: AAT::Lookup<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::get_value(unsigned int, unsigned int) const |
728 | | |
729 | | const typename T::type get_value_or_null (hb_codepoint_t glyph_id, unsigned int num_glyphs) const |
730 | 0 | { |
731 | 0 | switch (u.format.v) { |
732 | | /* Format 10 cannot return a pointer. */ |
733 | 0 | case 10: hb_barrier (); return u.format10.get_value_or_null (glyph_id); |
734 | 0 | default: |
735 | 0 | const T *v = get_value (glyph_id, num_glyphs); |
736 | 0 | return v ? *v : Null (T); |
737 | 0 | } |
738 | 0 | } Unexecuted instantiation: AAT::Lookup<OT::NumType<true, unsigned int, 4u> >::get_value_or_null(unsigned int, unsigned int) const Unexecuted instantiation: AAT::Lookup<OT::NumType<true, unsigned short, 2u> >::get_value_or_null(unsigned int, unsigned int) const |
739 | | |
740 | | template <typename set_t> |
741 | | void collect_glyphs (set_t &glyphs, unsigned int num_glyphs) const |
742 | 0 | { |
743 | 0 | switch (u.format.v) { |
744 | 0 | case 0: hb_barrier (); u.format0.collect_glyphs (glyphs, num_glyphs); return; |
745 | 0 | case 2: hb_barrier (); u.format2.collect_glyphs (glyphs); return; |
746 | 0 | case 4: hb_barrier (); u.format4.collect_glyphs (glyphs); return; |
747 | 0 | case 6: hb_barrier (); u.format6.collect_glyphs (glyphs); return; |
748 | 0 | case 8: hb_barrier (); u.format8.collect_glyphs (glyphs); return; |
749 | 0 | case 10: hb_barrier (); u.format10.collect_glyphs (glyphs); return; |
750 | 0 | default:return; |
751 | 0 | } |
752 | 0 | } Unexecuted instantiation: void AAT::Lookup<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const Unexecuted instantiation: void AAT::Lookup<OT::HBGlyphID16>::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const Unexecuted instantiation: void AAT::Lookup<OT::NumType<true, unsigned int, 4u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const |
753 | | template <typename set_t, typename filter_t> |
754 | | void collect_glyphs_filtered (set_t &glyphs, unsigned num_glyphs, const filter_t &filter) const |
755 | 0 | { |
756 | 0 | switch (u.format.v) { |
757 | 0 | case 0: hb_barrier (); u.format0.collect_glyphs_filtered (glyphs, num_glyphs, filter); return; |
758 | 0 | case 2: hb_barrier (); u.format2.collect_glyphs_filtered (glyphs, filter); return; |
759 | 0 | case 4: hb_barrier (); u.format4.collect_glyphs_filtered (glyphs, filter); return; |
760 | 0 | case 6: hb_barrier (); u.format6.collect_glyphs_filtered (glyphs, filter); return; |
761 | 0 | case 8: hb_barrier (); u.format8.collect_glyphs_filtered (glyphs, filter); return; |
762 | 0 | case 10: hb_barrier (); u.format10.collect_glyphs_filtered (glyphs, filter); return; |
763 | 0 | default:return; |
764 | 0 | } |
765 | 0 | } |
766 | | |
767 | | typename T::type get_class (hb_codepoint_t glyph_id, |
768 | | unsigned int num_glyphs, |
769 | | unsigned int outOfRange) const |
770 | 0 | { |
771 | 0 | const T *v = get_value (glyph_id, num_glyphs); |
772 | 0 | return v ? *v : outOfRange; |
773 | 0 | } |
774 | | |
775 | | bool sanitize (hb_sanitize_context_t *c) const |
776 | 0 | { |
777 | 0 | TRACE_SANITIZE (this); |
778 | 0 | if (!u.format.v.sanitize (c)) return_trace (false); |
779 | 0 | hb_barrier (); |
780 | 0 | switch (u.format.v) { |
781 | 0 | case 0: hb_barrier (); return_trace (u.format0.sanitize (c)); |
782 | 0 | case 2: hb_barrier (); return_trace (u.format2.sanitize (c)); |
783 | 0 | case 4: hb_barrier (); return_trace (u.format4.sanitize (c)); |
784 | 0 | case 6: hb_barrier (); return_trace (u.format6.sanitize (c)); |
785 | 0 | case 8: hb_barrier (); return_trace (u.format8.sanitize (c)); |
786 | 0 | case 10: hb_barrier (); return_trace (u.format10.sanitize (c)); |
787 | 0 | default:return_trace (true); |
788 | 0 | } |
789 | 0 | } Unexecuted instantiation: AAT::Lookup<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::Lookup<OT::HBGlyphID16>::sanitize(hb_sanitize_context_t*) const Unexecuted instantiation: AAT::Lookup<OT::NumType<true, unsigned int, 4u> >::sanitize(hb_sanitize_context_t*) const |
790 | | bool sanitize (hb_sanitize_context_t *c, const void *base) const |
791 | 0 | { |
792 | 0 | TRACE_SANITIZE (this); |
793 | 0 | if (!u.format.v.sanitize (c)) return_trace (false); |
794 | 0 | hb_barrier (); |
795 | 0 | switch (u.format.v) { |
796 | 0 | case 0: hb_barrier (); return_trace (u.format0.sanitize (c, base)); |
797 | 0 | case 2: hb_barrier (); return_trace (u.format2.sanitize (c, base)); |
798 | 0 | case 4: hb_barrier (); return_trace (u.format4.sanitize (c, base)); |
799 | 0 | case 6: hb_barrier (); return_trace (u.format6.sanitize (c, base)); |
800 | 0 | case 8: hb_barrier (); return_trace (u.format8.sanitize (c, base)); |
801 | 0 | case 10: return_trace (false); /* We don't support format10 here currently. */ |
802 | 0 | default:return_trace (true); |
803 | 0 | } |
804 | 0 | } Unexecuted instantiation: AAT::Lookup<OT::OffsetTo<OT::ArrayOf<AAT::Anchor, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, false> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::Lookup<OT::OffsetTo<OT::ArrayOf<AAT::WidthDeltaPair, OT::NumType<true, unsigned int, 4u> >, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const Unexecuted instantiation: AAT::Lookup<OT::OffsetTo<AAT::OpticalBounds, OT::NumType<true, unsigned short, 2u>, void, true> >::sanitize(hb_sanitize_context_t*, void const*) const |
805 | | |
806 | | protected: |
807 | | union { |
808 | | struct { HBUINT16 v; } format; /* Format identifier */ |
809 | | LookupFormat0<T> format0; |
810 | | LookupFormat2<T> format2; |
811 | | LookupFormat4<T> format4; |
812 | | LookupFormat6<T> format6; |
813 | | LookupFormat8<T> format8; |
814 | | LookupFormat10<T> format10; |
815 | | } u; |
816 | | public: |
817 | | DEFINE_SIZE_UNION (2, format.v); |
818 | | }; |
819 | | DECLARE_NULL_NAMESPACE_BYTES_TEMPLATE1 (AAT, Lookup, 13); |
820 | | |
821 | | /* |
822 | | * (Extended) State Table |
823 | | */ |
824 | | |
825 | | template <typename T> |
826 | | struct Entry |
827 | | { |
828 | | // This doesn't seem like it's ever called. |
829 | | bool sanitize (hb_sanitize_context_t *c) const |
830 | | { |
831 | | TRACE_SANITIZE (this); |
832 | | /* Note, we don't recurse-sanitize data because we don't access it. |
833 | | * That said, in our DEFINE_SIZE_STATIC we access T::static_size, |
834 | | * which ensures that data has a simple sanitize(). To be determined |
835 | | * if I need to remove that as well. |
836 | | * |
837 | | * HOWEVER! Because we are a template, our DEFINE_SIZE_STATIC |
838 | | * assertion wouldn't be checked, hence the line below. */ |
839 | | static_assert (T::static_size, ""); |
840 | | |
841 | | return_trace (c->check_struct (this)); |
842 | | } |
843 | | |
844 | | public: |
845 | | HBUINT16 newState; /* Byte offset from beginning of state table |
846 | | * to the new state. Really?!?! Or just state |
847 | | * number? The latter in morx for sure. */ |
848 | | HBUINT16 flags; /* Table specific. */ |
849 | | T data; /* Optional offsets to per-glyph tables. */ |
850 | | public: |
851 | | DEFINE_SIZE_STATIC (4 + T::static_size); |
852 | | }; |
853 | | |
854 | | template <> |
855 | | struct Entry<void> |
856 | | { |
857 | | // This does seem like it's ever called. |
858 | | bool sanitize (hb_sanitize_context_t *c) const |
859 | 0 | { |
860 | 0 | TRACE_SANITIZE (this); |
861 | 0 | return_trace (c->check_struct (this)); |
862 | 0 | } |
863 | | |
864 | | public: |
865 | | HBUINT16 newState; /* Byte offset from beginning of state table to the new state. */ |
866 | | HBUINT16 flags; /* Table specific. */ |
867 | | public: |
868 | | DEFINE_SIZE_STATIC (4); |
869 | | }; |
870 | | |
871 | | enum Class |
872 | | { |
873 | | CLASS_END_OF_TEXT = 0, |
874 | | CLASS_OUT_OF_BOUNDS = 1, |
875 | | CLASS_DELETED_GLYPH = 2, |
876 | | CLASS_END_OF_LINE = 3, |
877 | | }; |
878 | | |
879 | | template <typename Types, typename Extra> |
880 | | struct StateTable |
881 | | { |
882 | | typedef typename Types::HBUINT HBUINT; |
883 | | typedef typename Types::HBUSHORT HBUSHORT; |
884 | | typedef typename Types::ClassTypeNarrow ClassType; |
885 | | |
886 | | enum State |
887 | | { |
888 | | STATE_START_OF_TEXT = 0, |
889 | | STATE_START_OF_LINE = 1, |
890 | | }; |
891 | | |
892 | | template <typename set_t, typename table_t> |
893 | | void collect_initial_glyphs (set_t &glyphs, unsigned num_glyphs, const table_t &table) const |
894 | 23 | { |
895 | 23 | unsigned num_classes = nClasses; |
896 | | |
897 | 23 | if (unlikely (num_classes > hb_bit_page_t::BITS)) |
898 | 0 | { |
899 | 0 | (this+classTable).collect_glyphs (glyphs, num_glyphs); |
900 | 0 | return; |
901 | 0 | } |
902 | | |
903 | | // Collect all classes going out from the start state. |
904 | 23 | hb_bit_page_t filter; |
905 | | |
906 | 3.02k | for (unsigned i = 0; i < num_classes; i++) |
907 | 2.99k | { |
908 | 2.99k | const auto &entry = get_entry (STATE_START_OF_TEXT, i); |
909 | 2.99k | if (new_state (entry.newState) == STATE_START_OF_TEXT && |
910 | 1.89k | !table.is_action_initiable (entry) && !table.is_actionable (entry)) |
911 | 27 | continue; |
912 | | |
913 | 2.97k | filter.add (i); |
914 | 2.97k | } |
915 | | |
916 | | // And glyphs in those classes. |
917 | | |
918 | 23 | if (filter (CLASS_DELETED_GLYPH)) |
919 | 23 | glyphs.add (DELETED_GLYPH); |
920 | | |
921 | 23 | (this+classTable).collect_glyphs_filtered (glyphs, num_glyphs, filter); |
922 | 23 | } Unexecuted instantiation: void AAT::StateTable<AAT::ExtendedTypes, void>::collect_initial_glyphs<hb_bit_set_t, AAT::RearrangementSubtable<AAT::ExtendedTypes> >(hb_bit_set_t&, unsigned int, AAT::RearrangementSubtable<AAT::ExtendedTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData>::collect_initial_glyphs<hb_bit_set_t, AAT::ContextualSubtable<AAT::ExtendedTypes> >(hb_bit_set_t&, unsigned int, AAT::ContextualSubtable<AAT::ExtendedTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData>::collect_initial_glyphs<hb_bit_set_t, AAT::LigatureSubtable<AAT::ExtendedTypes> >(hb_bit_set_t&, unsigned int, AAT::LigatureSubtable<AAT::ExtendedTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData>::collect_initial_glyphs<hb_bit_set_t, AAT::InsertionSubtable<AAT::ExtendedTypes> >(hb_bit_set_t&, unsigned int, AAT::InsertionSubtable<AAT::ExtendedTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ObsoleteTypes, void>::collect_initial_glyphs<hb_bit_set_t, AAT::RearrangementSubtable<AAT::ObsoleteTypes> >(hb_bit_set_t&, unsigned int, AAT::RearrangementSubtable<AAT::ObsoleteTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData>::collect_initial_glyphs<hb_bit_set_t, AAT::ContextualSubtable<AAT::ObsoleteTypes> >(hb_bit_set_t&, unsigned int, AAT::ContextualSubtable<AAT::ObsoleteTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ObsoleteTypes, void>::collect_initial_glyphs<hb_bit_set_t, AAT::LigatureSubtable<AAT::ObsoleteTypes> >(hb_bit_set_t&, unsigned int, AAT::LigatureSubtable<AAT::ObsoleteTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData>::collect_initial_glyphs<hb_bit_set_t, AAT::InsertionSubtable<AAT::ObsoleteTypes> >(hb_bit_set_t&, unsigned int, AAT::InsertionSubtable<AAT::ObsoleteTypes> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData>::collect_initial_glyphs<hb_bit_set_t, AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader> >(hb_bit_set_t&, unsigned int, AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader> const&) const Unexecuted instantiation: void AAT::StateTable<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData>::collect_initial_glyphs<hb_bit_set_t, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader> >(hb_bit_set_t&, unsigned int, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader> const&) const void AAT::StateTable<AAT::ObsoleteTypes, void>::collect_initial_glyphs<hb_bit_set_t, AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader> >(hb_bit_set_t&, unsigned int, AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader> const&) const Line | Count | Source | 894 | 23 | { | 895 | 23 | unsigned num_classes = nClasses; | 896 | | | 897 | 23 | if (unlikely (num_classes > hb_bit_page_t::BITS)) | 898 | 0 | { | 899 | 0 | (this+classTable).collect_glyphs (glyphs, num_glyphs); | 900 | 0 | return; | 901 | 0 | } | 902 | | | 903 | | // Collect all classes going out from the start state. | 904 | 23 | hb_bit_page_t filter; | 905 | | | 906 | 3.02k | for (unsigned i = 0; i < num_classes; i++) | 907 | 2.99k | { | 908 | 2.99k | const auto &entry = get_entry (STATE_START_OF_TEXT, i); | 909 | 2.99k | if (new_state (entry.newState) == STATE_START_OF_TEXT && | 910 | 1.89k | !table.is_action_initiable (entry) && !table.is_actionable (entry)) | 911 | 27 | continue; | 912 | | | 913 | 2.97k | filter.add (i); | 914 | 2.97k | } | 915 | | | 916 | | // And glyphs in those classes. | 917 | | | 918 | 23 | if (filter (CLASS_DELETED_GLYPH)) | 919 | 23 | glyphs.add (DELETED_GLYPH); | 920 | | | 921 | 23 | (this+classTable).collect_glyphs_filtered (glyphs, num_glyphs, filter); | 922 | 23 | } |
Unexecuted instantiation: void AAT::StateTable<AAT::ObsoleteTypes, void>::collect_initial_glyphs<hb_bit_set_t, AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader> >(hb_bit_set_t&, unsigned int, AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader> const&) const |
923 | | |
924 | | int new_state (unsigned int newState) const |
925 | 10.5k | { return Types::extended ? newState : ((int) newState - (int) stateArrayTable) / (int) nClasses; }Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, void>::new_state(unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData>::new_state(unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData>::new_state(unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData>::new_state(unsigned int) const AAT::StateTable<AAT::ObsoleteTypes, void>::new_state(unsigned int) const Line | Count | Source | 925 | 10.5k | { return Types::extended ? newState : ((int) newState - (int) stateArrayTable) / (int) nClasses; } |
Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData>::new_state(unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData>::new_state(unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData>::new_state(unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData>::new_state(unsigned int) const |
926 | | |
927 | | unsigned int get_class (hb_codepoint_t glyph_id, |
928 | | unsigned int num_glyphs, |
929 | | hb_aat_class_cache_t *cache = nullptr) const |
930 | 0 | { |
931 | 0 | unsigned klass; |
932 | 0 | if (cache && cache->get (glyph_id, &klass)) return klass; |
933 | 0 | if (unlikely (glyph_id == DELETED_GLYPH)) return CLASS_DELETED_GLYPH; |
934 | 0 | klass = (this+classTable).get_class (glyph_id, num_glyphs, CLASS_OUT_OF_BOUNDS); |
935 | 0 | if (cache) cache->set (glyph_id, klass); |
936 | 0 | return klass; |
937 | 0 | } Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, void>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, void>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData>::get_class(unsigned int, unsigned int, hb_cache_t<16u, 8u, 8u, true>*) const |
938 | | |
939 | | const Entry<Extra> *get_entries () const |
940 | 0 | { return (this+entryTable).arrayZ; }Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData>::get_entries() const Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData>::get_entries() const |
941 | | |
942 | | const Entry<Extra> &get_entry (int state, unsigned int klass) const |
943 | 2.99k | { |
944 | 2.99k | unsigned n_classes = nClasses; |
945 | 2.99k | if (unlikely (klass >= n_classes)) |
946 | 0 | klass = CLASS_OUT_OF_BOUNDS; |
947 | | |
948 | 2.99k | const HBUSHORT *states = (this+stateArrayTable).arrayZ; |
949 | 2.99k | const Entry<Extra> *entries = (this+entryTable).arrayZ; |
950 | | |
951 | 2.99k | unsigned int entry = states[state * n_classes + klass]; |
952 | 2.99k | DEBUG_MSG (APPLY, nullptr, "e%u", entry); |
953 | | |
954 | 2.99k | return entries[entry]; |
955 | 2.99k | } Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, void>::get_entry(int, unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData>::get_entry(int, unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData>::get_entry(int, unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData>::get_entry(int, unsigned int) const AAT::StateTable<AAT::ObsoleteTypes, void>::get_entry(int, unsigned int) const Line | Count | Source | 943 | 2.99k | { | 944 | 2.99k | unsigned n_classes = nClasses; | 945 | 2.99k | if (unlikely (klass >= n_classes)) | 946 | 0 | klass = CLASS_OUT_OF_BOUNDS; | 947 | | | 948 | 2.99k | const HBUSHORT *states = (this+stateArrayTable).arrayZ; | 949 | 2.99k | const Entry<Extra> *entries = (this+entryTable).arrayZ; | 950 | | | 951 | 2.99k | unsigned int entry = states[state * n_classes + klass]; | 952 | 2.99k | DEBUG_MSG (APPLY, nullptr, "e%u", entry); | 953 | | | 954 | 2.99k | return entries[entry]; | 955 | 2.99k | } |
Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData>::get_entry(int, unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData>::get_entry(int, unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData>::get_entry(int, unsigned int) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData>::get_entry(int, unsigned int) const |
956 | | |
957 | | bool sanitize (hb_sanitize_context_t *c, |
958 | | unsigned int *num_entries_out = nullptr) const |
959 | 62 | { |
960 | 62 | TRACE_SANITIZE (this); |
961 | 62 | if (unlikely (!(c->check_struct (this) && |
962 | 62 | hb_barrier () && |
963 | 62 | nClasses >= 4 /* Ensure pre-defined classes fit. */ && |
964 | 62 | classTable.sanitize (c, this)))) return_trace (false); |
965 | | |
966 | 54 | const HBUSHORT *states = (this+stateArrayTable).arrayZ; |
967 | 54 | const Entry<Extra> *entries = (this+entryTable).arrayZ; |
968 | | |
969 | 54 | unsigned int num_classes = nClasses; |
970 | 54 | if (unlikely (hb_unsigned_mul_overflows (num_classes, states[0].static_size))) |
971 | 0 | return_trace (false); |
972 | 54 | unsigned int row_stride = num_classes * states[0].static_size; |
973 | | |
974 | | /* Apple 'kern' table has this peculiarity: |
975 | | * |
976 | | * "Because the stateTableOffset in the state table header is (strictly |
977 | | * speaking) redundant, some 'kern' tables use it to record an initial |
978 | | * state where that should not be StartOfText. To determine if this is |
979 | | * done, calculate what the stateTableOffset should be. If it's different |
980 | | * from the actual stateTableOffset, use it as the initial state." |
981 | | * |
982 | | * We implement this by calling the initial state zero, but allow *negative* |
983 | | * states if the start state indeed was not the first state. Since the code |
984 | | * is shared, this will also apply to 'mort' table. The 'kerx' / 'morx' |
985 | | * tables are not affected since those address states by index, not offset. |
986 | | */ |
987 | | |
988 | 54 | int min_state = 0; |
989 | 54 | int max_state = 0; |
990 | 54 | unsigned int num_entries = 0; |
991 | | |
992 | 54 | int state_pos = 0; |
993 | 54 | int state_neg = 0; |
994 | 54 | unsigned int entry = 0; |
995 | 133 | while (min_state < state_neg || state_pos <= max_state) |
996 | 110 | { |
997 | 110 | if (min_state < state_neg) |
998 | 17 | { |
999 | | /* Negative states. */ |
1000 | 17 | if (unlikely (hb_unsigned_mul_overflows (min_state, num_classes))) |
1001 | 17 | return_trace (false); |
1002 | 0 | if (unlikely (!c->check_range (&states[min_state * num_classes], |
1003 | 0 | -min_state, |
1004 | 0 | row_stride))) |
1005 | 0 | return_trace (false); |
1006 | 0 | if ((c->max_ops -= state_neg - min_state) <= 0) |
1007 | 0 | return_trace (false); |
1008 | 0 | { /* Sweep new states. */ |
1009 | 0 | const HBUSHORT *stop = &states[min_state * num_classes]; |
1010 | 0 | if (unlikely (stop > states)) |
1011 | 0 | return_trace (false); |
1012 | 0 | for (const HBUSHORT *p = states; stop < p; p--) |
1013 | 0 | num_entries = hb_max (num_entries, *(p - 1) + 1u); |
1014 | 0 | state_neg = min_state; |
1015 | 0 | } |
1016 | 0 | } |
1017 | | |
1018 | 93 | if (state_pos <= max_state) |
1019 | 93 | { |
1020 | | /* Positive states. */ |
1021 | 93 | if (unlikely (!c->check_range (states, |
1022 | 93 | max_state + 1, |
1023 | 93 | row_stride))) |
1024 | 6 | return_trace (false); |
1025 | 87 | if ((c->max_ops -= max_state - state_pos + 1) <= 0) |
1026 | 0 | return_trace (false); |
1027 | 87 | { /* Sweep new states. */ |
1028 | 87 | if (unlikely (hb_unsigned_mul_overflows ((max_state + 1), num_classes))) |
1029 | 0 | return_trace (false); |
1030 | 87 | const HBUSHORT *stop = &states[(max_state + 1) * num_classes]; |
1031 | 87 | if (unlikely (stop < states)) |
1032 | 0 | return_trace (false); |
1033 | 149k | for (const HBUSHORT *p = &states[state_pos * num_classes]; p < stop; p++) |
1034 | 149k | num_entries = hb_max (num_entries, *p + 1u); |
1035 | 87 | state_pos = max_state + 1; |
1036 | 87 | } |
1037 | 87 | } |
1038 | | |
1039 | 87 | if (unlikely (!c->check_array (entries, num_entries))) |
1040 | 8 | return_trace (false); |
1041 | 79 | if ((c->max_ops -= num_entries - entry) <= 0) |
1042 | 0 | return_trace (false); |
1043 | 79 | { /* Sweep new entries. */ |
1044 | 79 | const Entry<Extra> *stop = &entries[num_entries]; |
1045 | 7.58k | for (const Entry<Extra> *p = &entries[entry]; p < stop; p++) |
1046 | 7.50k | { |
1047 | 7.50k | int newState = new_state (p->newState); |
1048 | 7.50k | min_state = hb_min (min_state, newState); |
1049 | 7.50k | max_state = hb_max (max_state, newState); |
1050 | 7.50k | } |
1051 | 79 | entry = num_entries; |
1052 | 79 | } |
1053 | 79 | } |
1054 | | |
1055 | 23 | if (num_entries_out) |
1056 | 0 | *num_entries_out = num_entries; |
1057 | | |
1058 | 23 | return_trace (true); |
1059 | 54 | } Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, void>::sanitize(hb_sanitize_context_t*, unsigned int*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData>::sanitize(hb_sanitize_context_t*, unsigned int*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData>::sanitize(hb_sanitize_context_t*, unsigned int*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData>::sanitize(hb_sanitize_context_t*, unsigned int*) const AAT::StateTable<AAT::ObsoleteTypes, void>::sanitize(hb_sanitize_context_t*, unsigned int*) const Line | Count | Source | 959 | 62 | { | 960 | 62 | TRACE_SANITIZE (this); | 961 | 62 | if (unlikely (!(c->check_struct (this) && | 962 | 62 | hb_barrier () && | 963 | 62 | nClasses >= 4 /* Ensure pre-defined classes fit. */ && | 964 | 62 | classTable.sanitize (c, this)))) return_trace (false); | 965 | | | 966 | 54 | const HBUSHORT *states = (this+stateArrayTable).arrayZ; | 967 | 54 | const Entry<Extra> *entries = (this+entryTable).arrayZ; | 968 | | | 969 | 54 | unsigned int num_classes = nClasses; | 970 | 54 | if (unlikely (hb_unsigned_mul_overflows (num_classes, states[0].static_size))) | 971 | 0 | return_trace (false); | 972 | 54 | unsigned int row_stride = num_classes * states[0].static_size; | 973 | | | 974 | | /* Apple 'kern' table has this peculiarity: | 975 | | * | 976 | | * "Because the stateTableOffset in the state table header is (strictly | 977 | | * speaking) redundant, some 'kern' tables use it to record an initial | 978 | | * state where that should not be StartOfText. To determine if this is | 979 | | * done, calculate what the stateTableOffset should be. If it's different | 980 | | * from the actual stateTableOffset, use it as the initial state." | 981 | | * | 982 | | * We implement this by calling the initial state zero, but allow *negative* | 983 | | * states if the start state indeed was not the first state. Since the code | 984 | | * is shared, this will also apply to 'mort' table. The 'kerx' / 'morx' | 985 | | * tables are not affected since those address states by index, not offset. | 986 | | */ | 987 | | | 988 | 54 | int min_state = 0; | 989 | 54 | int max_state = 0; | 990 | 54 | unsigned int num_entries = 0; | 991 | | | 992 | 54 | int state_pos = 0; | 993 | 54 | int state_neg = 0; | 994 | 54 | unsigned int entry = 0; | 995 | 133 | while (min_state < state_neg || state_pos <= max_state) | 996 | 110 | { | 997 | 110 | if (min_state < state_neg) | 998 | 17 | { | 999 | | /* Negative states. */ | 1000 | 17 | if (unlikely (hb_unsigned_mul_overflows (min_state, num_classes))) | 1001 | 17 | return_trace (false); | 1002 | 0 | if (unlikely (!c->check_range (&states[min_state * num_classes], | 1003 | 0 | -min_state, | 1004 | 0 | row_stride))) | 1005 | 0 | return_trace (false); | 1006 | 0 | if ((c->max_ops -= state_neg - min_state) <= 0) | 1007 | 0 | return_trace (false); | 1008 | 0 | { /* Sweep new states. */ | 1009 | 0 | const HBUSHORT *stop = &states[min_state * num_classes]; | 1010 | 0 | if (unlikely (stop > states)) | 1011 | 0 | return_trace (false); | 1012 | 0 | for (const HBUSHORT *p = states; stop < p; p--) | 1013 | 0 | num_entries = hb_max (num_entries, *(p - 1) + 1u); | 1014 | 0 | state_neg = min_state; | 1015 | 0 | } | 1016 | 0 | } | 1017 | | | 1018 | 93 | if (state_pos <= max_state) | 1019 | 93 | { | 1020 | | /* Positive states. */ | 1021 | 93 | if (unlikely (!c->check_range (states, | 1022 | 93 | max_state + 1, | 1023 | 93 | row_stride))) | 1024 | 6 | return_trace (false); | 1025 | 87 | if ((c->max_ops -= max_state - state_pos + 1) <= 0) | 1026 | 0 | return_trace (false); | 1027 | 87 | { /* Sweep new states. */ | 1028 | 87 | if (unlikely (hb_unsigned_mul_overflows ((max_state + 1), num_classes))) | 1029 | 0 | return_trace (false); | 1030 | 87 | const HBUSHORT *stop = &states[(max_state + 1) * num_classes]; | 1031 | 87 | if (unlikely (stop < states)) | 1032 | 0 | return_trace (false); | 1033 | 149k | for (const HBUSHORT *p = &states[state_pos * num_classes]; p < stop; p++) | 1034 | 149k | num_entries = hb_max (num_entries, *p + 1u); | 1035 | 87 | state_pos = max_state + 1; | 1036 | 87 | } | 1037 | 87 | } | 1038 | | | 1039 | 87 | if (unlikely (!c->check_array (entries, num_entries))) | 1040 | 8 | return_trace (false); | 1041 | 79 | if ((c->max_ops -= num_entries - entry) <= 0) | 1042 | 0 | return_trace (false); | 1043 | 79 | { /* Sweep new entries. */ | 1044 | 79 | const Entry<Extra> *stop = &entries[num_entries]; | 1045 | 7.58k | for (const Entry<Extra> *p = &entries[entry]; p < stop; p++) | 1046 | 7.50k | { | 1047 | 7.50k | int newState = new_state (p->newState); | 1048 | 7.50k | min_state = hb_min (min_state, newState); | 1049 | 7.50k | max_state = hb_max (max_state, newState); | 1050 | 7.50k | } | 1051 | 79 | entry = num_entries; | 1052 | 79 | } | 1053 | 79 | } | 1054 | | | 1055 | 23 | if (num_entries_out) | 1056 | 0 | *num_entries_out = num_entries; | 1057 | | | 1058 | 23 | return_trace (true); | 1059 | 54 | } |
Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData>::sanitize(hb_sanitize_context_t*, unsigned int*) const Unexecuted instantiation: AAT::StateTable<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData>::sanitize(hb_sanitize_context_t*, unsigned int*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData>::sanitize(hb_sanitize_context_t*, unsigned int*) const Unexecuted instantiation: AAT::StateTable<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData>::sanitize(hb_sanitize_context_t*, unsigned int*) const |
1060 | | |
1061 | | protected: |
1062 | | HBUINT nClasses; /* Number of classes, which is the number of indices |
1063 | | * in a single line in the state array. */ |
1064 | | NNOffsetTo<ClassType, HBUINT> |
1065 | | classTable; /* Offset to the class table. */ |
1066 | | NNOffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT> |
1067 | | stateArrayTable;/* Offset to the state array. */ |
1068 | | NNOffsetTo<UnsizedArrayOf<Entry<Extra>>, HBUINT> |
1069 | | entryTable; /* Offset to the entry array. */ |
1070 | | |
1071 | | public: |
1072 | | DEFINE_SIZE_STATIC (4 * sizeof (HBUINT)); |
1073 | | }; |
1074 | | |
1075 | | template <typename HBUCHAR> |
1076 | | struct ClassTable |
1077 | | { |
1078 | | unsigned int get_class (hb_codepoint_t glyph_id, unsigned int outOfRange) const |
1079 | 0 | { |
1080 | 0 | unsigned int i = glyph_id - firstGlyph; |
1081 | 0 | return i >= classArray.len ? outOfRange : classArray.arrayZ[i]; |
1082 | 0 | } Unexecuted instantiation: AAT::ClassTable<OT::NumType<true, unsigned char, 1u> >::get_class(unsigned int, unsigned int) const Unexecuted instantiation: AAT::ClassTable<OT::NumType<true, unsigned short, 2u> >::get_class(unsigned int, unsigned int) const |
1083 | | unsigned int get_class (hb_codepoint_t glyph_id, |
1084 | | unsigned int num_glyphs HB_UNUSED, |
1085 | | unsigned int outOfRange) const |
1086 | 0 | { |
1087 | 0 | return get_class (glyph_id, outOfRange); |
1088 | 0 | } Unexecuted instantiation: AAT::ClassTable<OT::NumType<true, unsigned char, 1u> >::get_class(unsigned int, unsigned int, unsigned int) const Unexecuted instantiation: AAT::ClassTable<OT::NumType<true, unsigned short, 2u> >::get_class(unsigned int, unsigned int, unsigned int) const |
1089 | | |
1090 | | template <typename set_t> |
1091 | | void collect_glyphs (set_t &glyphs, unsigned num_glyphs) const |
1092 | 102 | { |
1093 | 152k | for (unsigned i = 0; i < classArray.len; i++) |
1094 | 152k | if (classArray.arrayZ[i] != CLASS_OUT_OF_BOUNDS) |
1095 | 148k | glyphs.add (firstGlyph + i); |
1096 | 102 | } Unexecuted instantiation: void AAT::ClassTable<OT::NumType<true, unsigned char, 1u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const void AAT::ClassTable<OT::NumType<true, unsigned short, 2u> >::collect_glyphs<hb_bit_set_t>(hb_bit_set_t&, unsigned int) const Line | Count | Source | 1092 | 102 | { | 1093 | 152k | for (unsigned i = 0; i < classArray.len; i++) | 1094 | 152k | if (classArray.arrayZ[i] != CLASS_OUT_OF_BOUNDS) | 1095 | 148k | glyphs.add (firstGlyph + i); | 1096 | 102 | } |
|
1097 | | template <typename set_t, typename filter_t> |
1098 | | void collect_glyphs_filtered (set_t &glyphs, unsigned num_glyphs, const filter_t &filter) const |
1099 | 23 | { |
1100 | 46.1k | for (unsigned i = 0; i < classArray.len; i++) |
1101 | 46.1k | if (filter (classArray.arrayZ[i])) |
1102 | 21.1k | glyphs.add (firstGlyph + i); |
1103 | 23 | } |
1104 | | |
1105 | | bool sanitize (hb_sanitize_context_t *c) const |
1106 | 181 | { |
1107 | 181 | TRACE_SANITIZE (this); |
1108 | 181 | return_trace (c->check_struct (this) && classArray.sanitize (c)); |
1109 | 181 | } AAT::ClassTable<OT::NumType<true, unsigned char, 1u> >::sanitize(hb_sanitize_context_t*) const Line | Count | Source | 1106 | 60 | { | 1107 | 60 | TRACE_SANITIZE (this); | 1108 | 60 | return_trace (c->check_struct (this) && classArray.sanitize (c)); | 1109 | 60 | } |
AAT::ClassTable<OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*) const Line | Count | Source | 1106 | 121 | { | 1107 | 121 | TRACE_SANITIZE (this); | 1108 | 121 | return_trace (c->check_struct (this) && classArray.sanitize (c)); | 1109 | 121 | } |
|
1110 | | protected: |
1111 | | HBGlyphID16 firstGlyph; /* First glyph index included in the trimmed array. */ |
1112 | | Array16Of<HBUCHAR> classArray; /* The class codes (indexed by glyph index minus |
1113 | | * firstGlyph). */ |
1114 | | public: |
1115 | | DEFINE_SIZE_ARRAY (4, classArray); |
1116 | | }; |
1117 | | |
1118 | | struct SubtableGlyphCoverage |
1119 | | { |
1120 | | bool sanitize (hb_sanitize_context_t *c, unsigned subtable_count) const |
1121 | 1 | { |
1122 | 1 | TRACE_SANITIZE (this); |
1123 | | |
1124 | 1 | if (unlikely (!c->check_array (&subtableOffsets, subtable_count))) |
1125 | 0 | return_trace (false); |
1126 | | |
1127 | 1 | unsigned bytes = (c->get_num_glyphs () + CHAR_BIT - 1) / CHAR_BIT; |
1128 | 1 | for (unsigned i = 0; i < subtable_count; i++) |
1129 | 0 | { |
1130 | 0 | uint32_t offset = (uint32_t) subtableOffsets[i]; |
1131 | | // A font file called SFNSDisplay.ttf has value 0xFFFFFFFF in the offsets. |
1132 | | // Just ignore it. |
1133 | 0 | if (offset == 0 || offset == 0xFFFFFFFF) |
1134 | 0 | continue; |
1135 | 0 | if (unlikely (!subtableOffsets[i].sanitize (c, this, bytes))) |
1136 | 0 | return_trace (false); |
1137 | 0 | } |
1138 | | |
1139 | 1 | return_trace (true); |
1140 | 1 | } |
1141 | | protected: |
1142 | | UnsizedArrayOf<NNOffset32To<UnsizedArrayOf<HBUINT8>>> subtableOffsets; |
1143 | | /* Array of offsets from the beginning of the |
1144 | | * subtable glyph coverage table to the glyph |
1145 | | * coverage bitfield for a given subtable; there |
1146 | | * is one offset for each subtable in the chain */ |
1147 | | /* UnsizedArrayOf<HBUINT8> coverageBitfields; *//* The individual coverage bitfields. */ |
1148 | | public: |
1149 | | DEFINE_SIZE_ARRAY (0, subtableOffsets); |
1150 | | }; |
1151 | | |
1152 | | struct ObsoleteTypes |
1153 | | { |
1154 | | static constexpr bool extended = false; |
1155 | | typedef HBUINT16 HBUINT; |
1156 | | typedef HBUINT8 HBUSHORT; |
1157 | | typedef ClassTable<HBUINT8> ClassTypeNarrow; |
1158 | | typedef ClassTable<HBUINT16> ClassTypeWide; |
1159 | | |
1160 | | template <typename T> |
1161 | | static int offsetToIndex (int64_t offset, |
1162 | | const void *base, |
1163 | | const T *array) |
1164 | 0 | { |
1165 | 0 | int64_t array_offset = (const char *) array - (const char *) base; |
1166 | 0 | int bad_index = INT_MAX / T::static_size; |
1167 | | |
1168 | | /* https://github.com/harfbuzz/harfbuzz/issues/3483 */ |
1169 | | /* If offset is less than base, return an offset that would |
1170 | | * result in an address half a 32bit address-space away, |
1171 | | * to make sure sanitize fails even on 32bit builds. */ |
1172 | 0 | if (unlikely (offset < array_offset)) |
1173 | 0 | return bad_index; |
1174 | | |
1175 | | /* https://github.com/harfbuzz/harfbuzz/issues/2816 */ |
1176 | 0 | int64_t index = (offset - array_offset) / T::static_size; |
1177 | 0 | if (unlikely (index > bad_index)) |
1178 | 0 | return bad_index; |
1179 | 0 | return index; |
1180 | 0 | } Unexecuted instantiation: int AAT::ObsoleteTypes::offsetToIndex<OT::HBGlyphID16>(long, void const*, OT::HBGlyphID16 const*) Unexecuted instantiation: int AAT::ObsoleteTypes::offsetToIndex<OT::NumType<true, unsigned int, 4u> >(long, void const*, OT::NumType<true, unsigned int, 4u> const*) Unexecuted instantiation: int AAT::ObsoleteTypes::offsetToIndex<OT::NumType<true, unsigned short, 2u> >(long, void const*, OT::NumType<true, unsigned short, 2u> const*) Unexecuted instantiation: int AAT::ObsoleteTypes::offsetToIndex<OT::NumType<true, short, 2u> >(long, void const*, OT::NumType<true, short, 2u> const*) |
1181 | | template <typename T> |
1182 | | static int byteOffsetToIndex (int64_t offset, |
1183 | | const void *base, |
1184 | | const T *array) |
1185 | 0 | { |
1186 | 0 | return offsetToIndex (offset, base, array); |
1187 | 0 | } |
1188 | | template <typename T> |
1189 | | static int wordOffsetToIndex (int64_t offset, |
1190 | | const void *base, |
1191 | | const T *array) |
1192 | 0 | { |
1193 | 0 | return offsetToIndex (2 * offset, base, array); |
1194 | 0 | } Unexecuted instantiation: int AAT::ObsoleteTypes::wordOffsetToIndex<OT::HBGlyphID16>(long, void const*, OT::HBGlyphID16 const*) Unexecuted instantiation: int AAT::ObsoleteTypes::wordOffsetToIndex<OT::NumType<true, unsigned short, 2u> >(long, void const*, OT::NumType<true, unsigned short, 2u> const*) |
1195 | | }; |
1196 | | struct ExtendedTypes |
1197 | | { |
1198 | | static constexpr bool extended = true; |
1199 | | typedef HBUINT32 HBUINT; |
1200 | | typedef HBUINT16 HBUSHORT; |
1201 | | typedef Lookup<HBUINT16> ClassTypeNarrow; |
1202 | | typedef Lookup<HBUINT16> ClassTypeWide; |
1203 | | |
1204 | | template <typename T> |
1205 | | static unsigned int offsetToIndex (unsigned int offset, |
1206 | | const void *base HB_UNUSED, |
1207 | | const T *array HB_UNUSED) |
1208 | 0 | { |
1209 | 0 | return offset; |
1210 | 0 | } Unexecuted instantiation: unsigned int AAT::ExtendedTypes::offsetToIndex<OT::NumType<true, unsigned int, 4u> >(unsigned int, void const*, OT::NumType<true, unsigned int, 4u> const*) Unexecuted instantiation: unsigned int AAT::ExtendedTypes::offsetToIndex<OT::HBGlyphID16>(unsigned int, void const*, OT::HBGlyphID16 const*) Unexecuted instantiation: unsigned int AAT::ExtendedTypes::offsetToIndex<OT::NumType<true, short, 2u> >(unsigned int, void const*, OT::NumType<true, short, 2u> const*) |
1211 | | template <typename T> |
1212 | | static unsigned int byteOffsetToIndex (unsigned int offset, |
1213 | | const void *base HB_UNUSED, |
1214 | | const T *array HB_UNUSED) |
1215 | 0 | { |
1216 | 0 | return offset / 2; |
1217 | 0 | } |
1218 | | template <typename T> |
1219 | | static unsigned int wordOffsetToIndex (unsigned int offset, |
1220 | | const void *base HB_UNUSED, |
1221 | | const T *array HB_UNUSED) |
1222 | 0 | { |
1223 | 0 | return offset; |
1224 | 0 | } Unexecuted instantiation: unsigned int AAT::ExtendedTypes::wordOffsetToIndex<OT::NumType<true, unsigned short, 2u> >(unsigned int, void const*, OT::NumType<true, unsigned short, 2u> const*) Unexecuted instantiation: unsigned int AAT::ExtendedTypes::wordOffsetToIndex<OT::HBGlyphID16>(unsigned int, void const*, OT::HBGlyphID16 const*) |
1225 | | }; |
1226 | | |
1227 | | template <typename Types, typename EntryData, typename Flags> |
1228 | | struct StateTableDriver |
1229 | | { |
1230 | | using StateTableT = StateTable<Types, EntryData>; |
1231 | | using EntryT = Entry<EntryData>; |
1232 | | |
1233 | | StateTableDriver (const StateTableT &machine_, |
1234 | | hb_face_t *face_) : |
1235 | 0 | machine (machine_), |
1236 | 0 | num_glyphs (face_->get_num_glyphs ()) {}Unexecuted instantiation: AAT::StateTableDriver<AAT::ExtendedTypes, void, AAT::RearrangementSubtable<AAT::ExtendedTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ExtendedTypes, void> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData, AAT::ContextualSubtable<AAT::ExtendedTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData, AAT::LigatureSubtable<AAT::ExtendedTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData, AAT::InsertionSubtable<AAT::ExtendedTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::RearrangementSubtable<AAT::ObsoleteTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ObsoleteTypes, void> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData, AAT::ContextualSubtable<AAT::ObsoleteTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::LigatureSubtable<AAT::ObsoleteTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ObsoleteTypes, void> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData, AAT::InsertionSubtable<AAT::ObsoleteTypes>::Flags>::StateTableDriver(AAT::StateTable<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData, AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader>::Flags>::StateTableDriver(AAT::StateTable<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::Flags>::StateTableDriver(AAT::StateTable<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader>::Flags>::StateTableDriver(AAT::StateTable<AAT::ObsoleteTypes, void> const&, hb_face_t*) Unexecuted instantiation: AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader>::Flags>::StateTableDriver(AAT::StateTable<AAT::ObsoleteTypes, void> const&, hb_face_t*) |
1237 | | |
1238 | | template <typename context_t> |
1239 | | void drive (context_t *c, hb_aat_apply_context_t *ac) |
1240 | 0 | { |
1241 | 0 | hb_buffer_t *buffer = ac->buffer; |
1242 | |
|
1243 | 0 | if (!c->in_place) |
1244 | 0 | buffer->clear_output (); |
1245 | |
|
1246 | 0 | int state = StateTableT::STATE_START_OF_TEXT; |
1247 | | // If there's only one range, we already checked the flag. |
1248 | 0 | auto *last_range = ac->range_flags && (ac->range_flags->length > 1) ? &(*ac->range_flags)[0] : nullptr; |
1249 | 0 | const bool start_state_safe_to_break_eot = |
1250 | 0 | !c->table->is_actionable (machine.get_entry (StateTableT::STATE_START_OF_TEXT, CLASS_END_OF_TEXT)); |
1251 | 0 | for (buffer->idx = 0; buffer->successful;) |
1252 | 0 | { |
1253 | 0 | unsigned int klass = likely (buffer->idx < buffer->len) ? |
1254 | 0 | machine.get_class (buffer->cur().codepoint, num_glyphs, ac->machine_class_cache) : |
1255 | 0 | (unsigned) CLASS_END_OF_TEXT; |
1256 | 0 | resume: |
1257 | 0 | DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx); |
1258 | 0 | const EntryT &entry = machine.get_entry (state, klass); |
1259 | 0 | const int next_state = machine.new_state (entry.newState); |
1260 | |
|
1261 | 0 | bool is_not_epsilon_transition = !(entry.flags & Flags::DontAdvance); |
1262 | 0 | bool is_not_actionable = !c->table->is_actionable (entry); |
1263 | |
|
1264 | 0 | if (unlikely (last_range)) |
1265 | 0 | { |
1266 | | /* This block is copied in NoncontextualSubtable::apply. Keep in sync. */ |
1267 | 0 | auto *range = last_range; |
1268 | 0 | if (buffer->idx < buffer->len) |
1269 | 0 | { |
1270 | 0 | unsigned cluster = buffer->cur().cluster; |
1271 | 0 | while (cluster < range->cluster_first) |
1272 | 0 | range--; |
1273 | 0 | while (cluster > range->cluster_last) |
1274 | 0 | range++; |
1275 | | |
1276 | |
|
1277 | 0 | last_range = range; |
1278 | 0 | } |
1279 | 0 | if (!(range->flags & ac->subtable_flags)) |
1280 | 0 | { |
1281 | 0 | if (buffer->idx == buffer->len) |
1282 | 0 | break; |
1283 | | |
1284 | 0 | state = StateTableT::STATE_START_OF_TEXT; |
1285 | 0 | (void) buffer->next_glyph (); |
1286 | 0 | continue; |
1287 | 0 | } |
1288 | 0 | } |
1289 | 0 | else |
1290 | 0 | { |
1291 | | // Fast path for when transitioning from start-state to start-state with |
1292 | | // no action and advancing. Do so as long as the class remains the same. |
1293 | | // This is common with runs of non-actionable glyphs. |
1294 | |
|
1295 | 0 | bool is_null_transition = state == StateTableT::STATE_START_OF_TEXT && |
1296 | 0 | next_state == StateTableT::STATE_START_OF_TEXT && |
1297 | 0 | start_state_safe_to_break_eot && |
1298 | 0 | is_not_actionable && |
1299 | 0 | is_not_epsilon_transition; |
1300 | |
|
1301 | 0 | if (is_null_transition) |
1302 | 0 | { |
1303 | 0 | unsigned old_klass = klass; |
1304 | 0 | do |
1305 | 0 | { |
1306 | 0 | c->transition (buffer, this, entry); |
1307 | |
|
1308 | 0 | if (buffer->idx == buffer->len || !buffer->successful) |
1309 | 0 | break; |
1310 | | |
1311 | 0 | (void) buffer->next_glyph (); |
1312 | |
|
1313 | 0 | klass = likely (buffer->idx < buffer->len) ? |
1314 | 0 | machine.get_class (buffer->cur().codepoint, num_glyphs, ac->machine_class_cache) : |
1315 | 0 | (unsigned) CLASS_END_OF_TEXT; |
1316 | 0 | } while (klass == old_klass); |
1317 | |
|
1318 | 0 | if (buffer->idx == buffer->len || !buffer->successful) |
1319 | 0 | break; |
1320 | | |
1321 | 0 | goto resume; |
1322 | 0 | } |
1323 | 0 | } |
1324 | | |
1325 | | /* Conditions under which it's guaranteed safe-to-break before current glyph: |
1326 | | * |
1327 | | * 1. There was no action in this transition; and |
1328 | | * |
1329 | | * 2. If we break before current glyph, the results will be the same. That |
1330 | | * is guaranteed if: |
1331 | | * |
1332 | | * 2a. We were already in start-of-text state; or |
1333 | | * |
1334 | | * 2b. We are epsilon-transitioning to start-of-text state; or |
1335 | | * |
1336 | | * 2c. Starting from start-of-text state seeing current glyph: |
1337 | | * |
1338 | | * 2c'. There won't be any actions; and |
1339 | | * |
1340 | | * 2c". We would end up in the same state that we were going to end up |
1341 | | * in now, including whether epsilon-transitioning. |
1342 | | * |
1343 | | * and |
1344 | | * |
1345 | | * 3. If we break before current glyph, there won't be any end-of-text action |
1346 | | * after previous glyph. |
1347 | | * |
1348 | | * This triples the transitions we need to look up, but is worth returning |
1349 | | * granular unsafe-to-break results. See eg.: |
1350 | | * |
1351 | | * https://github.com/harfbuzz/harfbuzz/issues/2860 |
1352 | | */ |
1353 | 0 | const EntryT *wouldbe_entry; |
1354 | 0 | bool is_safe_to_break = |
1355 | 0 | ( |
1356 | | /* 1. */ |
1357 | 0 | !c->table->is_actionable (entry) && |
1358 | | |
1359 | | /* 2. */ |
1360 | | // This one is meh, I know... |
1361 | 0 | ( |
1362 | 0 | state == StateTableT::STATE_START_OF_TEXT |
1363 | 0 | || ((entry.flags & Flags::DontAdvance) && next_state == StateTableT::STATE_START_OF_TEXT) |
1364 | 0 | || ( |
1365 | | /* 2c. */ |
1366 | 0 | wouldbe_entry = &machine.get_entry(StateTableT::STATE_START_OF_TEXT, klass) |
1367 | 0 | , |
1368 | | /* 2c'. */ |
1369 | 0 | !c->table->is_actionable (*wouldbe_entry) && |
1370 | | /* 2c". */ |
1371 | 0 | ( |
1372 | 0 | next_state == machine.new_state(wouldbe_entry->newState) && |
1373 | 0 | (entry.flags & Flags::DontAdvance) == (wouldbe_entry->flags & Flags::DontAdvance) |
1374 | 0 | ) |
1375 | 0 | ) |
1376 | 0 | ) && |
1377 | | |
1378 | | /* 3. */ |
1379 | 0 | !c->table->is_actionable (machine.get_entry (state, CLASS_END_OF_TEXT)) |
1380 | 0 | ); |
1381 | |
|
1382 | 0 | if (!is_safe_to_break && buffer->backtrack_len () && buffer->idx < buffer->len) |
1383 | 0 | buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1); |
1384 | |
|
1385 | 0 | c->transition (buffer, this, entry); |
1386 | |
|
1387 | 0 | state = next_state; |
1388 | 0 | DEBUG_MSG (APPLY, nullptr, "s%d", state); |
1389 | |
|
1390 | 0 | if (buffer->idx == buffer->len) |
1391 | 0 | break; |
1392 | | |
1393 | 0 | if (is_not_epsilon_transition || buffer->max_ops-- <= 0) |
1394 | 0 | (void) buffer->next_glyph (); |
1395 | 0 | } |
1396 | | |
1397 | 0 | if (!c->in_place) |
1398 | 0 | buffer->sync (); |
1399 | 0 | } Unexecuted instantiation: void AAT::StateTableDriver<AAT::ExtendedTypes, void, AAT::RearrangementSubtable<AAT::ExtendedTypes>::Flags>::drive<AAT::RearrangementSubtable<AAT::ExtendedTypes>::driver_context_t>(AAT::RearrangementSubtable<AAT::ExtendedTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ExtendedTypes, AAT::ContextualSubtable<AAT::ExtendedTypes>::EntryData, AAT::ContextualSubtable<AAT::ExtendedTypes>::Flags>::drive<AAT::ContextualSubtable<AAT::ExtendedTypes>::driver_context_t>(AAT::ContextualSubtable<AAT::ExtendedTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ExtendedTypes, AAT::LigatureEntry<true>::EntryData, AAT::LigatureSubtable<AAT::ExtendedTypes>::Flags>::drive<AAT::LigatureSubtable<AAT::ExtendedTypes>::driver_context_t>(AAT::LigatureSubtable<AAT::ExtendedTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ExtendedTypes, AAT::InsertionSubtable<AAT::ExtendedTypes>::EntryData, AAT::InsertionSubtable<AAT::ExtendedTypes>::Flags>::drive<AAT::InsertionSubtable<AAT::ExtendedTypes>::driver_context_t>(AAT::InsertionSubtable<AAT::ExtendedTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::RearrangementSubtable<AAT::ObsoleteTypes>::Flags>::drive<AAT::RearrangementSubtable<AAT::ObsoleteTypes>::driver_context_t>(AAT::RearrangementSubtable<AAT::ObsoleteTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ObsoleteTypes, AAT::ContextualSubtable<AAT::ObsoleteTypes>::EntryData, AAT::ContextualSubtable<AAT::ObsoleteTypes>::Flags>::drive<AAT::ContextualSubtable<AAT::ObsoleteTypes>::driver_context_t>(AAT::ContextualSubtable<AAT::ObsoleteTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::LigatureSubtable<AAT::ObsoleteTypes>::Flags>::drive<AAT::LigatureSubtable<AAT::ObsoleteTypes>::driver_context_t>(AAT::LigatureSubtable<AAT::ObsoleteTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ObsoleteTypes, AAT::InsertionSubtable<AAT::ObsoleteTypes>::EntryData, AAT::InsertionSubtable<AAT::ObsoleteTypes>::Flags>::drive<AAT::InsertionSubtable<AAT::ObsoleteTypes>::driver_context_t>(AAT::InsertionSubtable<AAT::ObsoleteTypes>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ExtendedTypes, AAT::Format1Entry<true>::EntryData, AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader>::Flags>::drive<AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader>::driver_context_t>(AAT::KerxSubTableFormat1<AAT::KerxSubTableHeader>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ExtendedTypes, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::EntryData, AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::Flags>::drive<AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::driver_context_t>(AAT::KerxSubTableFormat4<AAT::KerxSubTableHeader>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader>::Flags>::drive<AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader>::driver_context_t>(AAT::KerxSubTableFormat1<OT::KernOTSubTableHeader>::driver_context_t*, AAT::hb_aat_apply_context_t*) Unexecuted instantiation: void AAT::StateTableDriver<AAT::ObsoleteTypes, void, AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader>::Flags>::drive<AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader>::driver_context_t>(AAT::KerxSubTableFormat1<OT::KernAATSubTableHeader>::driver_context_t*, AAT::hb_aat_apply_context_t*) |
1400 | | |
1401 | | public: |
1402 | | const StateTableT &machine; |
1403 | | unsigned int num_glyphs; |
1404 | | }; |
1405 | | |
1406 | | |
1407 | | } /* namespace AAT */ |
1408 | | |
1409 | | |
1410 | | #endif /* HB_AAT_LAYOUT_COMMON_HH */ |