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