Coverage Report

Created: 2026-06-30 11:14

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