Coverage Report

Created: 2025-08-29 06:20

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