Coverage Report

Created: 2026-09-28 10:59

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