Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/workdir/UnpackedTarball/harfbuzz/src/hb-ot-layout-gsubgpos.hh
Line
Count
Source
1
/*
2
 * Copyright © 2007,2008,2009,2010  Red Hat, Inc.
3
 * Copyright © 2010,2012  Google, Inc.
4
 *
5
 *  This is part of HarfBuzz, a text shaping library.
6
 *
7
 * Permission is hereby granted, without written agreement and without
8
 * license or royalty fees, to use, copy, modify, and distribute this
9
 * software and its documentation for any purpose, provided that the
10
 * above copyright notice and the following two paragraphs appear in
11
 * all copies of this software.
12
 *
13
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17
 * DAMAGE.
18
 *
19
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24
 *
25
 * Red Hat Author(s): Behdad Esfahbod
26
 * Google Author(s): Behdad Esfahbod
27
 */
28
29
#ifndef HB_OT_LAYOUT_GSUBGPOS_HH
30
#define HB_OT_LAYOUT_GSUBGPOS_HH
31
32
#include "hb.hh"
33
#include "hb-buffer.hh"
34
#include "hb-map.hh"
35
#include "hb-set.hh"
36
#include "hb-ot-map.hh"
37
#include "hb-ot-layout-common.hh"
38
#include "hb-ot-layout-gdef-table.hh"
39
40
41
namespace OT {
42
43
44
struct hb_intersects_context_t :
45
       hb_dispatch_context_t<hb_intersects_context_t, bool>
46
{
47
  template <typename T>
48
0
  return_t dispatch (const T &obj) { return obj.intersects (this->glyphs); }
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_intersects_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
49
0
  static return_t default_return_value () { return false; }
50
0
  bool stop_sublookup_iteration (return_t r) const { return r; }
51
52
  const hb_set_t *glyphs;
53
54
  hb_intersects_context_t (const hb_set_t *glyphs_) :
55
0
                            glyphs (glyphs_) {}
56
};
57
58
struct hb_have_non_1to1_context_t :
59
       hb_dispatch_context_t<hb_have_non_1to1_context_t, bool>
60
{
61
  template <typename T>
62
0
  return_t dispatch (const T &obj) { return obj.may_have_non_1to1 (); }
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_have_non_1to1_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
63
0
  static return_t default_return_value () { return false; }
64
0
  bool stop_sublookup_iteration (return_t r) const { return r; }
65
};
66
67
struct hb_closure_context_t :
68
       hb_dispatch_context_t<hb_closure_context_t>
69
{
70
  typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indicies, unsigned seq_index, unsigned end_index);
71
  template <typename T>
72
0
  return_t dispatch (const T &obj) { obj.closure (this); return hb_empty_t (); }
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
73
0
  static return_t default_return_value () { return hb_empty_t (); }
74
  void recurse (unsigned lookup_index, hb_set_t *covered_seq_indicies, unsigned seq_index, unsigned end_index)
75
0
  {
76
0
    if (unlikely (nesting_level_left == 0 || !recurse_func))
77
0
      return;
78
79
0
    nesting_level_left--;
80
0
    recurse_func (this, lookup_index, covered_seq_indicies, seq_index, end_index);
81
0
    nesting_level_left++;
82
0
  }
83
84
  void reset_lookup_visit_count ()
85
0
  { lookup_count = 0; }
86
87
  bool lookup_limit_exceeded ()
88
0
  { return lookup_count > HB_MAX_LOOKUP_VISIT_COUNT; }
89
90
  bool should_visit_lookup (unsigned int lookup_index)
91
0
  {
92
0
    if (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT)
93
0
      return false;
94
95
0
    if (is_lookup_done (lookup_index))
96
0
      return false;
97
98
0
    return true;
99
0
  }
100
101
  bool is_lookup_done (unsigned int lookup_index)
102
0
  {
103
0
    if (unlikely (done_lookups_glyph_count->in_error () ||
104
0
      done_lookups_glyph_set->in_error ()))
105
0
      return true;
106
107
    /* Have we visited this lookup with the current set of glyphs? */
108
0
    if (done_lookups_glyph_count->get (lookup_index) != glyphs->get_population ())
109
0
    {
110
0
      done_lookups_glyph_count->set (lookup_index, glyphs->get_population ());
111
112
0
      if (!done_lookups_glyph_set->has (lookup_index))
113
0
      {
114
0
  if (unlikely (!done_lookups_glyph_set->set (lookup_index, hb::unique_ptr<hb_set_t> {hb_set_create ()})))
115
0
    return true;
116
0
      }
117
118
0
      done_lookups_glyph_set->get (lookup_index)->clear ();
119
0
    }
120
121
0
    hb_set_t *covered_glyph_set = done_lookups_glyph_set->get (lookup_index);
122
0
    if (unlikely (covered_glyph_set->in_error ()))
123
0
      return true;
124
0
    if (parent_active_glyphs ().is_subset (*covered_glyph_set))
125
0
      return true;
126
127
0
    covered_glyph_set->union_ (parent_active_glyphs ());
128
0
    return false;
129
0
  }
130
131
0
  const hb_set_t& previous_parent_active_glyphs () {
132
0
    if (active_glyphs_stack.length <= 1)
133
0
      return *glyphs;
134
135
0
    return active_glyphs_stack[active_glyphs_stack.length - 2];
136
0
  }
137
138
  const hb_set_t& parent_active_glyphs ()
139
0
  {
140
0
    if (!active_glyphs_stack)
141
0
      return *glyphs;
142
143
0
    return active_glyphs_stack.tail ();
144
0
  }
145
146
  hb_set_t* push_cur_active_glyphs ()
147
0
  {
148
0
    hb_set_t *s = active_glyphs_stack.push ();
149
0
    if (unlikely (active_glyphs_stack.in_error ()))
150
0
      return nullptr;
151
0
    return s;
152
0
  }
153
154
  bool pop_cur_done_glyphs ()
155
0
  {
156
0
    if (!active_glyphs_stack)
157
0
      return false;
158
159
0
    active_glyphs_stack.pop ();
160
0
    return true;
161
0
  }
162
163
  hb_face_t *face;
164
  hb_set_t *glyphs;
165
  hb_set_t output[1];
166
  hb_vector_t<hb_set_t> active_glyphs_stack;
167
  recurse_func_t recurse_func = nullptr;
168
  unsigned int nesting_level_left;
169
170
  hb_closure_context_t (hb_face_t *face_,
171
      hb_set_t *glyphs_,
172
      hb_map_t *done_lookups_glyph_count_,
173
      hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *done_lookups_glyph_set_,
174
      unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
175
0
        face (face_),
176
0
        glyphs (glyphs_),
177
0
        nesting_level_left (nesting_level_left_),
178
0
        done_lookups_glyph_count (done_lookups_glyph_count_),
179
0
        done_lookups_glyph_set (done_lookups_glyph_set_)
180
0
  {}
181
182
0
  ~hb_closure_context_t () { flush (); }
183
184
0
  void set_recurse_func (recurse_func_t func) { recurse_func = func; }
185
186
  void flush ()
187
0
  {
188
0
    output->del_range (face->get_num_glyphs (), HB_SET_VALUE_INVALID);  /* Remove invalid glyphs. */
189
0
    glyphs->union_ (*output);
190
0
    output->clear ();
191
0
    active_glyphs_stack.pop ();
192
0
    active_glyphs_stack.reset ();
193
0
  }
194
195
  private:
196
  hb_map_t *done_lookups_glyph_count;
197
  hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *done_lookups_glyph_set;
198
  unsigned int lookup_count = 0;
199
};
200
201
202
203
struct hb_closure_lookups_context_t :
204
       hb_dispatch_context_t<hb_closure_lookups_context_t>
205
{
206
  typedef return_t (*recurse_func_t) (hb_closure_lookups_context_t *c, unsigned lookup_index);
207
  template <typename T>
208
0
  return_t dispatch (const T &obj) { obj.closure_lookups (this); return hb_empty_t (); }
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_closure_lookups_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
209
0
  static return_t default_return_value () { return hb_empty_t (); }
210
  void recurse (unsigned lookup_index)
211
0
  {
212
0
    if (unlikely (nesting_level_left == 0 || !recurse_func))
213
0
      return;
214
215
    /* Return if new lookup was recursed to before. */
216
0
    if (lookup_limit_exceeded ()
217
0
        || visited_lookups->in_error ()
218
0
        || visited_lookups->has (lookup_index))
219
      // Don't increment lookup count here, that will be done in the call to closure_lookups()
220
      // made by recurse_func.
221
0
      return;
222
223
0
    nesting_level_left--;
224
0
    recurse_func (this, lookup_index);
225
0
    nesting_level_left++;
226
0
  }
227
228
  void set_lookup_visited (unsigned lookup_index)
229
0
  { visited_lookups->add (lookup_index); }
230
231
  void set_lookup_inactive (unsigned lookup_index)
232
0
  { inactive_lookups->add (lookup_index); }
233
234
  bool lookup_limit_exceeded ()
235
0
  {
236
0
    bool ret = lookup_count > HB_MAX_LOOKUP_VISIT_COUNT;
237
0
    if (ret)
238
0
      DEBUG_MSG (SUBSET, nullptr, "lookup visit count limit exceeded in lookup closure!");
239
0
    return ret; }
240
241
  bool is_lookup_visited (unsigned lookup_index)
242
0
  {
243
0
    if (unlikely (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT))
244
0
    {
245
0
      DEBUG_MSG (SUBSET, nullptr, "total visited lookup count %u exceeds max limit, lookup %u is dropped.",
246
0
                 lookup_count, lookup_index);
247
0
      return true;
248
0
    }
249
250
0
    if (unlikely (visited_lookups->in_error ()))
251
0
      return true;
252
253
0
    return visited_lookups->has (lookup_index);
254
0
  }
255
256
  hb_face_t *face;
257
  const hb_set_t *glyphs;
258
  recurse_func_t recurse_func;
259
  unsigned int nesting_level_left;
260
261
  hb_closure_lookups_context_t (hb_face_t *face_,
262
        const hb_set_t *glyphs_,
263
        hb_set_t *visited_lookups_,
264
        hb_set_t *inactive_lookups_,
265
        unsigned nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
266
0
        face (face_),
267
0
        glyphs (glyphs_),
268
0
        recurse_func (nullptr),
269
0
        nesting_level_left (nesting_level_left_),
270
0
        visited_lookups (visited_lookups_),
271
0
        inactive_lookups (inactive_lookups_),
272
0
        lookup_count (0) {}
273
274
0
  void set_recurse_func (recurse_func_t func) { recurse_func = func; }
275
276
  private:
277
  hb_set_t *visited_lookups;
278
  hb_set_t *inactive_lookups;
279
  unsigned int lookup_count;
280
};
281
282
struct hb_would_apply_context_t :
283
       hb_dispatch_context_t<hb_would_apply_context_t, bool>
284
{
285
  template <typename T>
286
0
  return_t dispatch (const T &obj) { return obj.would_apply (this); }
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_would_apply_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
287
0
  static return_t default_return_value () { return false; }
288
0
  bool stop_sublookup_iteration (return_t r) const { return r; }
289
290
  hb_face_t *face;
291
  const hb_codepoint_t *glyphs;
292
  unsigned int len;
293
  bool zero_context;
294
295
  hb_would_apply_context_t (hb_face_t *face_,
296
          const hb_codepoint_t *glyphs_,
297
          unsigned int len_,
298
          bool zero_context_) :
299
0
            face (face_),
300
0
            glyphs (glyphs_),
301
0
            len (len_),
302
0
            zero_context (zero_context_) {}
303
};
304
305
struct hb_collect_glyphs_context_t :
306
       hb_dispatch_context_t<hb_collect_glyphs_context_t>
307
{
308
  typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index);
309
  template <typename T>
310
0
  return_t dispatch (const T &obj) { obj.collect_glyphs (this); return hb_empty_t (); }
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_glyphs_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
311
0
  static return_t default_return_value () { return hb_empty_t (); }
312
  void recurse (unsigned int lookup_index)
313
0
  {
314
0
    if (unlikely (nesting_level_left == 0 || !recurse_func))
315
0
      return;
316
317
    /* Note that GPOS sets recurse_func to nullptr already, so it doesn't get
318
     * past the previous check.  For GSUB, we only want to collect the output
319
     * glyphs in the recursion.  If output is not requested, we can go home now.
320
     *
321
     * Note further, that the above is not exactly correct.  A recursed lookup
322
     * is allowed to match input that is not matched in the context, but that's
323
     * not how most fonts are built.  It's possible to relax that and recurse
324
     * with all sets here if it proves to be an issue.
325
     */
326
327
0
    if (output == hb_set_get_empty ())
328
0
      return;
329
330
    /* Return if new lookup was recursed to before. */
331
0
    if (recursed_lookups->has (lookup_index))
332
0
      return;
333
334
0
    hb_set_t *old_before = before;
335
0
    hb_set_t *old_input  = input;
336
0
    hb_set_t *old_after  = after;
337
0
    before = input = after = hb_set_get_empty ();
338
339
0
    nesting_level_left--;
340
0
    recurse_func (this, lookup_index);
341
0
    nesting_level_left++;
342
343
0
    before = old_before;
344
0
    input  = old_input;
345
0
    after  = old_after;
346
347
0
    recursed_lookups->add (lookup_index);
348
0
  }
349
350
  hb_face_t *face;
351
  hb_set_t *before;
352
  hb_set_t *input;
353
  hb_set_t *after;
354
  hb_set_t *output;
355
  recurse_func_t recurse_func;
356
  hb_set_t *recursed_lookups;
357
  unsigned int nesting_level_left;
358
359
  hb_collect_glyphs_context_t (hb_face_t *face_,
360
             hb_set_t  *glyphs_before, /* OUT.  May be NULL */
361
             hb_set_t  *glyphs_input,  /* OUT.  May be NULL */
362
             hb_set_t  *glyphs_after,  /* OUT.  May be NULL */
363
             hb_set_t  *glyphs_output, /* OUT.  May be NULL */
364
             unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
365
0
            face (face_),
366
0
            before (glyphs_before ? glyphs_before : hb_set_get_empty ()),
367
0
            input  (glyphs_input  ? glyphs_input  : hb_set_get_empty ()),
368
0
            after  (glyphs_after  ? glyphs_after  : hb_set_get_empty ()),
369
0
            output (glyphs_output ? glyphs_output : hb_set_get_empty ()),
370
0
            recurse_func (nullptr),
371
0
            recursed_lookups (hb_set_create ()),
372
0
            nesting_level_left (nesting_level_left_) {}
373
0
  ~hb_collect_glyphs_context_t () { hb_set_destroy (recursed_lookups); }
374
375
0
  void set_recurse_func (recurse_func_t func) { recurse_func = func; }
376
};
377
378
379
380
template <typename set_t>
381
struct hb_collect_coverage_context_t :
382
       hb_dispatch_context_t<hb_collect_coverage_context_t<set_t>, const Coverage &>
383
{
384
  typedef const Coverage &return_t; // Stoopid that we have to dupe this here.
385
  template <typename T>
386
  return_t dispatch (const T &obj) { return obj.get_coverage (); }
387
  static return_t default_return_value () { return Null (Coverage); }
388
  bool stop_sublookup_iteration (return_t r) const
389
  {
390
    r.collect_coverage (set);
391
    return false;
392
  }
393
394
  hb_collect_coverage_context_t (set_t *set_) :
395
           set (set_) {}
396
397
  set_t *set;
398
};
399
400
struct matcher_t
401
{
402
  typedef bool (*match_func_t) (hb_glyph_info_t &info, unsigned value, const void *data);
403
404
  template <typename context_t>
405
  void init (const context_t *c, bool context_match = false)
406
145M
  {
407
145M
    set_match_func (nullptr, nullptr);
408
145M
    lookup_props = c->lookup_props;
409
    /* Ignore ZWNJ if we are matching GPOS, or matching GSUB context and asked to. */
410
145M
    ignore_zwnj = c->table_index == 1 || (context_match && c->auto_zwnj);
411
    /* Ignore ZWJ if we are matching context, or asked to. */
412
145M
    ignore_zwj = context_match || c->auto_zwj;
413
    /* Ignore hidden glyphs (like CGJ) during GPOS. */
414
145M
    ignore_hidden = c->table_index == 1;
415
145M
    mask = context_match ? -1 : c->lookup_mask;
416
    /* Per syllable matching is only for GSUB. */
417
145M
    per_syllable = c->table_index == 0 && c->per_syllable;
418
145M
    syllable = 0;
419
145M
  }
420
421
  void set_match_func (match_func_t match_func_,
422
           const void *match_data_)
423
148M
  { match_func = match_func_; match_data = match_data_; }
424
425
  enum may_match_t {
426
    MATCH_NO,
427
    MATCH_YES,
428
    MATCH_MAYBE
429
  };
430
431
#ifndef HB_OPTIMIZE_SIZE
432
  HB_ALWAYS_INLINE
433
#endif
434
  may_match_t may_match (hb_glyph_info_t &info,
435
       hb_codepoint_t glyph_data) const
436
20.5M
  {
437
20.5M
    if (!(info.mask & mask) ||
438
20.5M
  (per_syllable && syllable && syllable != info.syllable ()))
439
0
      return MATCH_NO;
440
441
20.5M
    if (match_func)
442
1.32M
      return match_func (info, glyph_data, match_data) ? MATCH_YES : MATCH_NO;
443
444
19.1M
    return MATCH_MAYBE;
445
20.5M
  }
446
447
  enum may_skip_t {
448
    SKIP_NO,
449
    SKIP_YES,
450
    SKIP_MAYBE
451
  };
452
453
  template <typename context_t>
454
#ifndef HB_OPTIMIZE_SIZE
455
  HB_ALWAYS_INLINE
456
#endif
457
  may_skip_t may_skip (const context_t *c,
458
           const hb_glyph_info_t &info) const
459
20.6M
  {
460
20.6M
    if (!c->check_glyph_property (&info, lookup_props))
461
124k
      return SKIP_YES;
462
463
20.5M
    if (unlikely (_hb_glyph_info_is_default_ignorable (&info) &&
464
20.5M
      (ignore_zwnj || !_hb_glyph_info_is_zwnj (&info)) &&
465
20.5M
      (ignore_zwj || !_hb_glyph_info_is_zwj (&info)) &&
466
20.5M
      (ignore_hidden || !_hb_glyph_info_is_hidden (&info))))
467
11.9k
      return SKIP_MAYBE;
468
469
20.5M
    return SKIP_NO;
470
20.5M
  }
471
472
  public:
473
  unsigned int lookup_props = 0;
474
  hb_mask_t mask = -1;
475
  bool ignore_zwnj = false;
476
  bool ignore_zwj = false;
477
  bool ignore_hidden = false;
478
  bool per_syllable = false;
479
  uint8_t syllable = 0;
480
  match_func_t match_func = nullptr;
481
  const void *match_data = nullptr;
482
};
483
484
template <typename context_t>
485
struct skipping_iterator_t
486
{
487
  void init (context_t *c_, bool context_match = false)
488
145M
  {
489
145M
    c = c_;
490
145M
    end = c->buffer->len;
491
145M
    match_glyph_data16 = nullptr;
492
#ifndef HB_NO_BEYOND_64K
493
    match_glyph_data24 = nullptr;
494
#endif
495
145M
    matcher.init (c, context_match);
496
145M
  }
497
  void set_lookup_props (unsigned int lookup_props)
498
592k
  {
499
592k
    matcher.lookup_props = lookup_props;
500
592k
  }
501
  void set_match_func (matcher_t::match_func_t match_func_,
502
           const void *match_data_)
503
2.27M
  {
504
2.27M
    matcher.set_match_func (match_func_, match_data_);
505
2.27M
  }
506
  void set_glyph_data (const HBUINT16 glyph_data[])
507
2.27M
  {
508
2.27M
    match_glyph_data16 = glyph_data;
509
#ifndef HB_NO_BEYOND_64K
510
    match_glyph_data24 = nullptr;
511
#endif
512
2.27M
  }
513
#ifndef HB_NO_BEYOND_64K
514
  void set_glyph_data (const HBUINT24 glyph_data[])
515
  {
516
    match_glyph_data16 = nullptr;
517
    match_glyph_data24 = glyph_data;
518
  }
519
#endif
520
521
#ifndef HB_OPTIMIZE_SIZE
522
  HB_ALWAYS_INLINE
523
#endif
524
  void reset (unsigned int start_index_)
525
1.41M
  {
526
    // For GSUB forward iterator
527
1.41M
    idx = start_index_;
528
1.41M
    end = c->buffer->len;
529
1.41M
    matcher.syllable = c->buffer->cur().syllable();
530
1.41M
  }
531
  void reset_back (unsigned int start_index_, bool from_out_buffer = false)
532
864k
  {
533
    // For GSUB backward iterator
534
864k
    idx = start_index_;
535
864k
    matcher.syllable = c->buffer->cur().syllable();
536
864k
  }
537
538
#ifndef HB_OPTIMIZE_SIZE
539
  HB_ALWAYS_INLINE
540
#endif
541
  void reset_fast (unsigned int start_index_)
542
20.7M
  {
543
    // Doesn't set end or syllable. Used by GPOS which doesn't care / change.
544
20.7M
    idx = start_index_;
545
20.7M
  }
546
547
#ifndef HB_OPTIMIZE_SIZE
548
  HB_ALWAYS_INLINE
549
#endif
550
  matcher_t::may_skip_t may_skip (const hb_glyph_info_t &info) const
551
32.8k
  { return matcher.may_skip (c, info); }
552
553
  enum match_t {
554
    MATCH,
555
    NOT_MATCH,
556
    SKIP
557
  };
558
559
#ifndef HB_OPTIMIZE_SIZE
560
  HB_ALWAYS_INLINE
561
#endif
562
  match_t match (hb_glyph_info_t &info)
563
20.6M
  {
564
20.6M
    matcher_t::may_skip_t skip = matcher.may_skip (c, info);
565
20.6M
    if (unlikely (skip == matcher_t::SKIP_YES))
566
124k
      return SKIP;
567
568
20.5M
    matcher_t::may_match_t match = matcher.may_match (info, get_glyph_data ());
569
20.5M
    if (match == matcher_t::MATCH_YES ||
570
20.1M
  (match == matcher_t::MATCH_MAYBE &&
571
19.1M
   skip == matcher_t::SKIP_NO))
572
19.5M
      return MATCH;
573
574
1.00M
    if (skip == matcher_t::SKIP_NO)
575
990k
      return NOT_MATCH;
576
577
11.8k
    return SKIP;
578
1.00M
  }
579
580
#ifndef HB_OPTIMIZE_SIZE
581
  HB_ALWAYS_INLINE
582
#endif
583
  bool next (unsigned *unsafe_to = nullptr)
584
22.0M
  {
585
22.0M
    auto *info = c->buffer->info;
586
22.0M
    const signed stop = (signed) end - 1;
587
22.0M
    while ((signed) idx < stop)
588
19.5M
    {
589
19.5M
      idx++;
590
19.5M
      switch (match (info[idx]))
591
19.5M
      {
592
18.9M
  case MATCH:
593
18.9M
  {
594
18.9M
    advance_glyph_data ();
595
18.9M
    return true;
596
0
  }
597
467k
  case NOT_MATCH:
598
467k
  {
599
467k
    if (unsafe_to)
600
467k
      *unsafe_to = idx + 1;
601
467k
    return false;
602
0
  }
603
72.0k
  case SKIP:
604
72.0k
    continue;
605
19.5M
      }
606
19.5M
    }
607
2.58M
    if (unsafe_to)
608
2.58M
      *unsafe_to = end;
609
2.58M
    return false;
610
22.0M
  }
611
#ifndef HB_OPTIMIZE_SIZE
612
  HB_ALWAYS_INLINE
613
#endif
614
  bool prev (unsigned *unsafe_from = nullptr)
615
1.15M
  {
616
1.15M
    auto *out_info = c->buffer->out_info;
617
1.15M
    const unsigned stop = 0;
618
1.16M
    while (idx > stop)
619
805k
    {
620
805k
      idx--;
621
805k
      switch (match (out_info[idx]))
622
805k
      {
623
281k
  case MATCH:
624
281k
  {
625
281k
    advance_glyph_data ();
626
281k
    return true;
627
0
  }
628
523k
  case NOT_MATCH:
629
523k
  {
630
523k
    if (unsafe_from)
631
523k
      *unsafe_from = hb_max (1u, idx) - 1u;
632
523k
    return false;
633
0
  }
634
1.20k
  case SKIP:
635
1.20k
    continue;
636
805k
      }
637
805k
    }
638
354k
    if (unsafe_from)
639
354k
      *unsafe_from = 0;
640
354k
    return false;
641
1.15M
  }
642
643
  HB_ALWAYS_INLINE
644
  hb_codepoint_t
645
  get_glyph_data ()
646
20.5M
  {
647
20.5M
    if (match_glyph_data16) return *match_glyph_data16;
648
#ifndef HB_NO_BEYOND_64K
649
    else
650
    if (match_glyph_data24) return *match_glyph_data24;
651
#endif
652
19.2M
    return 0;
653
20.5M
  }
654
  HB_ALWAYS_INLINE
655
  void
656
  advance_glyph_data ()
657
19.2M
  {
658
19.2M
    if (match_glyph_data16) match_glyph_data16++;
659
#ifndef HB_NO_BEYOND_64K
660
    else
661
    if (match_glyph_data24) match_glyph_data24++;
662
#endif
663
19.2M
  }
664
665
  unsigned int idx;
666
  protected:
667
  context_t *c;
668
  matcher_t matcher;
669
  const HBUINT16 *match_glyph_data16;
670
#ifndef HB_NO_BEYOND_64K
671
  const HBUINT24 *match_glyph_data24;
672
#endif
673
674
  unsigned int end;
675
};
676
677
struct hb_ot_apply_context_t :
678
       hb_dispatch_context_t<hb_ot_apply_context_t, bool, HB_DEBUG_APPLY>
679
{
680
0
  const char *get_name () { return "APPLY"; }
681
  typedef return_t (*recurse_func_t) (hb_ot_apply_context_t *c, unsigned int lookup_index);
682
683
  template <typename T>
684
  static inline auto apply_ (const T &obj, hb_ot_apply_context_t *c, hb_priority<1>) HB_RETURN (return_t, obj.apply (c, nullptr) )
685
  template <typename T>
686
  static inline auto apply_ (const T &obj, hb_ot_apply_context_t *c, hb_priority<0>) HB_RETURN (return_t, obj.apply (c) )
687
  template <typename T>
688
0
  return_t dispatch (const T &obj) { return apply_(obj, this, hb_prioritize); }
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: bool OT::hb_ot_apply_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
689
690
0
  static return_t default_return_value () { return false; }
691
0
  bool stop_sublookup_iteration (return_t r) const { return r; }
692
  return_t recurse (unsigned int sub_lookup_index)
693
8.30k
  {
694
8.30k
    assert (recurse_func);
695
8.30k
    if (unlikely (nesting_level_left == 0))
696
0
    {
697
0
      buffer->successful = false;
698
0
      return default_return_value ();
699
0
    }
700
701
8.30k
    buffer->max_ops--;
702
8.30k
    if (unlikely (buffer->max_ops < 0))
703
0
    {
704
0
      buffer->successful = false;
705
0
      return default_return_value ();
706
0
    }
707
708
8.30k
    nesting_level_left--;
709
8.30k
    bool ret = recurse_func (this, sub_lookup_index);
710
8.30k
    nesting_level_left++;
711
8.30k
    return ret;
712
8.30k
  }
713
714
  skipping_iterator_t<hb_ot_apply_context_t> iter_input, iter_context;
715
716
  unsigned int table_index; /* GSUB/GPOS */
717
  hb_font_t *font;
718
  hb_face_t *face;
719
  hb_buffer_t *buffer;
720
  hb_sanitize_context_t sanitizer;
721
  recurse_func_t recurse_func = nullptr;
722
  const GDEF &gdef;
723
  const GDEF::accelerator_t &gdef_accel;
724
  const hb_ot_layout_lookup_accelerator_t *lookup_accel = nullptr;
725
  const ItemVariationStore &var_store;
726
  hb_scalar_cache_t *var_store_cache;
727
728
  hb_direction_t direction;
729
  hb_mask_t lookup_mask = 1;
730
  unsigned int lookup_index = (unsigned) -1;
731
  unsigned int lookup_props = 0;
732
  unsigned int nesting_level_left = HB_MAX_NESTING_LEVEL;
733
734
  bool has_glyph_classes;
735
  bool auto_zwnj = true;
736
  bool auto_zwj = true;
737
  bool per_syllable = false;
738
  bool random = false;
739
  unsigned new_syllables = (unsigned) -1;
740
741
  signed last_base = -1; // GPOS uses
742
  unsigned last_base_until = 0; // GPOS uses
743
744
  hb_vector_t<uint32_t> match_positions;
745
  uint32_t stack_match_positions[8];
746
#ifndef HB_NO_BUFFER_MESSAGE
747
  hb_buffer_t::changed_func_t orig_changed_func = nullptr;
748
  void *orig_changed_data = nullptr;
749
#endif
750
751
  hb_ot_apply_context_t (unsigned int table_index_,
752
       hb_font_t *font_,
753
       hb_buffer_t *buffer_,
754
       hb_blob_t *table_blob_,
755
       hb_scalar_cache_t *var_store_cache_ = nullptr) :
756
63.8M
      table_index (table_index_),
757
63.8M
      font (font_), face (font->face), buffer (buffer_),
758
63.8M
      sanitizer (table_blob_),
759
      gdef (
760
#ifndef HB_NO_OT_LAYOUT
761
63.8M
            *face->table.GDEF->table
762
#else
763
            Null (GDEF)
764
#endif
765
           ),
766
      gdef_accel (
767
#ifndef HB_NO_OT_LAYOUT
768
63.8M
            *face->table.GDEF
769
#else
770
            Null (GDEF::accelerator_t)
771
#endif
772
           ),
773
63.8M
      var_store (gdef.get_var_store ()),
774
63.8M
      var_store_cache (var_store_cache_),
775
63.8M
      direction (buffer_->props.direction),
776
63.8M
      has_glyph_classes (gdef.has_glyph_classes ())
777
63.8M
  {
778
63.8M
    init_iters ();
779
63.8M
    match_positions.set_storage (stack_match_positions);
780
781
63.8M
#ifndef HB_NO_BUFFER_MESSAGE
782
63.8M
    if (buffer->messaging ())
783
0
    {
784
0
      assert (buffer->changed_func == nullptr ||
785
0
        buffer->changed_func == buffer_changed_trampoline);
786
0
      orig_changed_func = buffer->changed_func;
787
0
      orig_changed_data = buffer->changed_data;
788
0
      buffer->changed_func = buffer_changed_trampoline;
789
0
      buffer->changed_data = this;
790
0
    }
791
63.8M
#endif
792
63.8M
  }
793
  ~hb_ot_apply_context_t ()
794
63.8M
  {
795
63.8M
#ifndef HB_NO_BUFFER_MESSAGE
796
63.8M
    if (buffer->messaging ())
797
0
    {
798
0
      assert (buffer->changed_func == buffer_changed_trampoline);
799
0
      assert (buffer->changed_data == this);
800
0
      buffer->changed_func = orig_changed_func;
801
0
      buffer->changed_data = orig_changed_data;
802
0
    }
803
63.8M
#endif
804
63.8M
  }
805
806
  void init_iters ()
807
72.8M
  {
808
72.8M
    iter_input.init (this, false);
809
72.8M
    iter_context.init (this, true);
810
72.8M
  }
811
812
8.31M
  void set_lookup_mask (hb_mask_t mask, bool init = true) { lookup_mask = mask; last_base = -1; last_base_until = 0; if (init) init_iters (); }
813
7.60M
  void set_auto_zwj (bool auto_zwj_, bool init = true) { auto_zwj = auto_zwj_; if (init) init_iters (); }
814
7.60M
  void set_auto_zwnj (bool auto_zwnj_, bool init = true) { auto_zwnj = auto_zwnj_; if (init) init_iters (); }
815
7.60M
  void set_per_syllable (bool per_syllable_, bool init = true) { per_syllable = per_syllable_; if (init) init_iters (); }
816
7.60M
  void set_random (bool random_) { random = random_; }
817
62.4M
  void set_recurse_func (recurse_func_t func) { recurse_func = func; }
818
7.62M
  void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; }
819
  void set_lookup_props (unsigned int lookup_props_)
820
8.33M
  {
821
8.33M
    lookup_props = gdef_accel.sanitize_lookup_props (lookup_props_);
822
8.33M
    init_iters ();
823
8.33M
  }
824
825
  uint32_t random_number ()
826
0
  {
827
    /* http://www.cplusplus.com/reference/random/minstd_rand/ */
828
0
    buffer->random_state = buffer->random_state * 48271 % 2147483647;
829
0
    return buffer->random_state;
830
0
  }
831
832
  static void buffer_changed_trampoline (hb_buffer_t *buffer HB_UNUSED, void *user_data)
833
0
  {
834
0
    ((hb_ot_apply_context_t *) user_data)->buffer_changed ();
835
0
  }
836
  void buffer_changed ()
837
0
  {
838
0
    buffer->update_digest ();
839
0
    if (likely (has_glyph_classes))
840
0
      for (unsigned i = 0; i < buffer->len; i++)
841
0
  _set_glyph_class_props (buffer->info[i]);
842
0
  }
843
844
  HB_ALWAYS_INLINE
845
  HB_HOT
846
  bool match_properties_mark (const hb_glyph_info_t *info,
847
            unsigned int    glyph_props,
848
            unsigned int    match_props) const
849
1.37M
  {
850
    /* If using mark filtering sets, the high short of
851
     * match_props has the set index.
852
     */
853
1.37M
    if (match_props & LookupFlag::UseMarkFilteringSet)
854
0
      return gdef_accel.mark_set_covers (match_props >> 16, info->codepoint);
855
856
    /* The second byte of match_props has the meaning
857
     * "ignore marks of attachment type different than
858
     * the attachment type specified."
859
     */
860
1.37M
    if (match_props & LookupFlag::MarkAttachmentType)
861
150
      return (match_props & LookupFlag::MarkAttachmentType) == (glyph_props & LookupFlag::MarkAttachmentType);
862
863
1.37M
    return true;
864
1.37M
  }
865
866
#ifndef HB_OPTIMIZE_SIZE
867
  HB_ALWAYS_INLINE
868
#endif
869
  bool check_glyph_property (const hb_glyph_info_t *info,
870
           unsigned match_props) const
871
177M
  {
872
177M
    unsigned int glyph_props = _hb_glyph_info_get_glyph_props (info);
873
874
    /* Not covered, if, for example, glyph class is ligature and
875
     * match_props includes LookupFlags::IgnoreLigatures
876
     */
877
177M
    if (glyph_props & match_props & LookupFlag::IgnoreFlags)
878
124k
      return false;
879
880
177M
    if (glyph_props & HB_OT_LAYOUT_GLYPH_PROPS_MARK)
881
1.37M
      return match_properties_mark (info, glyph_props, match_props);
882
883
176M
    return true;
884
177M
  }
885
886
  void _set_glyph_class (hb_codepoint_t glyph_index,
887
        unsigned int class_guess = 0,
888
        bool ligature = false,
889
        bool component = false)
890
29.1k
  {
891
29.1k
    buffer->digest.add (glyph_index);
892
893
29.1k
    if (new_syllables != (unsigned) -1)
894
0
      buffer->cur().syllable() = new_syllables;
895
896
29.1k
    unsigned int props = _hb_glyph_info_get_glyph_props (&buffer->cur());
897
29.1k
    props |= HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED;
898
29.1k
    if (ligature)
899
29.1k
    {
900
29.1k
      props |= HB_OT_LAYOUT_GLYPH_PROPS_LIGATED;
901
      /* In the only place that the MULTIPLIED bit is used, Uniscribe
902
       * seems to only care about the "last" transformation between
903
       * Ligature and Multiple substitutions.  Ie. if you ligate, expand,
904
       * and ligate again, it forgives the multiplication and acts as
905
       * if only ligation happened.  As such, clear MULTIPLIED bit.
906
       */
907
29.1k
      props &= ~HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED;
908
29.1k
    }
909
29.1k
    if (component)
910
0
      props |= HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED;
911
29.1k
    if (likely (has_glyph_classes))
912
29.1k
    {
913
29.1k
      _set_glyph_class_props (buffer->cur(), props, glyph_index);
914
29.1k
    }
915
0
    else if (class_guess)
916
0
    {
917
0
      props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE;
918
0
      _hb_glyph_info_set_glyph_props (&buffer->cur(), props | class_guess);
919
0
    }
920
0
    else
921
0
      _hb_glyph_info_set_glyph_props (&buffer->cur(), props);
922
29.1k
  }
923
  void _set_glyph_class_props (hb_glyph_info_t &info,
924
             unsigned int props,
925
             hb_codepoint_t glyph_index)
926
29.1k
  {
927
29.1k
    props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE;
928
29.1k
    _hb_glyph_info_set_glyph_props (&info, props | gdef_accel.get_glyph_props (glyph_index));
929
29.1k
  }
930
  void _set_glyph_class_props (hb_glyph_info_t &info)
931
0
  {
932
0
    _set_glyph_class_props (info,
933
0
          _hb_glyph_info_get_glyph_props (&info),
934
0
          info.codepoint);
935
0
  }
936
937
  void replace_glyph (hb_codepoint_t glyph_index)
938
0
  {
939
0
    _set_glyph_class (glyph_index);
940
0
    (void) buffer->replace_glyph (glyph_index);
941
0
  }
942
  void replace_glyph_inplace (hb_codepoint_t glyph_index)
943
0
  {
944
0
    _set_glyph_class (glyph_index);
945
0
    buffer->cur().codepoint = glyph_index;
946
0
  }
947
  void replace_glyph_with_ligature (hb_codepoint_t glyph_index,
948
            unsigned int class_guess)
949
29.1k
  {
950
29.1k
    _set_glyph_class (glyph_index, class_guess, true);
951
29.1k
    (void) buffer->replace_glyph (glyph_index);
952
29.1k
  }
953
  void output_glyph_for_component (hb_codepoint_t glyph_index,
954
           unsigned int class_guess)
955
0
  {
956
0
    _set_glyph_class (glyph_index, class_guess, false, true);
957
0
    (void) buffer->output_glyph (glyph_index);
958
0
  }
959
};
960
961
enum class hb_ot_subtable_cache_op_t
962
{
963
  ENTER,
964
  LEAVE,
965
};
966
967
struct hb_accelerate_subtables_context_t :
968
       hb_dispatch_context_t<hb_accelerate_subtables_context_t>
969
{
970
  template <typename T>
971
  static inline auto apply_ (const T *obj, hb_ot_apply_context_t *c, void *external_cache, hb_priority<1>) HB_RETURN (bool, obj->apply (c, external_cache) )
972
  template <typename T>
973
  static inline auto apply_ (const T *obj, hb_ot_apply_context_t *c, void *external_cache, hb_priority<0>) HB_RETURN (bool, obj->apply (c) )
974
  template <typename T>
975
  static inline bool apply_to (const void *obj, hb_ot_apply_context_t *c, void *external_cache)
976
158M
  {
977
158M
    const T *typed_obj = (const T *) obj;
978
158M
    return apply_ (typed_obj, c, external_cache, hb_prioritize);
979
158M
  }
bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::SinglePosFormat1>(void const*, OT::hb_ot_apply_context_t*, void*)
Line
Count
Source
976
912
  {
977
912
    const T *typed_obj = (const T *) obj;
978
912
    return apply_ (typed_obj, c, external_cache, hb_prioritize);
979
912
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::SinglePosFormat2>(void const*, OT::hb_ot_apply_context_t*, void*)
bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Line
Count
Source
976
155M
  {
977
155M
    const T *typed_obj = (const T *) obj;
978
155M
    return apply_ (typed_obj, c, external_cache, hb_prioritize);
979
155M
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::CursivePosFormat1>(void const*, OT::hb_ot_apply_context_t*, void*)
bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Line
Count
Source
976
499k
  {
977
499k
    const T *typed_obj = (const T *) obj;
978
499k
    return apply_ (typed_obj, c, external_cache, hb_prioritize);
979
499k
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Line
Count
Source
976
246k
  {
977
246k
    const T *typed_obj = (const T *) obj;
978
246k
    return apply_ (typed_obj, c, external_cache, hb_prioritize);
979
246k
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ContextFormat3>(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
bool OT::hb_accelerate_subtables_context_t::apply_to<OT::ChainContextFormat3>(void const*, OT::hb_ot_apply_context_t*, void*)
Line
Count
Source
976
2.01M
  {
977
2.01M
    const T *typed_obj = (const T *) obj;
978
2.01M
    return apply_ (typed_obj, c, external_cache, hb_prioritize);
979
2.01M
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Line
Count
Source
976
411k
  {
977
411k
    const T *typed_obj = (const T *) obj;
978
411k
    return apply_ (typed_obj, c, external_cache, hb_prioritize);
979
411k
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_to<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(void const*, OT::hb_ot_apply_context_t*, void*)
980
981
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
982
  template <typename T>
983
  static inline auto apply_cached_ (const T *obj, hb_ot_apply_context_t *c, void *external_cache, hb_priority<2>) HB_RETURN (bool, obj->apply_cached (c, external_cache) )
984
  template <typename T>
985
  static inline auto apply_cached_ (const T *obj, hb_ot_apply_context_t *c, void *external_cache, hb_priority<1>) HB_RETURN (bool, obj->apply (c, external_cache) )
986
  template <typename T>
987
  static inline auto apply_cached_ (const T *obj, hb_ot_apply_context_t *c, void *external_cache, hb_priority<0>) HB_RETURN (bool, obj->apply (c) )
988
  template <typename T>
989
  static inline bool apply_cached_to (const void *obj, hb_ot_apply_context_t *c, void *external_cache)
990
0
  {
991
0
    const T *typed_obj = (const T *) obj;
992
0
    return apply_cached_ (typed_obj, c, external_cache, hb_prioritize);
993
0
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::SinglePosFormat1>(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::SinglePosFormat2>(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::CursivePosFormat1>(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ContextFormat3>(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::ChainContextFormat3>(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(void const*, OT::hb_ot_apply_context_t*, void*)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::apply_cached_to<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(void const*, OT::hb_ot_apply_context_t*, void*)
994
995
  template <typename T>
996
  static inline auto cache_func_ (hb_ot_apply_context_t *c,
997
          hb_ot_subtable_cache_op_t op,
998
          hb_priority<1>) HB_RETURN (bool, T::cache_func (c, op) )
999
  template <typename T=void>
1000
  static inline bool cache_func_ (hb_ot_apply_context_t *c,
1001
          hb_ot_subtable_cache_op_t op HB_UNUSED,
1002
0
          hb_priority<0>) { return false; }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::ContextFormat3>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::ChainContextFormat3>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t, hb_priority<0u>)
1003
  template <typename Type>
1004
  static inline bool cache_func_to (hb_ot_apply_context_t *c,
1005
            hb_ot_subtable_cache_op_t op)
1006
0
  {
1007
0
    return cache_func_<Type> (c, op, hb_prioritize);
1008
0
  }
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ContextFormat3>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::ChainContextFormat3>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: bool OT::hb_accelerate_subtables_context_t::cache_func_to<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
1009
#endif
1010
1011
  typedef bool (*hb_apply_func_t) (const void *obj, hb_ot_apply_context_t *c, void *external_cache);
1012
  typedef bool (*hb_cache_func_t) (hb_ot_apply_context_t *c, hb_ot_subtable_cache_op_t op);
1013
1014
  struct hb_applicable_t
1015
  {
1016
    friend struct hb_accelerate_subtables_context_t;
1017
    friend struct hb_ot_layout_lookup_accelerator_t;
1018
1019
    template <typename T>
1020
    void init (const T &obj_,
1021
         hb_apply_func_t apply_func_
1022
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1023
         , hb_apply_func_t apply_cached_func_
1024
         , hb_cache_func_t cache_func_
1025
         , void *external_cache_
1026
#endif
1027
    )
1028
1.67k
    {
1029
1.67k
      obj = &obj_;
1030
1.67k
      apply_func = apply_func_;
1031
1.67k
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1032
1.67k
      apply_cached_func = apply_cached_func_;
1033
1.67k
      cache_func = cache_func_;
1034
1.67k
      external_cache = external_cache_;
1035
1.67k
#endif
1036
1.67k
      digest.init ();
1037
1.67k
      obj_.get_coverage ().collect_coverage (&digest);
1038
1.67k
    }
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Line
Count
Source
1028
4
    {
1029
4
      obj = &obj_;
1030
4
      apply_func = apply_func_;
1031
4
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1032
4
      apply_cached_func = apply_cached_func_;
1033
4
      cache_func = cache_func_;
1034
4
      external_cache = external_cache_;
1035
4
#endif
1036
4
      digest.init ();
1037
4
      obj_.get_coverage ().collect_coverage (&digest);
1038
4
    }
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Line
Count
Source
1028
52
    {
1029
52
      obj = &obj_;
1030
52
      apply_func = apply_func_;
1031
52
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1032
52
      apply_cached_func = apply_cached_func_;
1033
52
      cache_func = cache_func_;
1034
52
      external_cache = external_cache_;
1035
52
#endif
1036
52
      digest.init ();
1037
52
      obj_.get_coverage ().collect_coverage (&digest);
1038
52
    }
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Line
Count
Source
1028
554
    {
1029
554
      obj = &obj_;
1030
554
      apply_func = apply_func_;
1031
554
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1032
554
      apply_cached_func = apply_cached_func_;
1033
554
      cache_func = cache_func_;
1034
554
      external_cache = external_cache_;
1035
554
#endif
1036
554
      digest.init ();
1037
554
      obj_.get_coverage ().collect_coverage (&digest);
1038
554
    }
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Line
Count
Source
1028
92
    {
1029
92
      obj = &obj_;
1030
92
      apply_func = apply_func_;
1031
92
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1032
92
      apply_cached_func = apply_cached_func_;
1033
92
      cache_func = cache_func_;
1034
92
      external_cache = external_cache_;
1035
92
#endif
1036
92
      digest.init ();
1037
92
      obj_.get_coverage ().collect_coverage (&digest);
1038
92
    }
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ContextFormat3>(OT::ContextFormat3 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Line
Count
Source
1028
902
    {
1029
902
      obj = &obj_;
1030
902
      apply_func = apply_func_;
1031
902
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1032
902
      apply_cached_func = apply_cached_func_;
1033
902
      cache_func = cache_func_;
1034
902
      external_cache = external_cache_;
1035
902
#endif
1036
902
      digest.init ();
1037
902
      obj_.get_coverage ().collect_coverage (&digest);
1038
902
    }
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
Line
Count
Source
1028
75
    {
1029
75
      obj = &obj_;
1030
75
      apply_func = apply_func_;
1031
75
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1032
75
      apply_cached_func = apply_cached_func_;
1033
75
      cache_func = cache_func_;
1034
75
      external_cache = external_cache_;
1035
75
#endif
1036
75
      digest.init ();
1037
75
      obj_.get_coverage ().collect_coverage (&digest);
1038
75
    }
Unexecuted instantiation: void OT::hb_accelerate_subtables_context_t::hb_applicable_t::init<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&, bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(void const*, OT::hb_ot_apply_context_t*, void*), bool (*)(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t), void*)
1039
1040
#ifdef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1041
    bool apply (hb_ot_apply_context_t *c) const
1042
    {
1043
      return digest.may_have (c->buffer->cur().codepoint) && apply_func (obj, c, nullptr);
1044
    }
1045
#else
1046
    bool apply (hb_ot_apply_context_t *c) const
1047
158M
    {
1048
158M
      return digest.may_have (c->buffer->cur().codepoint) && apply_func (obj, c, external_cache);
1049
158M
    }
1050
    bool apply_cached (hb_ot_apply_context_t *c) const
1051
0
    {
1052
0
      return digest.may_have (c->buffer->cur().codepoint) &&  apply_cached_func (obj, c, external_cache);
1053
0
    }
1054
1055
    bool cache_enter (hb_ot_apply_context_t *c) const
1056
0
    {
1057
0
      return cache_func (c, hb_ot_subtable_cache_op_t::ENTER);
1058
0
    }
1059
    void cache_leave (hb_ot_apply_context_t *c) const
1060
0
    {
1061
0
      cache_func (c, hb_ot_subtable_cache_op_t::LEAVE);
1062
0
    }
1063
#endif
1064
1065
    private:
1066
    const void *obj;
1067
    hb_apply_func_t apply_func;
1068
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1069
    hb_apply_func_t apply_cached_func;
1070
    hb_cache_func_t cache_func;
1071
    void *external_cache;
1072
#endif
1073
    hb_set_digest_t digest;
1074
  };
1075
1076
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1077
  template <typename T>
1078
  auto cache_cost (const T &obj, hb_priority<1>) HB_AUTO_RETURN ( obj.cache_cost () )
1079
  template <typename T>
1080
  auto cache_cost (const T &obj, hb_priority<0>) HB_AUTO_RETURN ( 0u )
1081
1082
  template <typename T>
1083
  auto external_cache_create (const T &obj, hb_priority<1>) HB_AUTO_RETURN ( obj.external_cache_create () )
1084
  template <typename T>
1085
  auto external_cache_create (const T &obj, hb_priority<0>) HB_AUTO_RETURN ( nullptr )
1086
#endif
1087
1088
  /* Dispatch interface. */
1089
  template <typename T>
1090
  return_t dispatch (const T &obj)
1091
1.67k
  {
1092
1.67k
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1093
1.67k
    void *external_cache = nullptr;
1094
1.67k
    if (i < 8)
1095
1.56k
      external_cache = external_cache_create (obj, hb_prioritize);
1096
1.67k
#endif
1097
1098
1.67k
    hb_applicable_t *entry = &array[i++];
1099
1100
1.67k
    entry->init (obj,
1101
1.67k
     apply_to<T>
1102
1.67k
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1103
1.67k
     , apply_cached_to<T>
1104
1.67k
     , cache_func_to<T>
1105
1.67k
     , external_cache
1106
1.67k
#endif
1107
1.67k
     );
1108
1109
1.67k
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1110
    /* Cache handling
1111
     *
1112
     * We allow one subtable from each lookup to use a cache. The assumption
1113
     * being that multiple subtables of the same lookup cannot use a cache
1114
     * because the resources they would use will collide.  As such, we ask
1115
     * each subtable to tell us how much it costs (which a cache would avoid),
1116
     * and we allocate the cache opportunity to the costliest subtable.
1117
     */
1118
1.67k
    unsigned cost = cache_cost (obj, hb_prioritize);
1119
1.67k
    if (cost > subtable_cache_user_cost)
1120
0
    {
1121
0
      subtable_cache_user_idx = i - 1;
1122
0
      subtable_cache_user_cost = cost;
1123
0
    }
1124
1.67k
#endif
1125
1126
1.67k
    return hb_empty_t ();
1127
1.67k
  }
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&)
Line
Count
Source
1091
4
  {
1092
4
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1093
4
    void *external_cache = nullptr;
1094
4
    if (i < 8)
1095
4
      external_cache = external_cache_create (obj, hb_prioritize);
1096
4
#endif
1097
1098
4
    hb_applicable_t *entry = &array[i++];
1099
1100
4
    entry->init (obj,
1101
4
     apply_to<T>
1102
4
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1103
4
     , apply_cached_to<T>
1104
4
     , cache_func_to<T>
1105
4
     , external_cache
1106
4
#endif
1107
4
     );
1108
1109
4
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1110
    /* Cache handling
1111
     *
1112
     * We allow one subtable from each lookup to use a cache. The assumption
1113
     * being that multiple subtables of the same lookup cannot use a cache
1114
     * because the resources they would use will collide.  As such, we ask
1115
     * each subtable to tell us how much it costs (which a cache would avoid),
1116
     * and we allocate the cache opportunity to the costliest subtable.
1117
     */
1118
4
    unsigned cost = cache_cost (obj, hb_prioritize);
1119
4
    if (cost > subtable_cache_user_cost)
1120
0
    {
1121
0
      subtable_cache_user_idx = i - 1;
1122
0
      subtable_cache_user_cost = cost;
1123
0
    }
1124
4
#endif
1125
1126
4
    return hb_empty_t ();
1127
4
  }
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&)
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat1_3<OT::Layout::SmallTypes> const&)
Line
Count
Source
1091
52
  {
1092
52
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1093
52
    void *external_cache = nullptr;
1094
52
    if (i < 8)
1095
52
      external_cache = external_cache_create (obj, hb_prioritize);
1096
52
#endif
1097
1098
52
    hb_applicable_t *entry = &array[i++];
1099
1100
52
    entry->init (obj,
1101
52
     apply_to<T>
1102
52
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1103
52
     , apply_cached_to<T>
1104
52
     , cache_func_to<T>
1105
52
     , external_cache
1106
52
#endif
1107
52
     );
1108
1109
52
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1110
    /* Cache handling
1111
     *
1112
     * We allow one subtable from each lookup to use a cache. The assumption
1113
     * being that multiple subtables of the same lookup cannot use a cache
1114
     * because the resources they would use will collide.  As such, we ask
1115
     * each subtable to tell us how much it costs (which a cache would avoid),
1116
     * and we allocate the cache opportunity to the costliest subtable.
1117
     */
1118
52
    unsigned cost = cache_cost (obj, hb_prioritize);
1119
52
    if (cost > subtable_cache_user_cost)
1120
0
    {
1121
0
      subtable_cache_user_idx = i - 1;
1122
0
      subtable_cache_user_cost = cost;
1123
0
    }
1124
52
#endif
1125
1126
52
    return hb_empty_t ();
1127
52
  }
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::PairPosFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&)
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkBasePosFormat1_2<OT::Layout::SmallTypes> const&)
Line
Count
Source
1091
554
  {
1092
554
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1093
554
    void *external_cache = nullptr;
1094
554
    if (i < 8)
1095
554
      external_cache = external_cache_create (obj, hb_prioritize);
1096
554
#endif
1097
1098
554
    hb_applicable_t *entry = &array[i++];
1099
1100
554
    entry->init (obj,
1101
554
     apply_to<T>
1102
554
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1103
554
     , apply_cached_to<T>
1104
554
     , cache_func_to<T>
1105
554
     , external_cache
1106
554
#endif
1107
554
     );
1108
1109
554
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1110
    /* Cache handling
1111
     *
1112
     * We allow one subtable from each lookup to use a cache. The assumption
1113
     * being that multiple subtables of the same lookup cannot use a cache
1114
     * because the resources they would use will collide.  As such, we ask
1115
     * each subtable to tell us how much it costs (which a cache would avoid),
1116
     * and we allocate the cache opportunity to the costliest subtable.
1117
     */
1118
554
    unsigned cost = cache_cost (obj, hb_prioritize);
1119
554
    if (cost > subtable_cache_user_cost)
1120
0
    {
1121
0
      subtable_cache_user_idx = i - 1;
1122
0
      subtable_cache_user_cost = cost;
1123
0
    }
1124
554
#endif
1125
1126
554
    return hb_empty_t ();
1127
554
  }
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkLigPosFormat1_2<OT::Layout::SmallTypes> const&)
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GPOS_impl::MarkMarkPosFormat1_2<OT::Layout::SmallTypes> const&)
Line
Count
Source
1091
92
  {
1092
92
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1093
92
    void *external_cache = nullptr;
1094
92
    if (i < 8)
1095
92
      external_cache = external_cache_create (obj, hb_prioritize);
1096
92
#endif
1097
1098
92
    hb_applicable_t *entry = &array[i++];
1099
1100
92
    entry->init (obj,
1101
92
     apply_to<T>
1102
92
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1103
92
     , apply_cached_to<T>
1104
92
     , cache_func_to<T>
1105
92
     , external_cache
1106
92
#endif
1107
92
     );
1108
1109
92
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1110
    /* Cache handling
1111
     *
1112
     * We allow one subtable from each lookup to use a cache. The assumption
1113
     * being that multiple subtables of the same lookup cannot use a cache
1114
     * because the resources they would use will collide.  As such, we ask
1115
     * each subtable to tell us how much it costs (which a cache would avoid),
1116
     * and we allocate the cache opportunity to the costliest subtable.
1117
     */
1118
92
    unsigned cost = cache_cost (obj, hb_prioritize);
1119
92
    if (cost > subtable_cache_user_cost)
1120
0
    {
1121
0
      subtable_cache_user_idx = i - 1;
1122
0
      subtable_cache_user_cost = cost;
1123
0
    }
1124
92
#endif
1125
1126
92
    return hb_empty_t ();
1127
92
  }
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
Line
Count
Source
1091
902
  {
1092
902
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1093
902
    void *external_cache = nullptr;
1094
902
    if (i < 8)
1095
792
      external_cache = external_cache_create (obj, hb_prioritize);
1096
902
#endif
1097
1098
902
    hb_applicable_t *entry = &array[i++];
1099
1100
902
    entry->init (obj,
1101
902
     apply_to<T>
1102
902
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1103
902
     , apply_cached_to<T>
1104
902
     , cache_func_to<T>
1105
902
     , external_cache
1106
902
#endif
1107
902
     );
1108
1109
902
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1110
    /* Cache handling
1111
     *
1112
     * We allow one subtable from each lookup to use a cache. The assumption
1113
     * being that multiple subtables of the same lookup cannot use a cache
1114
     * because the resources they would use will collide.  As such, we ask
1115
     * each subtable to tell us how much it costs (which a cache would avoid),
1116
     * and we allocate the cache opportunity to the costliest subtable.
1117
     */
1118
902
    unsigned cost = cache_cost (obj, hb_prioritize);
1119
902
    if (cost > subtable_cache_user_cost)
1120
0
    {
1121
0
      subtable_cache_user_idx = i - 1;
1122
0
      subtable_cache_user_cost = cost;
1123
0
    }
1124
902
#endif
1125
1126
902
    return hb_empty_t ();
1127
902
  }
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat1_3<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::SingleSubstFormat2_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::MultipleSubstFormat1_2<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::AlternateSubstFormat1_2<OT::Layout::SmallTypes> const&)
hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> >(OT::Layout::GSUB_impl::LigatureSubstFormat1_2<OT::Layout::SmallTypes> const&)
Line
Count
Source
1091
75
  {
1092
75
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1093
75
    void *external_cache = nullptr;
1094
75
    if (i < 8)
1095
75
      external_cache = external_cache_create (obj, hb_prioritize);
1096
75
#endif
1097
1098
75
    hb_applicable_t *entry = &array[i++];
1099
1100
75
    entry->init (obj,
1101
75
     apply_to<T>
1102
75
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1103
75
     , apply_cached_to<T>
1104
75
     , cache_func_to<T>
1105
75
     , external_cache
1106
75
#endif
1107
75
     );
1108
1109
75
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1110
    /* Cache handling
1111
     *
1112
     * We allow one subtable from each lookup to use a cache. The assumption
1113
     * being that multiple subtables of the same lookup cannot use a cache
1114
     * because the resources they would use will collide.  As such, we ask
1115
     * each subtable to tell us how much it costs (which a cache would avoid),
1116
     * and we allocate the cache opportunity to the costliest subtable.
1117
     */
1118
75
    unsigned cost = cache_cost (obj, hb_prioritize);
1119
75
    if (cost > subtable_cache_user_cost)
1120
0
    {
1121
0
      subtable_cache_user_idx = i - 1;
1122
0
      subtable_cache_user_cost = cost;
1123
0
    }
1124
75
#endif
1125
1126
75
    return hb_empty_t ();
1127
75
  }
Unexecuted instantiation: hb_empty_t OT::hb_accelerate_subtables_context_t::dispatch<OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1>(OT::Layout::GSUB_impl::ReverseChainSingleSubstFormat1 const&)
1128
975
  static return_t default_return_value () { return hb_empty_t (); }
1129
1130
  hb_accelerate_subtables_context_t (hb_applicable_t *array_) :
1131
975
             array (array_) {}
1132
1133
  hb_applicable_t *array;
1134
  unsigned i = 0;
1135
1136
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
1137
  unsigned subtable_cache_user_idx = (unsigned) -1;
1138
  unsigned subtable_cache_user_cost = 0;
1139
#endif
1140
};
1141
1142
1143
typedef bool (*intersects_func_t) (const hb_set_t *glyphs, unsigned value, const void *data, void *cache);
1144
typedef void (*intersected_glyphs_func_t) (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, void *cache);
1145
typedef void (*collect_glyphs_func_t) (hb_set_t *glyphs, unsigned value, const void *data);
1146
typedef bool (*match_func_t) (hb_glyph_info_t &info, unsigned value, const void *data);
1147
1148
struct ContextClosureFuncs
1149
{
1150
  intersects_func_t intersects;
1151
  intersected_glyphs_func_t intersected_glyphs;
1152
};
1153
struct ContextCollectGlyphsFuncs
1154
{
1155
  collect_glyphs_func_t collect;
1156
};
1157
struct ContextApplyFuncs
1158
{
1159
  match_func_t match;
1160
};
1161
struct ChainContextApplyFuncs
1162
{
1163
  match_func_t match[3];
1164
};
1165
1166
1167
static inline bool intersects_glyph (const hb_set_t *glyphs, unsigned value, const void *data HB_UNUSED, void *cache HB_UNUSED)
1168
0
{
1169
0
  return glyphs->has (value);
1170
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-face.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-layout.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: gsubgpos-context.cc:OT::intersects_glyph(hb_set_t const*, unsigned int, void const*, void*)
1171
static inline bool intersects_class (const hb_set_t *glyphs, unsigned value, const void *data, void *cache)
1172
0
{
1173
0
  const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
1174
0
  hb_map_t *map = (hb_map_t *) cache;
1175
1176
0
  hb_codepoint_t *cached_v;
1177
0
  if (map->has (value, &cached_v))
1178
0
    return *cached_v;
1179
1180
0
  bool v = class_def.intersects_class (glyphs, value);
1181
0
  map->set (value, v);
1182
1183
0
  return v;
1184
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-face.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-layout.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: gsubgpos-context.cc:OT::intersects_class(hb_set_t const*, unsigned int, void const*, void*)
1185
static inline bool intersects_coverage (const hb_set_t *glyphs, unsigned value, const void *data, void *cache HB_UNUSED)
1186
0
{
1187
0
  Offset16To<Coverage> coverage;
1188
0
  coverage = value;
1189
0
  return (data+coverage).intersects (glyphs);
1190
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-face.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-layout.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
Unexecuted instantiation: gsubgpos-context.cc:OT::intersects_coverage(hb_set_t const*, unsigned int, void const*, void*)
1191
1192
1193
static inline void intersected_glyph (const hb_set_t *glyphs HB_UNUSED, const void *data, unsigned value, hb_set_t *intersected_glyphs, HB_UNUSED void *cache)
1194
0
{
1195
0
  unsigned g = reinterpret_cast<const HBUINT16 *>(data)[value];
1196
0
  intersected_glyphs->add (g);
1197
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-face.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-layout.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: gsubgpos-context.cc:OT::intersected_glyph(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
1198
1199
using intersected_class_cache_t = hb_hashmap_t<unsigned, hb_set_t>;
1200
1201
static inline void intersected_class_glyphs (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, void *cache)
1202
0
{
1203
0
  const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
1204
1205
0
  intersected_class_cache_t *map = (intersected_class_cache_t *) cache;
1206
1207
0
  hb_set_t *cached_v;
1208
0
  if (map->has (value, &cached_v))
1209
0
  {
1210
0
    intersected_glyphs->union_ (*cached_v);
1211
0
    return;
1212
0
  }
1213
1214
0
  hb_set_t v;
1215
0
  class_def.intersected_class_glyphs (glyphs, value, &v);
1216
1217
0
  intersected_glyphs->union_ (v);
1218
1219
0
  map->set (value, std::move (v));
1220
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-face.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-layout.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: gsubgpos-context.cc:OT::intersected_class_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
1221
1222
static inline void intersected_coverage_glyphs (const hb_set_t *glyphs, const void *data, unsigned value, hb_set_t *intersected_glyphs, HB_UNUSED void *cache)
1223
0
{
1224
0
  Offset16To<Coverage> coverage;
1225
0
  coverage = value;
1226
0
  (data+coverage).intersect_set (*glyphs, *intersected_glyphs);
1227
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-face.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-layout.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
Unexecuted instantiation: gsubgpos-context.cc:OT::intersected_coverage_glyphs(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*)
1228
1229
1230
template <typename HBUINT>
1231
static inline bool array_is_subset_of (const hb_set_t *glyphs,
1232
               unsigned int count,
1233
               const HBUINT values[],
1234
               intersects_func_t intersects_func,
1235
               const void *intersects_data,
1236
               void *cache)
1237
0
{
1238
0
  for (const auto &_ : + hb_iter (values, count))
1239
0
    if (!intersects_func (glyphs, _, intersects_data, cache)) return false;
1240
0
  return true;
1241
0
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-ot-face.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-subset.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::array_is_subset_of<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_set_t const*, unsigned int, void const*, void*), void const*, void*)
1242
1243
1244
static inline void collect_glyph (hb_set_t *glyphs, unsigned value, const void *data HB_UNUSED)
1245
0
{
1246
0
  glyphs->add (value);
1247
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::collect_glyph(hb_set_t*, unsigned int, void const*)
1248
static inline void collect_class (hb_set_t *glyphs, unsigned value, const void *data)
1249
0
{
1250
0
  const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
1251
0
  class_def.collect_class (glyphs, value);
1252
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::collect_class(hb_set_t*, unsigned int, void const*)
1253
static inline void collect_coverage (hb_set_t *glyphs, unsigned value, const void *data)
1254
0
{
1255
0
  Offset16To<Coverage> coverage;
1256
0
  coverage = value;
1257
0
  (data+coverage).collect_coverage (glyphs);
1258
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::collect_coverage(hb_set_t*, unsigned int, void const*)
1259
template <typename HBUINT>
1260
static inline void collect_array (hb_collect_glyphs_context_t *c HB_UNUSED,
1261
          hb_set_t *glyphs,
1262
          unsigned int count,
1263
          const HBUINT values[],
1264
          collect_glyphs_func_t collect_func,
1265
          const void *collect_data)
1266
0
{
1267
0
  return
1268
0
  + hb_iter (values, count)
1269
0
  | hb_apply ([&] (const HBUINT &_) { collect_func (glyphs, _, collect_data); })
1270
0
  ;
1271
0
}
Unexecuted instantiation: hb-aat-layout.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-face.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-layout.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
Unexecuted instantiation: gsubgpos-context.cc:void OT::collect_array<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, hb_set_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, void (*)(hb_set_t*, unsigned int, void const*), void const*)
1272
1273
1274
static inline bool match_always (hb_glyph_info_t &info HB_UNUSED, unsigned value HB_UNUSED, const void *data HB_UNUSED)
1275
32.8k
{
1276
32.8k
  return true;
1277
32.8k
}
Unexecuted instantiation: hb-aat-layout.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
hb-ot-layout.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Line
Count
Source
1275
32.8k
{
1276
32.8k
  return true;
1277
32.8k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::match_always(hb_glyph_info_t&, unsigned int, void const*)
1278
static inline bool match_glyph (hb_glyph_info_t &info, unsigned value, const void *data HB_UNUSED)
1279
210k
{
1280
210k
  return info.codepoint == value;
1281
210k
}
Unexecuted instantiation: hb-aat-layout.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
hb-ot-layout.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Line
Count
Source
1279
210k
{
1280
210k
  return info.codepoint == value;
1281
210k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::match_glyph(hb_glyph_info_t&, unsigned int, void const*)
1282
static inline bool match_class (hb_glyph_info_t &info, unsigned value, const void *data)
1283
0
{
1284
0
  const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
1285
0
  return class_def.get_class (info.codepoint) == value;
1286
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::match_class(hb_glyph_info_t&, unsigned int, void const*)
1287
static inline unsigned get_class_cached (const ClassDef &class_def, hb_glyph_info_t &info)
1288
0
{
1289
0
  unsigned klass = info.syllable();
1290
0
  if (klass < 255)
1291
0
    return klass;
1292
0
  klass = class_def.get_class (info.codepoint);
1293
0
  if (likely (klass < 255))
1294
0
    info.syllable() = klass;
1295
0
  return klass;
1296
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-face.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-layout.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-var.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-color.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-other.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: gsubgpos-context.cc:OT::get_class_cached(OT::ClassDef const&, hb_glyph_info_t&)
1297
static inline bool match_class_cached (hb_glyph_info_t &info, unsigned value, const void *data)
1298
0
{
1299
0
  const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
1300
0
  return get_class_cached (class_def, info) == value;
1301
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::match_class_cached(hb_glyph_info_t&, unsigned int, void const*)
1302
static inline unsigned get_class_cached1 (const ClassDef &class_def, hb_glyph_info_t &info)
1303
0
{
1304
0
  unsigned klass = info.syllable() & 0x0F;
1305
0
  if (klass < 15)
1306
0
    return klass;
1307
0
  klass = class_def.get_class (info.codepoint);
1308
0
  if (likely (klass < 15))
1309
0
    info.syllable() = (info.syllable() & 0xF0) | klass;
1310
0
  return klass;
1311
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-face.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-layout.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-var.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-color.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-other.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: gsubgpos-context.cc:OT::get_class_cached1(OT::ClassDef const&, hb_glyph_info_t&)
1312
static inline bool match_class_cached1 (hb_glyph_info_t &info, unsigned value, const void *data)
1313
0
{
1314
0
  const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
1315
0
  return get_class_cached1 (class_def, info) == value;
1316
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::match_class_cached1(hb_glyph_info_t&, unsigned int, void const*)
1317
static inline unsigned get_class_cached2 (const ClassDef &class_def, hb_glyph_info_t &info)
1318
0
{
1319
0
  unsigned klass = (info.syllable() & 0xF0) >> 4;
1320
0
  if (klass < 15)
1321
0
    return klass;
1322
0
  klass = class_def.get_class (info.codepoint);
1323
0
  if (likely (klass < 15))
1324
0
    info.syllable() = (info.syllable() & 0x0F) | (klass << 4);
1325
0
  return klass;
1326
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-face.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-layout.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-var.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-color.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: hb-subset-table-other.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
Unexecuted instantiation: gsubgpos-context.cc:OT::get_class_cached2(OT::ClassDef const&, hb_glyph_info_t&)
1327
static inline bool match_class_cached2 (hb_glyph_info_t &info, unsigned value, const void *data)
1328
0
{
1329
0
  const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
1330
0
  return get_class_cached2 (class_def, info) == value;
1331
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::match_class_cached2(hb_glyph_info_t&, unsigned int, void const*)
1332
static inline bool match_coverage (hb_glyph_info_t &info, unsigned value, const void *data)
1333
1.07M
{
1334
1.07M
  Offset16To<Coverage> coverage;
1335
1.07M
  coverage = value;
1336
1.07M
  return (data+coverage).get_coverage (info.codepoint) != NOT_COVERED;
1337
1.07M
}
Unexecuted instantiation: hb-aat-layout.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-face.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
hb-ot-layout.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Line
Count
Source
1333
1.07M
{
1334
1.07M
  Offset16To<Coverage> coverage;
1335
1.07M
  coverage = value;
1336
1.07M
  return (data+coverage).get_coverage (info.codepoint) != NOT_COVERED;
1337
1.07M
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::match_coverage(hb_glyph_info_t&, unsigned int, void const*)
1338
1339
template <typename HBUINT>
1340
static inline bool would_match_input (hb_would_apply_context_t *c,
1341
              unsigned int count, /* Including the first glyph (not matched) */
1342
              const HBUINT input[], /* Array of input values--start with second glyph */
1343
              match_func_t match_func,
1344
              const void *match_data)
1345
0
{
1346
0
  if (count != c->len)
1347
0
    return false;
1348
1349
0
  for (unsigned int i = 1; i < count; i++)
1350
0
  {
1351
0
    hb_glyph_info_t info;
1352
0
    info.codepoint = c->glyphs[i];
1353
0
    if (likely (!match_func (info, input[i - 1], match_data)))
1354
0
      return false;
1355
0
  }
1356
1357
0
  return true;
1358
0
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-face.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::would_match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*)
1359
template <typename HBUINT>
1360
#ifndef HB_OPTIMIZE_SIZE
1361
HB_ALWAYS_INLINE
1362
#endif
1363
static bool match_input (hb_ot_apply_context_t *c,
1364
       unsigned int count, /* Including the first glyph (not matched) */
1365
       const HBUINT input[], /* Array of input values--start with second glyph */
1366
       match_func_t match_func,
1367
       const void *match_data,
1368
       unsigned int *end_position,
1369
       unsigned int *p_total_component_count = nullptr)
1370
2.07M
{
1371
2.07M
  TRACE_APPLY (nullptr);
1372
1373
2.07M
  hb_buffer_t *buffer = c->buffer;
1374
1375
2.07M
  if (count == 1)
1376
1.48M
  {
1377
1.48M
    *end_position = buffer->idx + 1;
1378
1.48M
    c->match_positions[0] = buffer->idx;
1379
1.48M
    if (p_total_component_count)
1380
0
      *p_total_component_count = _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1381
1.48M
    return_trace (true);
1382
1.48M
  }
1383
1384
586k
  if (unlikely (count > HB_MAX_CONTEXT_LENGTH)) return_trace (false);
1385
1386
586k
  auto &skippy_iter = c->iter_input;
1387
586k
  skippy_iter.reset (buffer->idx);
1388
586k
  skippy_iter.set_match_func (match_func, match_data);
1389
586k
  skippy_iter.set_glyph_data (input);
1390
1391
  /*
1392
   * This is perhaps the trickiest part of OpenType...  Remarks:
1393
   *
1394
   * - If all components of the ligature were marks, we call this a mark ligature.
1395
   *
1396
   * - If there is no GDEF, and the ligature is NOT a mark ligature, we categorize
1397
   *   it as a ligature glyph.
1398
   *
1399
   * - Ligatures cannot be formed across glyphs attached to different components
1400
   *   of previous ligatures.  Eg. the sequence is LAM,SHADDA,LAM,FATHA,HEH, and
1401
   *   LAM,LAM,HEH form a ligature, leaving SHADDA,FATHA next to eachother.
1402
   *   However, it would be wrong to ligate that SHADDA,FATHA sequence.
1403
   *   There are a couple of exceptions to this:
1404
   *
1405
   *   o If a ligature tries ligating with marks that belong to it itself, go ahead,
1406
   *     assuming that the font designer knows what they are doing (otherwise it can
1407
   *     break Indic stuff when a matra wants to ligate with a conjunct,
1408
   *
1409
   *   o If two marks want to ligate and they belong to different components of the
1410
   *     same ligature glyph, and said ligature glyph is to be ignored according to
1411
   *     mark-filtering rules, then allow.
1412
   *     https://github.com/harfbuzz/harfbuzz/issues/545
1413
   */
1414
1415
586k
  unsigned int total_component_count = 0;
1416
1417
586k
  unsigned int first_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur());
1418
586k
  unsigned int first_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
1419
1420
586k
  enum {
1421
586k
    LIGBASE_NOT_CHECKED,
1422
586k
    LIGBASE_MAY_NOT_SKIP,
1423
586k
    LIGBASE_MAY_SKIP
1424
586k
  } ligbase = LIGBASE_NOT_CHECKED;
1425
1426
649k
  for (unsigned int i = 1; i < count; i++)
1427
586k
  {
1428
586k
    unsigned unsafe_to;
1429
586k
    if (!skippy_iter.next (&unsafe_to))
1430
523k
    {
1431
523k
      *end_position = unsafe_to;
1432
523k
      return_trace (false);
1433
523k
    }
1434
1435
62.9k
    if (unlikely (i + 1 > c->match_positions.length &&
1436
62.9k
      !c->match_positions.resize_dirty  (i + 1)))
1437
0
      return_trace (false);
1438
62.9k
    c->match_positions.arrayZ[i] = skippy_iter.idx;
1439
1440
62.9k
    unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[skippy_iter.idx]);
1441
62.9k
    unsigned int this_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx]);
1442
1443
62.9k
    if (first_lig_id && first_lig_comp)
1444
0
    {
1445
      /* If first component was attached to a previous ligature component,
1446
       * all subsequent components should be attached to the same ligature
1447
       * component, otherwise we shouldn't ligate them... */
1448
0
      if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp)
1449
0
      {
1450
  /* ...unless, we are attached to a base ligature and that base
1451
   * ligature is ignorable. */
1452
0
  if (ligbase == LIGBASE_NOT_CHECKED)
1453
0
  {
1454
0
    bool found = false;
1455
0
    const auto *out = buffer->out_info;
1456
0
    unsigned int j = buffer->out_len;
1457
0
    while (j && _hb_glyph_info_get_lig_id (&out[j - 1]) == first_lig_id)
1458
0
    {
1459
0
      if (_hb_glyph_info_get_lig_comp (&out[j - 1]) == 0)
1460
0
      {
1461
0
        j--;
1462
0
        found = true;
1463
0
        break;
1464
0
      }
1465
0
      j--;
1466
0
    }
1467
1468
0
    if (found && skippy_iter.may_skip (out[j]) == matcher_t::SKIP_YES)
1469
0
      ligbase = LIGBASE_MAY_SKIP;
1470
0
    else
1471
0
      ligbase = LIGBASE_MAY_NOT_SKIP;
1472
0
  }
1473
1474
0
  if (ligbase == LIGBASE_MAY_NOT_SKIP)
1475
0
    return_trace (false);
1476
0
      }
1477
0
    }
1478
62.9k
    else
1479
62.9k
    {
1480
      /* If first component was NOT attached to a previous ligature component,
1481
       * all subsequent components should also NOT be attached to any ligature
1482
       * component, unless they are attached to the first component itself! */
1483
62.9k
      if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id))
1484
0
  return_trace (false);
1485
62.9k
    }
1486
1487
62.9k
    total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[skippy_iter.idx]);
1488
62.9k
  }
1489
1490
62.6k
  *end_position = skippy_iter.idx + 1;
1491
1492
62.6k
  if (p_total_component_count)
1493
29.1k
  {
1494
29.1k
    total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1495
29.1k
    *p_total_component_count = total_component_count;
1496
29.1k
  }
1497
1498
62.6k
  c->match_positions.arrayZ[0] = buffer->idx;
1499
1500
62.6k
  return_trace (true);
1501
586k
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-ot-face.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-ot-face.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
hb-ot-layout.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Line
Count
Source
1370
467k
{
1371
467k
  TRACE_APPLY (nullptr);
1372
1373
467k
  hb_buffer_t *buffer = c->buffer;
1374
1375
467k
  if (count == 1)
1376
0
  {
1377
0
    *end_position = buffer->idx + 1;
1378
0
    c->match_positions[0] = buffer->idx;
1379
0
    if (p_total_component_count)
1380
0
      *p_total_component_count = _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1381
0
    return_trace (true);
1382
0
  }
1383
1384
467k
  if (unlikely (count > HB_MAX_CONTEXT_LENGTH)) return_trace (false);
1385
1386
467k
  auto &skippy_iter = c->iter_input;
1387
467k
  skippy_iter.reset (buffer->idx);
1388
467k
  skippy_iter.set_match_func (match_func, match_data);
1389
467k
  skippy_iter.set_glyph_data (input);
1390
1391
  /*
1392
   * This is perhaps the trickiest part of OpenType...  Remarks:
1393
   *
1394
   * - If all components of the ligature were marks, we call this a mark ligature.
1395
   *
1396
   * - If there is no GDEF, and the ligature is NOT a mark ligature, we categorize
1397
   *   it as a ligature glyph.
1398
   *
1399
   * - Ligatures cannot be formed across glyphs attached to different components
1400
   *   of previous ligatures.  Eg. the sequence is LAM,SHADDA,LAM,FATHA,HEH, and
1401
   *   LAM,LAM,HEH form a ligature, leaving SHADDA,FATHA next to eachother.
1402
   *   However, it would be wrong to ligate that SHADDA,FATHA sequence.
1403
   *   There are a couple of exceptions to this:
1404
   *
1405
   *   o If a ligature tries ligating with marks that belong to it itself, go ahead,
1406
   *     assuming that the font designer knows what they are doing (otherwise it can
1407
   *     break Indic stuff when a matra wants to ligate with a conjunct,
1408
   *
1409
   *   o If two marks want to ligate and they belong to different components of the
1410
   *     same ligature glyph, and said ligature glyph is to be ignored according to
1411
   *     mark-filtering rules, then allow.
1412
   *     https://github.com/harfbuzz/harfbuzz/issues/545
1413
   */
1414
1415
467k
  unsigned int total_component_count = 0;
1416
1417
467k
  unsigned int first_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur());
1418
467k
  unsigned int first_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
1419
1420
467k
  enum {
1421
467k
    LIGBASE_NOT_CHECKED,
1422
467k
    LIGBASE_MAY_NOT_SKIP,
1423
467k
    LIGBASE_MAY_SKIP
1424
467k
  } ligbase = LIGBASE_NOT_CHECKED;
1425
1426
496k
  for (unsigned int i = 1; i < count; i++)
1427
467k
  {
1428
467k
    unsigned unsafe_to;
1429
467k
    if (!skippy_iter.next (&unsafe_to))
1430
438k
    {
1431
438k
      *end_position = unsafe_to;
1432
438k
      return_trace (false);
1433
438k
    }
1434
1435
29.4k
    if (unlikely (i + 1 > c->match_positions.length &&
1436
29.4k
      !c->match_positions.resize_dirty  (i + 1)))
1437
0
      return_trace (false);
1438
29.4k
    c->match_positions.arrayZ[i] = skippy_iter.idx;
1439
1440
29.4k
    unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[skippy_iter.idx]);
1441
29.4k
    unsigned int this_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx]);
1442
1443
29.4k
    if (first_lig_id && first_lig_comp)
1444
0
    {
1445
      /* If first component was attached to a previous ligature component,
1446
       * all subsequent components should be attached to the same ligature
1447
       * component, otherwise we shouldn't ligate them... */
1448
0
      if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp)
1449
0
      {
1450
  /* ...unless, we are attached to a base ligature and that base
1451
   * ligature is ignorable. */
1452
0
  if (ligbase == LIGBASE_NOT_CHECKED)
1453
0
  {
1454
0
    bool found = false;
1455
0
    const auto *out = buffer->out_info;
1456
0
    unsigned int j = buffer->out_len;
1457
0
    while (j && _hb_glyph_info_get_lig_id (&out[j - 1]) == first_lig_id)
1458
0
    {
1459
0
      if (_hb_glyph_info_get_lig_comp (&out[j - 1]) == 0)
1460
0
      {
1461
0
        j--;
1462
0
        found = true;
1463
0
        break;
1464
0
      }
1465
0
      j--;
1466
0
    }
1467
1468
0
    if (found && skippy_iter.may_skip (out[j]) == matcher_t::SKIP_YES)
1469
0
      ligbase = LIGBASE_MAY_SKIP;
1470
0
    else
1471
0
      ligbase = LIGBASE_MAY_NOT_SKIP;
1472
0
  }
1473
1474
0
  if (ligbase == LIGBASE_MAY_NOT_SKIP)
1475
0
    return_trace (false);
1476
0
      }
1477
0
    }
1478
29.4k
    else
1479
29.4k
    {
1480
      /* If first component was NOT attached to a previous ligature component,
1481
       * all subsequent components should also NOT be attached to any ligature
1482
       * component, unless they are attached to the first component itself! */
1483
29.4k
      if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id))
1484
0
  return_trace (false);
1485
29.4k
    }
1486
1487
29.4k
    total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[skippy_iter.idx]);
1488
29.4k
  }
1489
1490
29.1k
  *end_position = skippy_iter.idx + 1;
1491
1492
29.1k
  if (p_total_component_count)
1493
29.1k
  {
1494
29.1k
    total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1495
29.1k
    *p_total_component_count = total_component_count;
1496
29.1k
  }
1497
1498
29.1k
  c->match_positions.arrayZ[0] = buffer->idx;
1499
1500
29.1k
  return_trace (true);
1501
467k
}
hb-ot-layout.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Line
Count
Source
1370
1.60M
{
1371
1.60M
  TRACE_APPLY (nullptr);
1372
1373
1.60M
  hb_buffer_t *buffer = c->buffer;
1374
1375
1.60M
  if (count == 1)
1376
1.48M
  {
1377
1.48M
    *end_position = buffer->idx + 1;
1378
1.48M
    c->match_positions[0] = buffer->idx;
1379
1.48M
    if (p_total_component_count)
1380
0
      *p_total_component_count = _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1381
1.48M
    return_trace (true);
1382
1.48M
  }
1383
1384
119k
  if (unlikely (count > HB_MAX_CONTEXT_LENGTH)) return_trace (false);
1385
1386
119k
  auto &skippy_iter = c->iter_input;
1387
119k
  skippy_iter.reset (buffer->idx);
1388
119k
  skippy_iter.set_match_func (match_func, match_data);
1389
119k
  skippy_iter.set_glyph_data (input);
1390
1391
  /*
1392
   * This is perhaps the trickiest part of OpenType...  Remarks:
1393
   *
1394
   * - If all components of the ligature were marks, we call this a mark ligature.
1395
   *
1396
   * - If there is no GDEF, and the ligature is NOT a mark ligature, we categorize
1397
   *   it as a ligature glyph.
1398
   *
1399
   * - Ligatures cannot be formed across glyphs attached to different components
1400
   *   of previous ligatures.  Eg. the sequence is LAM,SHADDA,LAM,FATHA,HEH, and
1401
   *   LAM,LAM,HEH form a ligature, leaving SHADDA,FATHA next to eachother.
1402
   *   However, it would be wrong to ligate that SHADDA,FATHA sequence.
1403
   *   There are a couple of exceptions to this:
1404
   *
1405
   *   o If a ligature tries ligating with marks that belong to it itself, go ahead,
1406
   *     assuming that the font designer knows what they are doing (otherwise it can
1407
   *     break Indic stuff when a matra wants to ligate with a conjunct,
1408
   *
1409
   *   o If two marks want to ligate and they belong to different components of the
1410
   *     same ligature glyph, and said ligature glyph is to be ignored according to
1411
   *     mark-filtering rules, then allow.
1412
   *     https://github.com/harfbuzz/harfbuzz/issues/545
1413
   */
1414
1415
119k
  unsigned int total_component_count = 0;
1416
1417
119k
  unsigned int first_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur());
1418
119k
  unsigned int first_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
1419
1420
119k
  enum {
1421
119k
    LIGBASE_NOT_CHECKED,
1422
119k
    LIGBASE_MAY_NOT_SKIP,
1423
119k
    LIGBASE_MAY_SKIP
1424
119k
  } ligbase = LIGBASE_NOT_CHECKED;
1425
1426
152k
  for (unsigned int i = 1; i < count; i++)
1427
119k
  {
1428
119k
    unsigned unsafe_to;
1429
119k
    if (!skippy_iter.next (&unsafe_to))
1430
85.5k
    {
1431
85.5k
      *end_position = unsafe_to;
1432
85.5k
      return_trace (false);
1433
85.5k
    }
1434
1435
33.5k
    if (unlikely (i + 1 > c->match_positions.length &&
1436
33.5k
      !c->match_positions.resize_dirty  (i + 1)))
1437
0
      return_trace (false);
1438
33.5k
    c->match_positions.arrayZ[i] = skippy_iter.idx;
1439
1440
33.5k
    unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[skippy_iter.idx]);
1441
33.5k
    unsigned int this_lig_comp = _hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx]);
1442
1443
33.5k
    if (first_lig_id && first_lig_comp)
1444
0
    {
1445
      /* If first component was attached to a previous ligature component,
1446
       * all subsequent components should be attached to the same ligature
1447
       * component, otherwise we shouldn't ligate them... */
1448
0
      if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp)
1449
0
      {
1450
  /* ...unless, we are attached to a base ligature and that base
1451
   * ligature is ignorable. */
1452
0
  if (ligbase == LIGBASE_NOT_CHECKED)
1453
0
  {
1454
0
    bool found = false;
1455
0
    const auto *out = buffer->out_info;
1456
0
    unsigned int j = buffer->out_len;
1457
0
    while (j && _hb_glyph_info_get_lig_id (&out[j - 1]) == first_lig_id)
1458
0
    {
1459
0
      if (_hb_glyph_info_get_lig_comp (&out[j - 1]) == 0)
1460
0
      {
1461
0
        j--;
1462
0
        found = true;
1463
0
        break;
1464
0
      }
1465
0
      j--;
1466
0
    }
1467
1468
0
    if (found && skippy_iter.may_skip (out[j]) == matcher_t::SKIP_YES)
1469
0
      ligbase = LIGBASE_MAY_SKIP;
1470
0
    else
1471
0
      ligbase = LIGBASE_MAY_NOT_SKIP;
1472
0
  }
1473
1474
0
  if (ligbase == LIGBASE_MAY_NOT_SKIP)
1475
0
    return_trace (false);
1476
0
      }
1477
0
    }
1478
33.5k
    else
1479
33.5k
    {
1480
      /* If first component was NOT attached to a previous ligature component,
1481
       * all subsequent components should also NOT be attached to any ligature
1482
       * component, unless they are attached to the first component itself! */
1483
33.5k
      if (this_lig_id && this_lig_comp && (this_lig_id != first_lig_id))
1484
0
  return_trace (false);
1485
33.5k
    }
1486
1487
33.5k
    total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[skippy_iter.idx]);
1488
33.5k
  }
1489
1490
33.5k
  *end_position = skippy_iter.idx + 1;
1491
1492
33.5k
  if (p_total_component_count)
1493
0
  {
1494
0
    total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1495
0
    *p_total_component_count = total_component_count;
1496
0
  }
1497
1498
33.5k
  c->match_positions.arrayZ[0] = buffer->idx;
1499
1500
33.5k
  return_trace (true);
1501
119k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::match_input<OT::HBGlyphID16>(OT::hb_ot_apply_context_t*, unsigned int, OT::HBGlyphID16 const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::match_input<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*, unsigned int*)
1502
static inline bool ligate_input (hb_ot_apply_context_t *c,
1503
         unsigned int count, /* Including the first glyph */
1504
         unsigned int match_end,
1505
         hb_codepoint_t lig_glyph,
1506
         unsigned int total_component_count)
1507
29.1k
{
1508
29.1k
  TRACE_APPLY (nullptr);
1509
1510
29.1k
  hb_buffer_t *buffer = c->buffer;
1511
1512
29.1k
  buffer->merge_clusters (buffer->idx, match_end);
1513
1514
  /* - If a base and one or more marks ligate, consider that as a base, NOT
1515
   *   ligature, such that all following marks can still attach to it.
1516
   *   https://github.com/harfbuzz/harfbuzz/issues/1109
1517
   *
1518
   * - If all components of the ligature were marks, we call this a mark ligature.
1519
   *   If it *is* a mark ligature, we don't allocate a new ligature id, and leave
1520
   *   the ligature to keep its old ligature id.  This will allow it to attach to
1521
   *   a base ligature in GPOS.  Eg. if the sequence is: LAM,LAM,SHADDA,FATHA,HEH,
1522
   *   and LAM,LAM,HEH for a ligature, they will leave SHADDA and FATHA with a
1523
   *   ligature id and component value of 2.  Then if SHADDA,FATHA form a ligature
1524
   *   later, we don't want them to lose their ligature id/component, otherwise
1525
   *   GPOS will fail to correctly position the mark ligature on top of the
1526
   *   LAM,LAM,HEH ligature.  See:
1527
   *     https://bugzilla.gnome.org/show_bug.cgi?id=676343
1528
   *
1529
   * - If a ligature is formed of components that some of which are also ligatures
1530
   *   themselves, and those ligature components had marks attached to *their*
1531
   *   components, we have to attach the marks to the new ligature component
1532
   *   positions!  Now *that*'s tricky!  And these marks may be following the
1533
   *   last component of the whole sequence, so we should loop forward looking
1534
   *   for them and update them.
1535
   *
1536
   *   Eg. the sequence is LAM,LAM,SHADDA,FATHA,HEH, and the font first forms a
1537
   *   'calt' ligature of LAM,HEH, leaving the SHADDA and FATHA with a ligature
1538
   *   id and component == 1.  Now, during 'liga', the LAM and the LAM-HEH ligature
1539
   *   form a LAM-LAM-HEH ligature.  We need to reassign the SHADDA and FATHA to
1540
   *   the new ligature with a component value of 2.
1541
   *
1542
   *   This in fact happened to a font...  See:
1543
   *   https://bugzilla.gnome.org/show_bug.cgi?id=437633
1544
   */
1545
1546
29.1k
  bool is_base_ligature = _hb_glyph_info_is_base_glyph (&buffer->info[c->match_positions.arrayZ[0]]);
1547
29.1k
  bool is_mark_ligature = _hb_glyph_info_is_mark (&buffer->info[c->match_positions.arrayZ[0]]);
1548
58.3k
  for (unsigned int i = 1; i < count; i++)
1549
29.1k
    if (!_hb_glyph_info_is_mark (&buffer->info[c->match_positions.arrayZ[i]]))
1550
0
    {
1551
0
      is_base_ligature = false;
1552
0
      is_mark_ligature = false;
1553
0
      break;
1554
0
    }
1555
29.1k
  bool is_ligature = !is_base_ligature && !is_mark_ligature;
1556
1557
29.1k
  unsigned int klass = is_ligature ? HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE : 0;
1558
29.1k
  unsigned int lig_id = is_ligature ? _hb_allocate_lig_id (buffer) : 0;
1559
29.1k
  unsigned int last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur());
1560
29.1k
  unsigned int last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1561
29.1k
  unsigned int components_so_far = last_num_components;
1562
1563
29.1k
  if (is_ligature)
1564
0
  {
1565
0
    _hb_glyph_info_set_lig_props_for_ligature (&buffer->cur(), lig_id, total_component_count);
1566
0
    if (_hb_glyph_info_get_general_category (&buffer->cur()) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
1567
0
    {
1568
0
      _hb_glyph_info_set_general_category (&buffer->cur(), HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER);
1569
0
    }
1570
0
  }
1571
29.1k
  c->replace_glyph_with_ligature (lig_glyph, klass);
1572
1573
58.3k
  for (unsigned int i = 1; i < count; i++)
1574
29.1k
  {
1575
29.1k
    while (buffer->idx < c->match_positions.arrayZ[i] && buffer->successful)
1576
0
    {
1577
0
      if (is_ligature)
1578
0
      {
1579
0
  unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
1580
0
  if (this_comp == 0)
1581
0
    this_comp = last_num_components;
1582
0
  assert (components_so_far >= last_num_components);
1583
0
  unsigned int new_lig_comp = components_so_far - last_num_components +
1584
0
            hb_min (this_comp, last_num_components);
1585
0
    _hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, new_lig_comp);
1586
0
      }
1587
0
      (void) buffer->next_glyph ();
1588
0
    }
1589
1590
29.1k
    last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur());
1591
29.1k
    last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1592
29.1k
    components_so_far += last_num_components;
1593
1594
    /* Skip the base glyph */
1595
29.1k
    buffer->idx++;
1596
29.1k
  }
1597
1598
29.1k
  if (!is_mark_ligature && last_lig_id)
1599
0
  {
1600
    /* Re-adjust components for any marks following. */
1601
0
    for (unsigned i = buffer->idx; i < buffer->len; ++i)
1602
0
    {
1603
0
      if (last_lig_id != _hb_glyph_info_get_lig_id (&buffer->info[i])) break;
1604
1605
0
      unsigned this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]);
1606
0
      if (!this_comp) break;
1607
1608
0
      assert (components_so_far >= last_num_components);
1609
0
      unsigned new_lig_comp = components_so_far - last_num_components +
1610
0
            hb_min (this_comp, last_num_components);
1611
0
      _hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig_comp);
1612
0
    }
1613
0
  }
1614
29.1k
  return_trace (true);
1615
29.1k
}
Unexecuted instantiation: hb-aat-layout.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-ot-face.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
hb-ot-layout.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Line
Count
Source
1507
29.1k
{
1508
29.1k
  TRACE_APPLY (nullptr);
1509
1510
29.1k
  hb_buffer_t *buffer = c->buffer;
1511
1512
29.1k
  buffer->merge_clusters (buffer->idx, match_end);
1513
1514
  /* - If a base and one or more marks ligate, consider that as a base, NOT
1515
   *   ligature, such that all following marks can still attach to it.
1516
   *   https://github.com/harfbuzz/harfbuzz/issues/1109
1517
   *
1518
   * - If all components of the ligature were marks, we call this a mark ligature.
1519
   *   If it *is* a mark ligature, we don't allocate a new ligature id, and leave
1520
   *   the ligature to keep its old ligature id.  This will allow it to attach to
1521
   *   a base ligature in GPOS.  Eg. if the sequence is: LAM,LAM,SHADDA,FATHA,HEH,
1522
   *   and LAM,LAM,HEH for a ligature, they will leave SHADDA and FATHA with a
1523
   *   ligature id and component value of 2.  Then if SHADDA,FATHA form a ligature
1524
   *   later, we don't want them to lose their ligature id/component, otherwise
1525
   *   GPOS will fail to correctly position the mark ligature on top of the
1526
   *   LAM,LAM,HEH ligature.  See:
1527
   *     https://bugzilla.gnome.org/show_bug.cgi?id=676343
1528
   *
1529
   * - If a ligature is formed of components that some of which are also ligatures
1530
   *   themselves, and those ligature components had marks attached to *their*
1531
   *   components, we have to attach the marks to the new ligature component
1532
   *   positions!  Now *that*'s tricky!  And these marks may be following the
1533
   *   last component of the whole sequence, so we should loop forward looking
1534
   *   for them and update them.
1535
   *
1536
   *   Eg. the sequence is LAM,LAM,SHADDA,FATHA,HEH, and the font first forms a
1537
   *   'calt' ligature of LAM,HEH, leaving the SHADDA and FATHA with a ligature
1538
   *   id and component == 1.  Now, during 'liga', the LAM and the LAM-HEH ligature
1539
   *   form a LAM-LAM-HEH ligature.  We need to reassign the SHADDA and FATHA to
1540
   *   the new ligature with a component value of 2.
1541
   *
1542
   *   This in fact happened to a font...  See:
1543
   *   https://bugzilla.gnome.org/show_bug.cgi?id=437633
1544
   */
1545
1546
29.1k
  bool is_base_ligature = _hb_glyph_info_is_base_glyph (&buffer->info[c->match_positions.arrayZ[0]]);
1547
29.1k
  bool is_mark_ligature = _hb_glyph_info_is_mark (&buffer->info[c->match_positions.arrayZ[0]]);
1548
58.3k
  for (unsigned int i = 1; i < count; i++)
1549
29.1k
    if (!_hb_glyph_info_is_mark (&buffer->info[c->match_positions.arrayZ[i]]))
1550
0
    {
1551
0
      is_base_ligature = false;
1552
0
      is_mark_ligature = false;
1553
0
      break;
1554
0
    }
1555
29.1k
  bool is_ligature = !is_base_ligature && !is_mark_ligature;
1556
1557
29.1k
  unsigned int klass = is_ligature ? HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE : 0;
1558
29.1k
  unsigned int lig_id = is_ligature ? _hb_allocate_lig_id (buffer) : 0;
1559
29.1k
  unsigned int last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur());
1560
29.1k
  unsigned int last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1561
29.1k
  unsigned int components_so_far = last_num_components;
1562
1563
29.1k
  if (is_ligature)
1564
0
  {
1565
0
    _hb_glyph_info_set_lig_props_for_ligature (&buffer->cur(), lig_id, total_component_count);
1566
0
    if (_hb_glyph_info_get_general_category (&buffer->cur()) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
1567
0
    {
1568
0
      _hb_glyph_info_set_general_category (&buffer->cur(), HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER);
1569
0
    }
1570
0
  }
1571
29.1k
  c->replace_glyph_with_ligature (lig_glyph, klass);
1572
1573
58.3k
  for (unsigned int i = 1; i < count; i++)
1574
29.1k
  {
1575
29.1k
    while (buffer->idx < c->match_positions.arrayZ[i] && buffer->successful)
1576
0
    {
1577
0
      if (is_ligature)
1578
0
      {
1579
0
  unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
1580
0
  if (this_comp == 0)
1581
0
    this_comp = last_num_components;
1582
0
  assert (components_so_far >= last_num_components);
1583
0
  unsigned int new_lig_comp = components_so_far - last_num_components +
1584
0
            hb_min (this_comp, last_num_components);
1585
0
    _hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, new_lig_comp);
1586
0
      }
1587
0
      (void) buffer->next_glyph ();
1588
0
    }
1589
1590
29.1k
    last_lig_id = _hb_glyph_info_get_lig_id (&buffer->cur());
1591
29.1k
    last_num_components = _hb_glyph_info_get_lig_num_comps (&buffer->cur());
1592
29.1k
    components_so_far += last_num_components;
1593
1594
    /* Skip the base glyph */
1595
29.1k
    buffer->idx++;
1596
29.1k
  }
1597
1598
29.1k
  if (!is_mark_ligature && last_lig_id)
1599
0
  {
1600
    /* Re-adjust components for any marks following. */
1601
0
    for (unsigned i = buffer->idx; i < buffer->len; ++i)
1602
0
    {
1603
0
      if (last_lig_id != _hb_glyph_info_get_lig_id (&buffer->info[i])) break;
1604
1605
0
      unsigned this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]);
1606
0
      if (!this_comp) break;
1607
1608
0
      assert (components_so_far >= last_num_components);
1609
0
      unsigned new_lig_comp = components_so_far - last_num_components +
1610
0
            hb_min (this_comp, last_num_components);
1611
0
      _hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig_comp);
1612
0
    }
1613
0
  }
1614
29.1k
  return_trace (true);
1615
29.1k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-var.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-color.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-other.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: gsubgpos-context.cc:OT::ligate_input(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, unsigned int, unsigned int)
1616
1617
template <typename HBUINT>
1618
#ifndef HB_OPTIMIZE_SIZE
1619
HB_ALWAYS_INLINE
1620
#endif
1621
static bool match_backtrack (hb_ot_apply_context_t *c,
1622
           unsigned int count,
1623
           const HBUINT backtrack[],
1624
           match_func_t match_func,
1625
           const void *match_data,
1626
           unsigned int *match_start)
1627
865k
{
1628
865k
  TRACE_APPLY (nullptr);
1629
1630
865k
  if (!count)
1631
859
  {
1632
859
    *match_start = c->buffer->backtrack_len ();
1633
859
    return_trace (true);
1634
859
  }
1635
1636
864k
  auto &skippy_iter = c->iter_context;
1637
864k
  skippy_iter.reset_back (c->buffer->backtrack_len ());
1638
864k
  skippy_iter.set_match_func (match_func, match_data);
1639
864k
  skippy_iter.set_glyph_data (backtrack);
1640
1641
983k
  for (unsigned int i = 0; i < count; i++)
1642
975k
  {
1643
975k
    unsigned unsafe_from;
1644
975k
    if (!skippy_iter.prev (&unsafe_from))
1645
857k
    {
1646
857k
      *match_start = unsafe_from;
1647
857k
      return_trace (false);
1648
857k
    }
1649
975k
  }
1650
1651
7.45k
  *match_start = skippy_iter.idx;
1652
7.45k
  return_trace (true);
1653
864k
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-ot-face.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
hb-ot-layout.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Line
Count
Source
1627
865k
{
1628
865k
  TRACE_APPLY (nullptr);
1629
1630
865k
  if (!count)
1631
859
  {
1632
859
    *match_start = c->buffer->backtrack_len ();
1633
859
    return_trace (true);
1634
859
  }
1635
1636
864k
  auto &skippy_iter = c->iter_context;
1637
864k
  skippy_iter.reset_back (c->buffer->backtrack_len ());
1638
864k
  skippy_iter.set_match_func (match_func, match_data);
1639
864k
  skippy_iter.set_glyph_data (backtrack);
1640
1641
983k
  for (unsigned int i = 0; i < count; i++)
1642
975k
  {
1643
975k
    unsigned unsafe_from;
1644
975k
    if (!skippy_iter.prev (&unsafe_from))
1645
857k
    {
1646
857k
      *match_start = unsafe_from;
1647
857k
      return_trace (false);
1648
857k
    }
1649
975k
  }
1650
1651
7.45k
  *match_start = skippy_iter.idx;
1652
7.45k
  return_trace (true);
1653
864k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-subset.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::match_backtrack<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int*)
1654
1655
template <typename HBUINT>
1656
#ifndef HB_OPTIMIZE_SIZE
1657
HB_ALWAYS_INLINE
1658
#endif
1659
static bool match_lookahead (hb_ot_apply_context_t *c,
1660
           unsigned int count,
1661
           const HBUINT lookahead[],
1662
           match_func_t match_func,
1663
           const void *match_data,
1664
           unsigned int start_index,
1665
           unsigned int *end_index)
1666
1.51M
{
1667
1.51M
  TRACE_APPLY (nullptr);
1668
1669
1.51M
  if (!count)
1670
753k
  {
1671
753k
    *end_index = start_index;
1672
753k
    return_trace (true);
1673
753k
  }
1674
1675
765k
  auto &skippy_iter = c->iter_context;
1676
765k
  assert (start_index >= 1);
1677
765k
  skippy_iter.reset (start_index - 1);
1678
765k
  skippy_iter.set_match_func (match_func, match_data);
1679
765k
  skippy_iter.set_glyph_data (lookahead);
1680
1681
877k
  for (unsigned int i = 0; i < count; i++)
1682
765k
  {
1683
765k
    unsigned unsafe_to;
1684
765k
    if (!skippy_iter.next (&unsafe_to))
1685
652k
    {
1686
652k
      *end_index = unsafe_to;
1687
652k
      return_trace (false);
1688
652k
    }
1689
765k
  }
1690
1691
112k
  *end_index = skippy_iter.idx + 1;
1692
112k
  return_trace (true);
1693
765k
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-ot-face.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
hb-ot-layout.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Line
Count
Source
1666
1.51M
{
1667
1.51M
  TRACE_APPLY (nullptr);
1668
1669
1.51M
  if (!count)
1670
753k
  {
1671
753k
    *end_index = start_index;
1672
753k
    return_trace (true);
1673
753k
  }
1674
1675
765k
  auto &skippy_iter = c->iter_context;
1676
765k
  assert (start_index >= 1);
1677
765k
  skippy_iter.reset (start_index - 1);
1678
765k
  skippy_iter.set_match_func (match_func, match_data);
1679
765k
  skippy_iter.set_glyph_data (lookahead);
1680
1681
877k
  for (unsigned int i = 0; i < count; i++)
1682
765k
  {
1683
765k
    unsigned unsafe_to;
1684
765k
    if (!skippy_iter.next (&unsafe_to))
1685
652k
    {
1686
652k
      *end_index = unsafe_to;
1687
652k
      return_trace (false);
1688
652k
    }
1689
765k
  }
1690
1691
112k
  *end_index = skippy_iter.idx + 1;
1692
112k
  return_trace (true);
1693
765k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-subset.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::match_lookahead<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, bool (*)(hb_glyph_info_t&, unsigned int, void const*), void const*, unsigned int, unsigned int*)
1694
1695
1696
1697
struct LookupRecord
1698
{
1699
  bool serialize (hb_serialize_context_t *c,
1700
      const hb_map_t         *lookup_map) const
1701
0
  {
1702
0
    TRACE_SERIALIZE (this);
1703
0
    auto *out = c->embed (*this);
1704
0
    if (unlikely (!out)) return_trace (false);
1705
1706
0
    return_trace (c->check_assign (out->lookupListIndex, lookup_map->get (lookupListIndex), HB_SERIALIZE_ERROR_INT_OVERFLOW));
1707
0
  }
1708
1709
  bool sanitize (hb_sanitize_context_t *c) const
1710
0
  {
1711
0
    TRACE_SANITIZE (this);
1712
0
    return_trace (c->check_struct (this));
1713
0
  }
1714
1715
  HBUINT16  sequenceIndex;    /* Index into current glyph
1716
           * sequence--first glyph = 0 */
1717
  HBUINT16  lookupListIndex;  /* Lookup to apply to that
1718
           * position--zero--based */
1719
  public:
1720
  DEFINE_SIZE_STATIC (4);
1721
};
1722
1723
static unsigned serialize_lookuprecord_array (hb_serialize_context_t *c,
1724
                const hb_array_t<const LookupRecord> lookupRecords,
1725
                const hb_map_t *lookup_map)
1726
0
{
1727
0
  unsigned count = 0;
1728
0
  for (const LookupRecord& r : lookupRecords)
1729
0
  {
1730
0
    if (!lookup_map->has (r.lookupListIndex))
1731
0
      continue;
1732
1733
0
    if (!r.serialize (c, lookup_map))
1734
0
      return 0;
1735
1736
0
    count++;
1737
0
  }
1738
0
  return count;
1739
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-ot-face.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-ot-layout.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-subset.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-subset-table-var.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-subset-table-color.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: hb-subset-table-other.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
Unexecuted instantiation: gsubgpos-context.cc:OT::serialize_lookuprecord_array(hb_serialize_context_t*, hb_array_t<OT::LookupRecord const>, hb_map_t const*)
1740
1741
enum ContextFormat { SimpleContext = 1, ClassBasedContext = 2, CoverageBasedContext = 3 };
1742
1743
template <typename HBUINT>
1744
static void context_closure_recurse_lookups (hb_closure_context_t *c,
1745
               unsigned inputCount, const HBUINT input[],
1746
               unsigned lookupCount,
1747
               const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */,
1748
               unsigned value,
1749
               ContextFormat context_format,
1750
               const void *data,
1751
               intersected_glyphs_func_t intersected_glyphs_func,
1752
               void *cache)
1753
0
{
1754
0
  hb_set_t covered_seq_indicies;
1755
0
  hb_set_t pos_glyphs;
1756
0
  for (unsigned int i = 0; i < lookupCount; i++)
1757
0
  {
1758
0
    unsigned seqIndex = lookupRecord[i].sequenceIndex;
1759
0
    if (seqIndex >= inputCount) continue;
1760
1761
0
    bool has_pos_glyphs = false;
1762
1763
0
    if (!covered_seq_indicies.has (seqIndex))
1764
0
    {
1765
0
      has_pos_glyphs = true;
1766
0
      pos_glyphs.clear ();
1767
0
      if (seqIndex == 0)
1768
0
      {
1769
0
        switch (context_format) {
1770
0
        case ContextFormat::SimpleContext:
1771
0
          pos_glyphs.add (value);
1772
0
          break;
1773
0
        case ContextFormat::ClassBasedContext:
1774
0
          intersected_glyphs_func (&c->parent_active_glyphs (), data, value, &pos_glyphs, cache);
1775
0
          break;
1776
0
        case ContextFormat::CoverageBasedContext:
1777
0
          pos_glyphs.set (c->parent_active_glyphs ());
1778
0
          break;
1779
0
        }
1780
0
      }
1781
0
      else
1782
0
      {
1783
0
        const void *input_data = input;
1784
0
        unsigned input_value = seqIndex - 1;
1785
0
        if (context_format != ContextFormat::SimpleContext)
1786
0
        {
1787
0
          input_data = data;
1788
0
          input_value = input[seqIndex - 1];
1789
0
        }
1790
1791
0
        intersected_glyphs_func (c->glyphs, input_data, input_value, &pos_glyphs, cache);
1792
0
      }
1793
0
    }
1794
1795
0
    covered_seq_indicies.add (seqIndex);
1796
0
    hb_set_t *cur_active_glyphs = c->push_cur_active_glyphs ();
1797
0
    if (unlikely (!cur_active_glyphs))
1798
0
      return;
1799
0
    if (has_pos_glyphs) {
1800
0
      *cur_active_glyphs = std::move (pos_glyphs);
1801
0
    } else {
1802
0
      *cur_active_glyphs = *c->glyphs;
1803
0
    }
1804
1805
0
    unsigned endIndex = inputCount;
1806
0
    if (context_format == ContextFormat::CoverageBasedContext)
1807
0
      endIndex += 1;
1808
1809
0
    c->recurse (lookupRecord[i].lookupListIndex, &covered_seq_indicies, seqIndex, endIndex);
1810
1811
0
    c->pop_cur_done_glyphs ();
1812
0
  }
1813
0
}
Unexecuted instantiation: hb-aat-layout.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-ot-face.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-ot-layout.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-subset.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
Unexecuted instantiation: gsubgpos-context.cc:void OT::context_closure_recurse_lookups<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextFormat, void const*, void (*)(hb_set_t const*, void const*, unsigned int, hb_set_t*, void*), void*)
1814
1815
template <typename context_t>
1816
static inline void recurse_lookups (context_t *c,
1817
                                    unsigned int lookupCount,
1818
                                    const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */)
1819
0
{
1820
0
  for (unsigned int i = 0; i < lookupCount; i++)
1821
0
    c->recurse (lookupRecord[i].lookupListIndex);
1822
0
}
Unexecuted instantiation: hb-aat-layout.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-aat-layout.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-face.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-face.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-layout.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-layout.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: gsubgpos-context.cc:void OT::recurse_lookups<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*, unsigned int, OT::LookupRecord const*)
Unexecuted instantiation: gsubgpos-context.cc:void OT::recurse_lookups<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*, unsigned int, OT::LookupRecord const*)
1823
1824
static inline void apply_lookup (hb_ot_apply_context_t *c,
1825
         unsigned int count, /* Including the first glyph */
1826
         unsigned int lookupCount,
1827
         const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
1828
         unsigned int match_end)
1829
8.30k
{
1830
8.30k
  hb_buffer_t *buffer = c->buffer;
1831
8.30k
  int end;
1832
1833
  /* All positions are distance from beginning of *output* buffer.
1834
   * Adjust. */
1835
8.30k
  {
1836
8.30k
    unsigned int bl = buffer->backtrack_len ();
1837
8.30k
    end = bl + match_end - buffer->idx;
1838
1839
8.30k
    int delta = bl - buffer->idx;
1840
    /* Convert positions to new indexing. */
1841
17.4k
    for (unsigned int j = 0; j < count; j++)
1842
9.16k
      c->match_positions.arrayZ[j] += delta;
1843
8.30k
  }
1844
1845
16.6k
  for (unsigned int i = 0; i < lookupCount && buffer->successful; i++)
1846
8.30k
  {
1847
8.30k
    unsigned int idx = lookupRecord[i].sequenceIndex;
1848
8.30k
    if (idx >= count)
1849
0
      continue;
1850
1851
8.30k
    unsigned int orig_len = buffer->backtrack_len () + buffer->lookahead_len ();
1852
1853
    /* This can happen if earlier recursed lookups deleted many entries. */
1854
8.30k
    if (unlikely (c->match_positions.arrayZ[idx] >= orig_len))
1855
0
      continue;
1856
1857
8.30k
    if (unlikely (!buffer->move_to (c->match_positions.arrayZ[idx])))
1858
0
      break;
1859
1860
8.30k
    if (unlikely (buffer->max_ops <= 0))
1861
0
      break;
1862
1863
8.30k
    if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ())
1864
0
    {
1865
0
      if (buffer->have_output)
1866
0
        c->buffer->sync_so_far ();
1867
0
      c->buffer->message (c->font,
1868
0
        "start recursing to lookup %u at %u",
1869
0
        (unsigned) lookupRecord[i].lookupListIndex,
1870
0
        buffer->idx);
1871
0
    }
1872
1873
8.30k
    bool ret = c->recurse (lookupRecord[i].lookupListIndex);
1874
1875
8.30k
    if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ())
1876
0
    {
1877
0
      if (buffer->have_output)
1878
0
        c->buffer->sync_so_far ();
1879
0
      c->buffer->message (c->font,
1880
0
        "end recursing to lookup %u",
1881
0
        (unsigned) lookupRecord[i].lookupListIndex);
1882
0
    }
1883
1884
8.30k
    if (!ret)
1885
834
      continue;
1886
1887
7.47k
    unsigned int new_len = buffer->backtrack_len () + buffer->lookahead_len ();
1888
7.47k
    int delta = new_len - orig_len;
1889
1890
7.47k
    if (!delta)
1891
7.45k
      continue;
1892
1893
    /* Recursed lookup changed buffer len.  Adjust.
1894
     *
1895
     * TODO:
1896
     *
1897
     * Right now, if buffer length increased by n, we assume n new glyphs
1898
     * were added right after the current position, and if buffer length
1899
     * was decreased by n, we assume n match positions after the current
1900
     * one where removed.  The former (buffer length increased) case is
1901
     * fine, but the decrease case can be improved in at least two ways,
1902
     * both of which are significant:
1903
     *
1904
     *   - If recursed-to lookup is MultipleSubst and buffer length
1905
     *     decreased, then it's current match position that was deleted,
1906
     *     NOT the one after it.
1907
     *
1908
     *   - If buffer length was decreased by n, it does not necessarily
1909
     *     mean that n match positions where removed, as there recursed-to
1910
     *     lookup might had a different LookupFlag.  Here's a constructed
1911
     *     case of that:
1912
     *     https://github.com/harfbuzz/harfbuzz/discussions/3538
1913
     *
1914
     * It should be possible to construct tests for both of these cases.
1915
     */
1916
1917
25
    end += delta;
1918
25
    if (end < int (c->match_positions.arrayZ[idx]))
1919
0
    {
1920
      /* End might end up being smaller than match_positions.arrayZ[idx] if the recursed
1921
       * lookup ended up removing many items.
1922
       * Just never rewind end beyond start of current position, since that is
1923
       * not possible in the recursed lookup.  Also adjust delta as such.
1924
       *
1925
       * https://bugs.chromium.org/p/chromium/issues/detail?id=659496
1926
       * https://github.com/harfbuzz/harfbuzz/issues/1611
1927
       */
1928
0
      delta += c->match_positions.arrayZ[idx] - end;
1929
0
      end = c->match_positions.arrayZ[idx];
1930
0
    }
1931
1932
25
    unsigned int next = idx + 1; /* next now is the position after the recursed lookup. */
1933
1934
25
    if (delta > 0)
1935
0
    {
1936
0
      if (unlikely (delta + count > HB_MAX_CONTEXT_LENGTH))
1937
0
  break;
1938
0
      if (unlikely (count + delta > c->match_positions.length &&
1939
0
        !c->match_positions.resize_dirty  (count + delta)))
1940
0
        return;
1941
0
    }
1942
25
    else
1943
25
    {
1944
      /* NOTE: delta is non-positive. */
1945
25
      delta = hb_max (delta, (int) next - (int) count);
1946
25
      next -= delta;
1947
25
    }
1948
1949
    /* Shift! */
1950
25
    memmove (c->match_positions + next + delta, c->match_positions + next,
1951
25
       (count - next) * sizeof (c->match_positions.arrayZ[0]));
1952
25
    next += delta;
1953
25
    count += delta;
1954
1955
    /* Fill in new entries. */
1956
25
    for (unsigned int j = idx + 1; j < next; j++)
1957
0
      c->match_positions.arrayZ[j] = c->match_positions.arrayZ[j - 1] + 1;
1958
1959
    /* And fixup the rest. */
1960
25
    for (; next < count; next++)
1961
0
      c->match_positions.arrayZ[next] += delta;
1962
25
  }
1963
1964
8.30k
  assert (end >= 0);
1965
8.30k
  (void) buffer->move_to (end);
1966
8.30k
}
Unexecuted instantiation: hb-aat-layout.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-ot-face.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
hb-ot-layout.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Line
Count
Source
1829
8.30k
{
1830
8.30k
  hb_buffer_t *buffer = c->buffer;
1831
8.30k
  int end;
1832
1833
  /* All positions are distance from beginning of *output* buffer.
1834
   * Adjust. */
1835
8.30k
  {
1836
8.30k
    unsigned int bl = buffer->backtrack_len ();
1837
8.30k
    end = bl + match_end - buffer->idx;
1838
1839
8.30k
    int delta = bl - buffer->idx;
1840
    /* Convert positions to new indexing. */
1841
17.4k
    for (unsigned int j = 0; j < count; j++)
1842
9.16k
      c->match_positions.arrayZ[j] += delta;
1843
8.30k
  }
1844
1845
16.6k
  for (unsigned int i = 0; i < lookupCount && buffer->successful; i++)
1846
8.30k
  {
1847
8.30k
    unsigned int idx = lookupRecord[i].sequenceIndex;
1848
8.30k
    if (idx >= count)
1849
0
      continue;
1850
1851
8.30k
    unsigned int orig_len = buffer->backtrack_len () + buffer->lookahead_len ();
1852
1853
    /* This can happen if earlier recursed lookups deleted many entries. */
1854
8.30k
    if (unlikely (c->match_positions.arrayZ[idx] >= orig_len))
1855
0
      continue;
1856
1857
8.30k
    if (unlikely (!buffer->move_to (c->match_positions.arrayZ[idx])))
1858
0
      break;
1859
1860
8.30k
    if (unlikely (buffer->max_ops <= 0))
1861
0
      break;
1862
1863
8.30k
    if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ())
1864
0
    {
1865
0
      if (buffer->have_output)
1866
0
        c->buffer->sync_so_far ();
1867
0
      c->buffer->message (c->font,
1868
0
        "start recursing to lookup %u at %u",
1869
0
        (unsigned) lookupRecord[i].lookupListIndex,
1870
0
        buffer->idx);
1871
0
    }
1872
1873
8.30k
    bool ret = c->recurse (lookupRecord[i].lookupListIndex);
1874
1875
8.30k
    if (HB_BUFFER_MESSAGE_MORE && c->buffer->messaging ())
1876
0
    {
1877
0
      if (buffer->have_output)
1878
0
        c->buffer->sync_so_far ();
1879
0
      c->buffer->message (c->font,
1880
0
        "end recursing to lookup %u",
1881
0
        (unsigned) lookupRecord[i].lookupListIndex);
1882
0
    }
1883
1884
8.30k
    if (!ret)
1885
834
      continue;
1886
1887
7.47k
    unsigned int new_len = buffer->backtrack_len () + buffer->lookahead_len ();
1888
7.47k
    int delta = new_len - orig_len;
1889
1890
7.47k
    if (!delta)
1891
7.45k
      continue;
1892
1893
    /* Recursed lookup changed buffer len.  Adjust.
1894
     *
1895
     * TODO:
1896
     *
1897
     * Right now, if buffer length increased by n, we assume n new glyphs
1898
     * were added right after the current position, and if buffer length
1899
     * was decreased by n, we assume n match positions after the current
1900
     * one where removed.  The former (buffer length increased) case is
1901
     * fine, but the decrease case can be improved in at least two ways,
1902
     * both of which are significant:
1903
     *
1904
     *   - If recursed-to lookup is MultipleSubst and buffer length
1905
     *     decreased, then it's current match position that was deleted,
1906
     *     NOT the one after it.
1907
     *
1908
     *   - If buffer length was decreased by n, it does not necessarily
1909
     *     mean that n match positions where removed, as there recursed-to
1910
     *     lookup might had a different LookupFlag.  Here's a constructed
1911
     *     case of that:
1912
     *     https://github.com/harfbuzz/harfbuzz/discussions/3538
1913
     *
1914
     * It should be possible to construct tests for both of these cases.
1915
     */
1916
1917
25
    end += delta;
1918
25
    if (end < int (c->match_positions.arrayZ[idx]))
1919
0
    {
1920
      /* End might end up being smaller than match_positions.arrayZ[idx] if the recursed
1921
       * lookup ended up removing many items.
1922
       * Just never rewind end beyond start of current position, since that is
1923
       * not possible in the recursed lookup.  Also adjust delta as such.
1924
       *
1925
       * https://bugs.chromium.org/p/chromium/issues/detail?id=659496
1926
       * https://github.com/harfbuzz/harfbuzz/issues/1611
1927
       */
1928
0
      delta += c->match_positions.arrayZ[idx] - end;
1929
0
      end = c->match_positions.arrayZ[idx];
1930
0
    }
1931
1932
25
    unsigned int next = idx + 1; /* next now is the position after the recursed lookup. */
1933
1934
25
    if (delta > 0)
1935
0
    {
1936
0
      if (unlikely (delta + count > HB_MAX_CONTEXT_LENGTH))
1937
0
  break;
1938
0
      if (unlikely (count + delta > c->match_positions.length &&
1939
0
        !c->match_positions.resize_dirty  (count + delta)))
1940
0
        return;
1941
0
    }
1942
25
    else
1943
25
    {
1944
      /* NOTE: delta is non-positive. */
1945
25
      delta = hb_max (delta, (int) next - (int) count);
1946
25
      next -= delta;
1947
25
    }
1948
1949
    /* Shift! */
1950
25
    memmove (c->match_positions + next + delta, c->match_positions + next,
1951
25
       (count - next) * sizeof (c->match_positions.arrayZ[0]));
1952
25
    next += delta;
1953
25
    count += delta;
1954
1955
    /* Fill in new entries. */
1956
25
    for (unsigned int j = idx + 1; j < next; j++)
1957
0
      c->match_positions.arrayZ[j] = c->match_positions.arrayZ[j - 1] + 1;
1958
1959
    /* And fixup the rest. */
1960
25
    for (; next < count; next++)
1961
0
      c->match_positions.arrayZ[next] += delta;
1962
25
  }
1963
1964
8.30k
  assert (end >= 0);
1965
8.30k
  (void) buffer->move_to (end);
1966
8.30k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-subset.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-subset-table-var.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-subset-table-color.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: hb-subset-table-other.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
Unexecuted instantiation: gsubgpos-context.cc:OT::apply_lookup(OT::hb_ot_apply_context_t*, unsigned int, unsigned int, OT::LookupRecord const*, unsigned int)
1967
1968
1969
1970
/* Contextual lookups */
1971
1972
struct ContextClosureLookupContext
1973
{
1974
  ContextClosureFuncs funcs;
1975
  ContextFormat context_format;
1976
  const void *intersects_data;
1977
  void *intersects_cache;
1978
  void *intersected_glyphs_cache;
1979
};
1980
1981
struct ContextCollectGlyphsLookupContext
1982
{
1983
  ContextCollectGlyphsFuncs funcs;
1984
  const void *collect_data;
1985
};
1986
1987
struct ContextApplyLookupContext
1988
{
1989
  ContextApplyFuncs funcs;
1990
  const void *match_data;
1991
};
1992
1993
template <typename HBUINT>
1994
static inline bool context_intersects (const hb_set_t *glyphs,
1995
               unsigned int inputCount, /* Including the first glyph (not matched) */
1996
               const HBUINT input[], /* Array of input values--start with second glyph */
1997
               ContextClosureLookupContext &lookup_context)
1998
0
{
1999
0
  return array_is_subset_of (glyphs,
2000
0
           inputCount ? inputCount - 1 : 0, input,
2001
0
           lookup_context.funcs.intersects,
2002
0
           lookup_context.intersects_data,
2003
0
           lookup_context.intersects_cache);
2004
0
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-face.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ContextClosureLookupContext&)
2005
2006
template <typename HBUINT>
2007
static inline void context_closure_lookup (hb_closure_context_t *c,
2008
             unsigned int inputCount, /* Including the first glyph (not matched) */
2009
             const HBUINT input[], /* Array of input values--start with second glyph */
2010
             unsigned int lookupCount,
2011
             const LookupRecord lookupRecord[],
2012
             unsigned value, /* Index of first glyph in Coverage or Class value in ClassDef table */
2013
             ContextClosureLookupContext &lookup_context)
2014
0
{
2015
0
  if (context_intersects (c->glyphs,
2016
0
        inputCount, input,
2017
0
        lookup_context))
2018
0
    context_closure_recurse_lookups (c,
2019
0
             inputCount, input,
2020
0
             lookupCount, lookupRecord,
2021
0
             value,
2022
0
             lookup_context.context_format,
2023
0
             lookup_context.intersects_data,
2024
0
             lookup_context.funcs.intersected_glyphs,
2025
0
             lookup_context.intersected_glyphs_cache);
2026
0
}
Unexecuted instantiation: hb-aat-layout.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-face.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-layout.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
Unexecuted instantiation: gsubgpos-context.cc:void OT::context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ContextClosureLookupContext&)
2027
2028
template <typename HBUINT>
2029
static inline void context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c,
2030
              unsigned int inputCount, /* Including the first glyph (not matched) */
2031
              const HBUINT input[], /* Array of input values--start with second glyph */
2032
              unsigned int lookupCount,
2033
              const LookupRecord lookupRecord[],
2034
              ContextCollectGlyphsLookupContext &lookup_context)
2035
0
{
2036
0
  collect_array (c, c->input,
2037
0
     inputCount ? inputCount - 1 : 0, input,
2038
0
     lookup_context.funcs.collect, lookup_context.collect_data);
2039
0
  recurse_lookups (c,
2040
0
       lookupCount, lookupRecord);
2041
0
}
Unexecuted instantiation: hb-aat-layout.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-face.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-layout.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
Unexecuted instantiation: gsubgpos-context.cc:void OT::context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextCollectGlyphsLookupContext&)
2042
2043
template <typename HBUINT>
2044
static inline bool context_would_apply_lookup (hb_would_apply_context_t *c,
2045
                 unsigned int inputCount, /* Including the first glyph (not matched) */
2046
                 const HBUINT input[], /* Array of input values--start with second glyph */
2047
                 unsigned int lookupCount HB_UNUSED,
2048
                 const LookupRecord lookupRecord[] HB_UNUSED,
2049
                 const ContextApplyLookupContext &lookup_context)
2050
0
{
2051
0
  return would_match_input (c,
2052
0
          inputCount, input,
2053
0
          lookup_context.funcs.match, lookup_context.match_data);
2054
0
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-face.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
2055
2056
template <typename HBUINT>
2057
static inline bool context_apply_lookup (hb_ot_apply_context_t *c,
2058
           unsigned int inputCount, /* Including the first glyph (not matched) */
2059
           const HBUINT input[], /* Array of input values--start with second glyph */
2060
           unsigned int lookupCount,
2061
           const LookupRecord lookupRecord[],
2062
           const ContextApplyLookupContext &lookup_context)
2063
0
{
2064
0
  if (unlikely (inputCount > HB_MAX_CONTEXT_LENGTH)) return false;
2065
2066
0
  unsigned match_end = 0;
2067
0
  bool ret = false;
2068
0
  if (match_input (c,
2069
0
       inputCount, input,
2070
0
       lookup_context.funcs.match, lookup_context.match_data,
2071
0
       &match_end))
2072
0
  {
2073
0
    c->buffer->unsafe_to_break (c->buffer->idx, match_end);
2074
0
    apply_lookup (c,
2075
0
      inputCount,
2076
0
      lookupCount, lookupRecord,
2077
0
      match_end);
2078
0
    ret = true;
2079
0
  }
2080
0
  else
2081
0
  {
2082
0
    c->buffer->unsafe_to_concat (c->buffer->idx, match_end);
2083
0
    ret = false;
2084
0
  }
2085
2086
0
  return ret;
2087
0
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-face.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ContextApplyLookupContext const&)
2088
2089
static inline bool context_cache_func (hb_ot_apply_context_t *c, hb_ot_subtable_cache_op_t op)
2090
0
{
2091
0
  switch (op)
2092
0
  {
2093
0
    case hb_ot_subtable_cache_op_t::ENTER:
2094
0
    {
2095
0
      if (!HB_BUFFER_TRY_ALLOCATE_VAR (c->buffer, syllable))
2096
0
  return false;
2097
0
      auto &info = c->buffer->info;
2098
0
      unsigned count = c->buffer->len;
2099
0
      for (unsigned i = 0; i < count; i++)
2100
0
  info[i].syllable() = 255;
2101
0
      c->new_syllables = 255;
2102
0
      return true;
2103
0
    }
2104
0
    case hb_ot_subtable_cache_op_t::LEAVE:
2105
0
    {
2106
0
      c->new_syllables = (unsigned) -1;
2107
0
      HB_BUFFER_DEALLOCATE_VAR (c->buffer, syllable);
2108
0
      break;
2109
0
    }
2110
0
  }
2111
0
  return false;
2112
0
}
Unexecuted instantiation: hb-aat-layout.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-ot-face.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-ot-layout.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-subset.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-subset-plan-layout.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-subset-table-layout.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-subset-table-var.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-subset-table-color.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: hb-subset-table-other.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
Unexecuted instantiation: gsubgpos-context.cc:OT::context_cache_func(OT::hb_ot_apply_context_t*, OT::hb_ot_subtable_cache_op_t)
2113
2114
template <typename Types>
2115
struct Rule
2116
{
2117
  template <typename T>
2118
  friend struct RuleSet;
2119
2120
  bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const
2121
0
  {
2122
0
    return context_intersects (glyphs,
2123
0
             inputCount, inputZ.arrayZ,
2124
0
             lookup_context);
2125
0
  }
2126
2127
  void closure (hb_closure_context_t *c, unsigned value, ContextClosureLookupContext &lookup_context) const
2128
0
  {
2129
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
2130
2131
0
    const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>>
2132
0
             (inputZ.as_array ((inputCount ? inputCount - 1 : 0)));
2133
0
    context_closure_lookup (c,
2134
0
          inputCount, inputZ.arrayZ,
2135
0
          lookupCount, lookupRecord.arrayZ,
2136
0
          value, lookup_context);
2137
0
  }
2138
2139
  void closure_lookups (hb_closure_lookups_context_t *c,
2140
                        ContextClosureLookupContext &lookup_context) const
2141
0
  {
2142
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
2143
0
    if (!intersects (c->glyphs, lookup_context)) return;
2144
2145
0
    const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>>
2146
0
             (inputZ.as_array (inputCount ? inputCount - 1 : 0));
2147
0
    recurse_lookups (c, lookupCount, lookupRecord.arrayZ);
2148
0
  }
2149
2150
  void collect_glyphs (hb_collect_glyphs_context_t *c,
2151
           ContextCollectGlyphsLookupContext &lookup_context) const
2152
0
  {
2153
0
    const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>>
2154
0
             (inputZ.as_array (inputCount ? inputCount - 1 : 0));
2155
0
    context_collect_glyphs_lookup (c,
2156
0
           inputCount, inputZ.arrayZ,
2157
0
           lookupCount, lookupRecord.arrayZ,
2158
0
           lookup_context);
2159
0
  }
2160
2161
  bool would_apply (hb_would_apply_context_t *c,
2162
        const ContextApplyLookupContext &lookup_context) const
2163
0
  {
2164
0
    const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>>
2165
0
             (inputZ.as_array (inputCount ? inputCount - 1 : 0));
2166
0
    return context_would_apply_lookup (c,
2167
0
               inputCount, inputZ.arrayZ,
2168
0
               lookupCount, lookupRecord.arrayZ,
2169
0
               lookup_context);
2170
0
  }
2171
2172
  bool apply (hb_ot_apply_context_t *c,
2173
        const ContextApplyLookupContext &lookup_context) const
2174
0
  {
2175
0
    TRACE_APPLY (this);
2176
0
    const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>>
2177
0
             (inputZ.as_array (inputCount ? inputCount - 1 : 0));
2178
0
    return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context));
2179
0
  }
2180
2181
  bool serialize (hb_serialize_context_t *c,
2182
      const hb_map_t *input_mapping, /* old->new glyphid or class mapping */
2183
      const hb_map_t *lookup_map) const
2184
0
  {
2185
0
    TRACE_SERIALIZE (this);
2186
0
    auto *out = c->start_embed (this);
2187
0
    if (unlikely (!c->extend_min (out))) return_trace (false);
2188
2189
0
    out->inputCount = inputCount;
2190
0
    const auto input = inputZ.as_array (inputCount - 1);
2191
0
    for (const auto org : input)
2192
0
    {
2193
0
      HBUINT16 d;
2194
0
      d = input_mapping->get (org);
2195
0
      c->copy (d);
2196
0
    }
2197
2198
0
    const auto &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>>
2199
0
             (inputZ.as_array ((inputCount ? inputCount - 1 : 0)));
2200
2201
0
    unsigned count = serialize_lookuprecord_array (c, lookupRecord.as_array (lookupCount), lookup_map);
2202
0
    return_trace (c->check_assign (out->lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW));
2203
0
  }
2204
2205
  bool subset (hb_subset_context_t *c,
2206
         const hb_map_t *lookup_map,
2207
         const hb_map_t *klass_map = nullptr) const
2208
0
  {
2209
0
    TRACE_SUBSET (this);
2210
0
    if (unlikely (!inputCount)) return_trace (false);
2211
0
    const auto input = inputZ.as_array (inputCount - 1);
2212
2213
0
    const hb_map_t *mapping = klass_map == nullptr ? c->plan->glyph_map : klass_map;
2214
0
    if (!hb_all (input, mapping)) return_trace (false);
2215
0
    return_trace (serialize (c->serializer, mapping, lookup_map));
2216
0
  }
2217
2218
  public:
2219
  bool sanitize (hb_sanitize_context_t *c) const
2220
0
  {
2221
0
    TRACE_SANITIZE (this);
2222
0
    return_trace (c->check_struct (this) &&
2223
0
      hb_barrier () &&
2224
0
      c->check_range (inputZ.arrayZ,
2225
0
          inputZ.item_size * (inputCount ? inputCount - 1 : 0) +
2226
0
          LookupRecord::static_size * lookupCount));
2227
0
  }
2228
2229
  protected:
2230
  HBUINT16  inputCount;   /* Total number of glyphs in input
2231
           * glyph sequence--includes the first
2232
           * glyph */
2233
  HBUINT16  lookupCount;    /* Number of LookupRecords */
2234
  UnsizedArrayOf<typename Types::HBUINT>
2235
    inputZ;     /* Array of match inputs--start with
2236
           * second glyph */
2237
/*UnsizedArrayOf<LookupRecord>
2238
    lookupRecordX;*/  /* Array of LookupRecords--in
2239
           * design order */
2240
  public:
2241
  DEFINE_SIZE_ARRAY (4, inputZ);
2242
};
2243
2244
template <typename Types>
2245
struct RuleSet
2246
{
2247
  using Rule = OT::Rule<Types>;
2248
2249
  bool intersects (const hb_set_t *glyphs,
2250
       ContextClosureLookupContext &lookup_context) const
2251
0
  {
2252
0
    return
2253
0
    + hb_iter (rule)
2254
0
    | hb_map (hb_add (this))
2255
0
    | hb_map ([&] (const Rule &_) { return _.intersects (glyphs, lookup_context); })
2256
0
    | hb_any
2257
0
    ;
2258
0
  }
2259
2260
  void closure (hb_closure_context_t *c, unsigned value,
2261
    ContextClosureLookupContext &lookup_context) const
2262
0
  {
2263
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
2264
2265
0
    return
2266
0
    + hb_iter (rule)
2267
0
    | hb_map (hb_add (this))
2268
0
    | hb_apply ([&] (const Rule &_) { _.closure (c, value, lookup_context); })
2269
0
    ;
2270
0
  }
2271
2272
  void closure_lookups (hb_closure_lookups_context_t *c,
2273
                        ContextClosureLookupContext &lookup_context) const
2274
0
  {
2275
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
2276
0
    + hb_iter (rule)
2277
0
    | hb_map (hb_add (this))
2278
0
    | hb_apply ([&] (const Rule &_) { _.closure_lookups (c, lookup_context); })
2279
0
    ;
2280
0
  }
2281
2282
  void collect_glyphs (hb_collect_glyphs_context_t *c,
2283
           ContextCollectGlyphsLookupContext &lookup_context) const
2284
0
  {
2285
0
    return
2286
0
    + hb_iter (rule)
2287
0
    | hb_map (hb_add (this))
2288
0
    | hb_apply ([&] (const Rule &_) { _.collect_glyphs (c, lookup_context); })
2289
0
    ;
2290
0
  }
2291
2292
  bool would_apply (hb_would_apply_context_t *c,
2293
        const ContextApplyLookupContext &lookup_context) const
2294
0
  {
2295
0
    return
2296
0
    + hb_iter (rule)
2297
0
    | hb_map (hb_add (this))
2298
0
    | hb_map ([&] (const Rule &_) { return _.would_apply (c, lookup_context); })
2299
0
    | hb_any
2300
0
    ;
2301
0
  }
2302
2303
  bool apply (hb_ot_apply_context_t *c,
2304
        const ContextApplyLookupContext &lookup_context) const
2305
0
  {
2306
0
    TRACE_APPLY (this);
2307
2308
0
    unsigned num_rules = rule.len;
2309
2310
0
#ifndef HB_NO_OT_RULESETS_FAST_PATH
2311
0
    if (HB_OPTIMIZE_SIZE_VAL || num_rules <= 4)
2312
0
#endif
2313
0
    {
2314
0
    slow:
2315
0
      return_trace (
2316
0
      + hb_iter (rule)
2317
0
      | hb_map (hb_add (this))
2318
0
      | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); })
2319
0
      | hb_any
2320
0
      )
2321
0
      ;
2322
0
    }
2323
2324
    /* This version is optimized for speed by matching the first & second
2325
     * components of the rule here, instead of calling into the matching code.
2326
     *
2327
     * Replicated from LigatureSet::apply(). */
2328
2329
    /* We use the iter_context instead of iter_input, to avoid skipping
2330
     * default-ignorables and such.
2331
     *
2332
     * Related: https://github.com/harfbuzz/harfbuzz/issues/4813
2333
     */
2334
0
    auto &skippy_iter = c->iter_context;
2335
0
    skippy_iter.reset (c->buffer->idx);
2336
0
    skippy_iter.set_match_func (match_always, nullptr);
2337
0
    skippy_iter.set_glyph_data ((HBUINT16 *) nullptr);
2338
0
    unsigned unsafe_to = (unsigned) -1, unsafe_to1, unsafe_to2 = 0;
2339
0
    hb_glyph_info_t *first = nullptr, *second = nullptr;
2340
0
    bool matched = skippy_iter.next ();
2341
0
    if (likely (matched))
2342
0
    {
2343
0
      if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))
2344
0
      {
2345
  /* Can't use the fast path if eg. the next char is a default-ignorable
2346
   * or other skippable. */
2347
0
        goto slow;
2348
0
      }
2349
2350
0
      first = &c->buffer->info[skippy_iter.idx];
2351
0
      unsafe_to1 = skippy_iter.idx + 1;
2352
0
    }
2353
0
    else
2354
0
    {
2355
      /* Failed to match a next glyph. Only try applying rules that have
2356
       * no further input. */
2357
0
      return_trace (
2358
0
      + hb_iter (rule)
2359
0
      | hb_map (hb_add (this))
2360
0
      | hb_filter ([&] (const Rule &_) { return _.inputCount <= 1; })
2361
0
      | hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); })
2362
0
      | hb_any
2363
0
      )
2364
0
      ;
2365
0
    }
2366
0
    matched = skippy_iter.next ();
2367
0
    if (likely (matched))
2368
0
    {
2369
0
      if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))
2370
0
      {
2371
  /* Can't use the fast path if eg. the next char is a default-ignorable
2372
   * or other skippable. */
2373
0
        goto slow;
2374
0
      }
2375
2376
0
      second = &c->buffer->info[skippy_iter.idx];
2377
0
      unsafe_to2 = skippy_iter.idx + 1;
2378
0
    }
2379
2380
0
    auto match_input = lookup_context.funcs.match;
2381
0
    auto *input_data = lookup_context.match_data;
2382
0
    for (unsigned int i = 0; i < num_rules; i++)
2383
0
    {
2384
0
      const auto &r = this+rule.arrayZ[i];
2385
2386
0
      const auto &input = r.inputZ;
2387
2388
0
      if (r.inputCount <= 1 ||
2389
0
    (!match_input ||
2390
0
     match_input (*first, input.arrayZ[0], input_data)))
2391
0
      {
2392
0
        if (!second ||
2393
0
      (r.inputCount <= 2 ||
2394
0
       (!match_input ||
2395
0
        match_input (*second, input.arrayZ[1], input_data)))
2396
0
     )
2397
0
  {
2398
0
    if (r.apply (c, lookup_context))
2399
0
    {
2400
0
      if (unsafe_to != (unsigned) -1)
2401
0
        c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to);
2402
0
      return_trace (true);
2403
0
    }
2404
0
  }
2405
0
  else
2406
0
    unsafe_to = unsafe_to2;
2407
0
      }
2408
0
      else
2409
0
      {
2410
0
  if (unsafe_to == (unsigned) -1)
2411
0
    unsafe_to = unsafe_to1;
2412
2413
  // Skip ahead to next possible first glyph match.
2414
0
  for (; i + 1 < num_rules; i++)
2415
0
  {
2416
0
    const auto &r2 = this+rule.arrayZ[i + 1];
2417
0
    const auto &input2 = r2.inputZ;
2418
0
    if (r2.inputCount <= 1 || input2.arrayZ[0] != input.arrayZ[0])
2419
0
      break;
2420
0
  }
2421
0
      }
2422
0
    }
2423
0
    if (likely (unsafe_to != (unsigned) -1))
2424
0
      c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to);
2425
2426
0
    return_trace (false);
2427
0
  }
2428
2429
  bool subset (hb_subset_context_t *c,
2430
         const hb_map_t *lookup_map,
2431
         const hb_map_t *klass_map = nullptr) const
2432
0
  {
2433
0
    TRACE_SUBSET (this);
2434
2435
0
    auto snap = c->serializer->snapshot ();
2436
0
    auto *out = c->serializer->start_embed (*this);
2437
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
2438
2439
0
    for (const Offset16To<Rule>& _ : rule)
2440
0
    {
2441
0
      if (!_) continue;
2442
0
      auto o_snap = c->serializer->snapshot ();
2443
0
      auto *o = out->rule.serialize_append (c->serializer);
2444
0
      if (unlikely (!o)) continue;
2445
2446
0
      if (!o->serialize_subset (c, _, this, lookup_map, klass_map))
2447
0
      {
2448
0
  out->rule.pop ();
2449
0
  c->serializer->revert (o_snap);
2450
0
      }
2451
0
    }
2452
2453
0
    bool ret = bool (out->rule);
2454
0
    if (!ret) c->serializer->revert (snap);
2455
2456
0
    return_trace (ret);
2457
0
  }
2458
2459
  bool sanitize (hb_sanitize_context_t *c) const
2460
0
  {
2461
0
    TRACE_SANITIZE (this);
2462
0
    return_trace (rule.sanitize (c, this));
2463
0
  }
2464
2465
  protected:
2466
  Array16OfOffset16To<Rule>
2467
    rule;     /* Array of Rule tables
2468
           * ordered by preference */
2469
  public:
2470
  DEFINE_SIZE_ARRAY (2, rule);
2471
};
2472
2473
2474
template <typename Types>
2475
struct ContextFormat1_4
2476
{
2477
  using RuleSet = OT::RuleSet<Types>;
2478
2479
  bool intersects (const hb_set_t *glyphs) const
2480
0
  {
2481
0
    struct ContextClosureLookupContext lookup_context = {
2482
0
      {intersects_glyph, intersected_glyph},
2483
0
      ContextFormat::SimpleContext,
2484
0
      nullptr
2485
0
    };
2486
2487
0
    return
2488
0
    + hb_zip (this+coverage, ruleSet)
2489
0
    | hb_filter (*glyphs, hb_first)
2490
0
    | hb_map (hb_second)
2491
0
    | hb_map (hb_add (this))
2492
0
    | hb_map ([&] (const RuleSet &_) { return _.intersects (glyphs, lookup_context); })
2493
0
    | hb_any
2494
0
    ;
2495
0
  }
2496
2497
  bool may_have_non_1to1 () const
2498
0
  { return true; }
2499
2500
  void closure (hb_closure_context_t *c) const
2501
0
  {
2502
0
    hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs ();
2503
0
    if (unlikely (!cur_active_glyphs)) return;
2504
0
    get_coverage ().intersect_set (c->previous_parent_active_glyphs (), *cur_active_glyphs);
2505
2506
0
    struct ContextClosureLookupContext lookup_context = {
2507
0
      {intersects_glyph, intersected_glyph},
2508
0
      ContextFormat::SimpleContext,
2509
0
      nullptr
2510
0
    };
2511
2512
0
    + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len))
2513
0
    | hb_filter ([&] (hb_codepoint_t _) {
2514
0
      return c->previous_parent_active_glyphs ().has (_);
2515
0
    }, hb_first)
2516
0
    | hb_map ([&](const hb_pair_t<hb_codepoint_t, unsigned> _) { return hb_pair_t<unsigned, const RuleSet&> (_.first, this+ruleSet[_.second]); })
2517
0
    | hb_apply ([&] (const hb_pair_t<unsigned, const RuleSet&>& _) { _.second.closure (c, _.first, lookup_context); })
2518
0
    ;
2519
2520
0
    c->pop_cur_done_glyphs ();
2521
0
  }
2522
2523
  void closure_lookups (hb_closure_lookups_context_t *c) const
2524
0
  {
2525
0
    struct ContextClosureLookupContext lookup_context = {
2526
0
      {intersects_glyph, nullptr},
2527
0
      ContextFormat::SimpleContext,
2528
0
      nullptr
2529
0
    };
2530
2531
0
    + hb_zip (this+coverage, ruleSet)
2532
0
    | hb_filter (*c->glyphs, hb_first)
2533
0
    | hb_map (hb_second)
2534
0
    | hb_map (hb_add (this))
2535
0
    | hb_apply ([&] (const RuleSet &_) { _.closure_lookups (c, lookup_context); })
2536
0
    ;
2537
0
  }
2538
2539
0
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {}
2540
2541
  void collect_glyphs (hb_collect_glyphs_context_t *c) const
2542
0
  {
2543
0
    (this+coverage).collect_coverage (c->input);
2544
2545
0
    struct ContextCollectGlyphsLookupContext lookup_context = {
2546
0
      {collect_glyph},
2547
0
      nullptr
2548
0
    };
2549
2550
0
    + hb_iter (ruleSet)
2551
0
    | hb_map (hb_add (this))
2552
0
    | hb_apply ([&] (const RuleSet &_) { _.collect_glyphs (c, lookup_context); })
2553
0
    ;
2554
0
  }
2555
2556
  bool would_apply (hb_would_apply_context_t *c) const
2557
0
  {
2558
0
    const RuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyphs[0])];
2559
0
    struct ContextApplyLookupContext lookup_context = {
2560
0
      {match_glyph},
2561
0
      nullptr
2562
0
    };
2563
0
    return rule_set.would_apply (c, lookup_context);
2564
0
  }
2565
2566
0
  const Coverage &get_coverage () const { return this+coverage; }
2567
2568
  bool apply (hb_ot_apply_context_t *c) const
2569
0
  {
2570
0
    TRACE_APPLY (this);
2571
0
    unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
2572
0
    if (likely (index == NOT_COVERED))
2573
0
      return_trace (false);
2574
2575
0
    const RuleSet &rule_set = this+ruleSet[index];
2576
0
    struct ContextApplyLookupContext lookup_context = {
2577
0
      {match_glyph},
2578
0
      nullptr
2579
0
    };
2580
0
    return_trace (rule_set.apply (c, lookup_context));
2581
0
  }
2582
2583
  bool subset (hb_subset_context_t *c) const
2584
0
  {
2585
0
    TRACE_SUBSET (this);
2586
0
    const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
2587
0
    const hb_map_t &glyph_map = *c->plan->glyph_map;
2588
2589
0
    auto *out = c->serializer->start_embed (*this);
2590
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
2591
0
    out->format = format;
2592
2593
0
    const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
2594
0
    hb_sorted_vector_t<hb_codepoint_t> new_coverage;
2595
0
    + hb_zip (this+coverage, ruleSet)
2596
0
    | hb_filter (glyphset, hb_first)
2597
0
    | hb_filter (subset_offset_array (c, out->ruleSet, this, lookup_map), hb_second)
2598
0
    | hb_map (hb_first)
2599
0
    | hb_map (glyph_map)
2600
0
    | hb_sink (new_coverage)
2601
0
    ;
2602
2603
0
    out->coverage.serialize_serialize (c->serializer, new_coverage.iter ());
2604
0
    return_trace (bool (new_coverage));
2605
0
  }
2606
2607
  bool sanitize (hb_sanitize_context_t *c) const
2608
0
  {
2609
0
    TRACE_SANITIZE (this);
2610
0
    return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this));
2611
0
  }
2612
2613
  protected:
2614
  HBUINT16  format;     /* Format identifier--format = 1 */
2615
  typename Types::template OffsetTo<Coverage>
2616
    coverage;   /* Offset to Coverage table--from
2617
           * beginning of table */
2618
  Array16Of<typename Types::template OffsetTo<RuleSet>>
2619
    ruleSet;    /* Array of RuleSet tables
2620
           * ordered by Coverage Index */
2621
  public:
2622
  DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ruleSet);
2623
};
2624
2625
2626
template <typename Types>
2627
struct ContextFormat2_5
2628
{
2629
  using RuleSet = OT::RuleSet<SmallTypes>;
2630
2631
  bool intersects (const hb_set_t *glyphs) const
2632
0
  {
2633
0
    if (!(this+coverage).intersects (glyphs))
2634
0
      return false;
2635
2636
0
    const ClassDef &class_def = this+classDef;
2637
2638
0
    hb_map_t cache;
2639
0
    struct ContextClosureLookupContext lookup_context = {
2640
0
      {intersects_class, nullptr},
2641
0
      ContextFormat::ClassBasedContext,
2642
0
      &class_def,
2643
0
      &cache
2644
0
    };
2645
2646
0
    hb_set_t retained_coverage_glyphs;
2647
0
    (this+coverage).intersect_set (*glyphs, retained_coverage_glyphs);
2648
2649
0
    hb_set_t coverage_glyph_classes;
2650
0
    class_def.intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes);
2651
2652
2653
0
    return
2654
0
    + hb_iter (ruleSet)
2655
0
    | hb_map (hb_add (this))
2656
0
    | hb_enumerate
2657
0
    | hb_map ([&] (const hb_pair_t<unsigned, const RuleSet &> p)
2658
0
        { return class_def.intersects_class (glyphs, p.first) &&
2659
0
           coverage_glyph_classes.has (p.first) &&
2660
0
           p.second.intersects (glyphs, lookup_context); })
2661
0
    | hb_any
2662
0
    ;
2663
0
  }
2664
2665
  bool may_have_non_1to1 () const
2666
0
  { return true; }
2667
2668
  void closure (hb_closure_context_t *c) const
2669
0
  {
2670
0
    if (!(this+coverage).intersects (c->glyphs))
2671
0
      return;
2672
2673
0
    hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs ();
2674
0
    if (unlikely (!cur_active_glyphs)) return;
2675
0
    get_coverage ().intersect_set (c->previous_parent_active_glyphs (),
2676
0
           *cur_active_glyphs);
2677
2678
0
    const ClassDef &class_def = this+classDef;
2679
2680
0
    hb_map_t cache;
2681
0
    intersected_class_cache_t intersected_cache;
2682
0
    struct ContextClosureLookupContext lookup_context = {
2683
0
      {intersects_class, intersected_class_glyphs},
2684
0
      ContextFormat::ClassBasedContext,
2685
0
      &class_def,
2686
0
      &cache,
2687
0
      &intersected_cache
2688
0
    };
2689
2690
0
    + hb_enumerate (ruleSet)
2691
0
    | hb_filter ([&] (unsigned _)
2692
0
    { return class_def.intersects_class (&c->parent_active_glyphs (), _); },
2693
0
     hb_first)
2694
0
    | hb_apply ([&] (const hb_pair_t<unsigned, const typename Types::template OffsetTo<RuleSet>&> _)
2695
0
                {
2696
0
                  const RuleSet& rule_set = this+_.second;
2697
0
                  rule_set.closure (c, _.first, lookup_context);
2698
0
                })
2699
0
    ;
2700
2701
0
    c->pop_cur_done_glyphs ();
2702
0
  }
2703
2704
  void closure_lookups (hb_closure_lookups_context_t *c) const
2705
0
  {
2706
0
    if (!(this+coverage).intersects (c->glyphs))
2707
0
      return;
2708
2709
0
    const ClassDef &class_def = this+classDef;
2710
2711
0
    hb_map_t cache;
2712
0
    struct ContextClosureLookupContext lookup_context = {
2713
0
      {intersects_class, nullptr},
2714
0
      ContextFormat::ClassBasedContext,
2715
0
      &class_def,
2716
0
      &cache
2717
0
    };
2718
2719
0
    + hb_iter (ruleSet)
2720
0
    | hb_map (hb_add (this))
2721
0
    | hb_enumerate
2722
0
    | hb_filter ([&] (const hb_pair_t<unsigned, const RuleSet &> p)
2723
0
    { return class_def.intersects_class (c->glyphs, p.first); })
2724
0
    | hb_map (hb_second)
2725
0
    | hb_apply ([&] (const RuleSet & _)
2726
0
    { _.closure_lookups (c, lookup_context); });
2727
0
  }
2728
2729
0
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {}
2730
2731
  void collect_glyphs (hb_collect_glyphs_context_t *c) const
2732
0
  {
2733
0
    (this+coverage).collect_coverage (c->input);
2734
2735
0
    const ClassDef &class_def = this+classDef;
2736
0
    struct ContextCollectGlyphsLookupContext lookup_context = {
2737
0
      {collect_class},
2738
0
      &class_def
2739
0
    };
2740
2741
0
    + hb_iter (ruleSet)
2742
0
    | hb_map (hb_add (this))
2743
0
    | hb_apply ([&] (const RuleSet &_) { _.collect_glyphs (c, lookup_context); })
2744
0
    ;
2745
0
  }
2746
2747
  bool would_apply (hb_would_apply_context_t *c) const
2748
0
  {
2749
0
    const ClassDef &class_def = this+classDef;
2750
0
    unsigned int index = class_def.get_class (c->glyphs[0]);
2751
0
    const RuleSet &rule_set = this+ruleSet[index];
2752
0
    struct ContextApplyLookupContext lookup_context = {
2753
0
      {match_class},
2754
0
      &class_def
2755
0
    };
2756
0
    return rule_set.would_apply (c, lookup_context);
2757
0
  }
2758
2759
0
  const Coverage &get_coverage () const { return this+coverage; }
2760
2761
  unsigned cache_cost () const
2762
0
  {
2763
0
    return (this+classDef).cost ();
2764
0
  }
2765
  static bool cache_func (hb_ot_apply_context_t *c, hb_ot_subtable_cache_op_t op)
2766
0
  {
2767
0
    return context_cache_func (c, op);
2768
0
  }
2769
2770
  struct external_cache_t
2771
  {
2772
    hb_ot_layout_binary_cache_t coverage;
2773
  };
2774
  void *external_cache_create () const
2775
0
  {
2776
0
    external_cache_t *cache = (external_cache_t *) hb_malloc (sizeof (external_cache_t));
2777
0
    if (likely (cache))
2778
0
    {
2779
0
      cache->coverage.clear ();
2780
0
    }
2781
0
    return cache;
2782
0
  }
2783
0
  bool apply_cached (hb_ot_apply_context_t *c, void *external_cache) const { return _apply (c, true, external_cache); }
2784
0
  bool apply (hb_ot_apply_context_t *c, void *external_cache) const { return _apply (c, false, external_cache); }
2785
  bool _apply (hb_ot_apply_context_t *c, bool cached, void *external_cache) const
2786
0
  {
2787
0
    TRACE_APPLY (this);
2788
0
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
2789
0
    external_cache_t *cache = (external_cache_t *) external_cache;
2790
0
    unsigned int index = (this+coverage).get_coverage_binary (c->buffer->cur().codepoint, cache ? &cache->coverage : nullptr);
2791
#else
2792
    unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
2793
#endif
2794
0
    if (index == NOT_COVERED) return_trace (false);
2795
2796
0
    const ClassDef &class_def = this+classDef;
2797
2798
0
    struct ContextApplyLookupContext lookup_context = {
2799
0
      {cached ? match_class_cached : match_class},
2800
0
      &class_def
2801
0
    };
2802
2803
0
    index = cached ? get_class_cached (class_def, c->buffer->cur()) : class_def.get_class (c->buffer->cur().codepoint);
2804
0
    const RuleSet &rule_set = this+ruleSet[index];
2805
0
    return_trace (rule_set.apply (c, lookup_context));
2806
0
  }
2807
2808
  bool subset (hb_subset_context_t *c) const
2809
0
  {
2810
0
    TRACE_SUBSET (this);
2811
0
    auto *out = c->serializer->start_embed (*this);
2812
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
2813
0
    out->format = format;
2814
0
    if (unlikely (!out->coverage.serialize_subset (c, coverage, this)))
2815
0
      return_trace (false);
2816
2817
0
    hb_map_t klass_map;
2818
0
    out->classDef.serialize_subset (c, classDef, this, &klass_map);
2819
2820
0
    const hb_set_t* glyphset = c->plan->glyphset_gsub ();
2821
0
    hb_set_t retained_coverage_glyphs;
2822
0
    (this+coverage).intersect_set (*glyphset, retained_coverage_glyphs);
2823
2824
0
    hb_set_t coverage_glyph_classes;
2825
0
    (this+classDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes);
2826
2827
0
    const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
2828
0
    bool ret = true;
2829
0
    int non_zero_index = -1, index = 0;
2830
0
    auto snapshot = c->serializer->snapshot();
2831
0
    for (const auto& _ : + hb_enumerate (ruleSet)
2832
0
       | hb_filter (klass_map, hb_first))
2833
0
    {
2834
0
      auto *o = out->ruleSet.serialize_append (c->serializer);
2835
0
      if (unlikely (!o))
2836
0
      {
2837
0
  ret = false;
2838
0
  break;
2839
0
      }
2840
2841
0
      if (coverage_glyph_classes.has (_.first) &&
2842
0
    o->serialize_subset (c, _.second, this, lookup_map, &klass_map)) {
2843
0
  non_zero_index = index;
2844
0
        snapshot = c->serializer->snapshot();
2845
0
      }
2846
2847
0
      index++;
2848
0
    }
2849
2850
0
    if (!ret || non_zero_index == -1) return_trace (false);
2851
2852
    //prune empty trailing ruleSets
2853
0
    --index;
2854
0
    while (index > non_zero_index)
2855
0
    {
2856
0
      out->ruleSet.pop ();
2857
0
      index--;
2858
0
    }
2859
0
    c->serializer->revert (snapshot);
2860
2861
0
    return_trace (bool (out->ruleSet));
2862
0
  }
2863
2864
  bool sanitize (hb_sanitize_context_t *c) const
2865
0
  {
2866
0
    TRACE_SANITIZE (this);
2867
0
    return_trace (coverage.sanitize (c, this) && classDef.sanitize (c, this) && ruleSet.sanitize (c, this));
2868
0
  }
2869
2870
  protected:
2871
  HBUINT16  format;     /* Format identifier--format = 2 */
2872
  typename Types::template OffsetTo<Coverage>
2873
    coverage;   /* Offset to Coverage table--from
2874
           * beginning of table */
2875
  typename Types::template OffsetTo<ClassDef>
2876
    classDef;   /* Offset to glyph ClassDef table--from
2877
           * beginning of table */
2878
  Array16Of<typename Types::template OffsetTo<RuleSet>>
2879
    ruleSet;    /* Array of RuleSet tables
2880
           * ordered by class */
2881
  public:
2882
  DEFINE_SIZE_ARRAY (4 + 2 * Types::size, ruleSet);
2883
};
2884
2885
2886
struct ContextFormat3
2887
{
2888
  using RuleSet = OT::RuleSet<SmallTypes>;
2889
2890
  bool intersects (const hb_set_t *glyphs) const
2891
0
  {
2892
0
    if (!(this+coverageZ[0]).intersects (glyphs))
2893
0
      return false;
2894
2895
0
    struct ContextClosureLookupContext lookup_context = {
2896
0
      {intersects_coverage, nullptr},
2897
0
      ContextFormat::CoverageBasedContext,
2898
0
      this
2899
0
    };
2900
0
    return context_intersects (glyphs,
2901
0
             glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1),
2902
0
             lookup_context);
2903
0
  }
2904
2905
  bool may_have_non_1to1 () const
2906
0
  { return true; }
2907
2908
  void closure (hb_closure_context_t *c) const
2909
0
  {
2910
0
    if (!(this+coverageZ[0]).intersects (c->glyphs))
2911
0
      return;
2912
2913
0
    hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs ();
2914
0
    if (unlikely (!cur_active_glyphs)) return;
2915
0
    get_coverage ().intersect_set (c->previous_parent_active_glyphs (),
2916
0
           *cur_active_glyphs);
2917
2918
0
    const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
2919
0
    struct ContextClosureLookupContext lookup_context = {
2920
0
      {intersects_coverage, intersected_coverage_glyphs},
2921
0
      ContextFormat::CoverageBasedContext,
2922
0
      this
2923
0
    };
2924
0
    context_closure_lookup (c,
2925
0
          glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1),
2926
0
          lookupCount, lookupRecord,
2927
0
          0, lookup_context);
2928
2929
0
    c->pop_cur_done_glyphs ();
2930
0
  }
2931
2932
  void closure_lookups (hb_closure_lookups_context_t *c) const
2933
0
  {
2934
0
    if (!intersects (c->glyphs))
2935
0
      return;
2936
0
    const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
2937
0
    recurse_lookups (c, lookupCount, lookupRecord);
2938
0
  }
2939
2940
0
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {}
2941
2942
  void collect_glyphs (hb_collect_glyphs_context_t *c) const
2943
0
  {
2944
0
    (this+coverageZ[0]).collect_coverage (c->input);
2945
2946
0
    const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
2947
0
    struct ContextCollectGlyphsLookupContext lookup_context = {
2948
0
      {collect_coverage},
2949
0
      this
2950
0
    };
2951
2952
0
    context_collect_glyphs_lookup (c,
2953
0
           glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1),
2954
0
           lookupCount, lookupRecord,
2955
0
           lookup_context);
2956
0
  }
2957
2958
  bool would_apply (hb_would_apply_context_t *c) const
2959
0
  {
2960
0
    const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
2961
0
    struct ContextApplyLookupContext lookup_context = {
2962
0
      {match_coverage},
2963
0
      this
2964
0
    };
2965
0
    return context_would_apply_lookup (c,
2966
0
               glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1),
2967
0
               lookupCount, lookupRecord,
2968
0
               lookup_context);
2969
0
  }
2970
2971
0
  const Coverage &get_coverage () const { return this+coverageZ[0]; }
2972
2973
  bool apply (hb_ot_apply_context_t *c) const
2974
0
  {
2975
0
    TRACE_APPLY (this);
2976
0
    unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint);
2977
0
    if (index == NOT_COVERED) return_trace (false);
2978
2979
0
    const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
2980
0
    struct ContextApplyLookupContext lookup_context = {
2981
0
      {match_coverage},
2982
0
      this
2983
0
    };
2984
0
    return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context));
2985
0
  }
2986
2987
  bool subset (hb_subset_context_t *c) const
2988
0
  {
2989
0
    TRACE_SUBSET (this);
2990
0
    auto *out = c->serializer->start_embed (this);
2991
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
2992
2993
0
    out->format = format;
2994
0
    out->glyphCount = glyphCount;
2995
2996
0
    auto coverages = coverageZ.as_array (glyphCount);
2997
2998
0
    for (const Offset16To<Coverage>& offset : coverages)
2999
0
    {
3000
      /* TODO(subset) This looks like should not be necessary to write this way. */
3001
0
      auto *o = c->serializer->allocate_size<Offset16To<Coverage>> (Offset16To<Coverage>::static_size);
3002
0
      if (unlikely (!o)) return_trace (false);
3003
0
      if (!o->serialize_subset (c, offset, this)) return_trace (false);
3004
0
    }
3005
3006
0
    const auto& lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> (coverageZ.as_array (glyphCount));
3007
0
    const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
3008
3009
3010
0
    unsigned count = serialize_lookuprecord_array (c->serializer, lookupRecord.as_array (lookupCount), lookup_map);
3011
0
    return_trace (c->serializer->check_assign (out->lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW));
3012
0
  }
3013
3014
  bool sanitize (hb_sanitize_context_t *c) const
3015
0
  {
3016
0
    TRACE_SANITIZE (this);
3017
0
    if (unlikely (!c->check_struct (this))) return_trace (false);
3018
0
    hb_barrier ();
3019
0
    unsigned int count = glyphCount;
3020
0
    if (unlikely (!count)) return_trace (false); /* We want to access coverageZ[0] freely. */
3021
0
    if (unlikely (!c->check_array (coverageZ.arrayZ, count))) return_trace (false);
3022
0
    for (unsigned int i = 0; i < count; i++)
3023
0
      if (unlikely (!coverageZ[i].sanitize (c, this))) return_trace (false);
3024
0
    const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
3025
0
    return_trace (likely (c->check_array (lookupRecord, lookupCount)));
3026
0
  }
3027
3028
  protected:
3029
  HBUINT16  format;     /* Format identifier--format = 3 */
3030
  HBUINT16  glyphCount;   /* Number of glyphs in the input glyph
3031
           * sequence */
3032
  HBUINT16  lookupCount;    /* Number of LookupRecords */
3033
  UnsizedArrayOf<Offset16To<Coverage>>
3034
    coverageZ;    /* Array of offsets to Coverage
3035
           * table in glyph sequence order */
3036
/*UnsizedArrayOf<LookupRecord>
3037
    lookupRecordX;*/  /* Array of LookupRecords--in
3038
           * design order */
3039
  public:
3040
  DEFINE_SIZE_ARRAY (6, coverageZ);
3041
};
3042
3043
struct Context
3044
{
3045
  template <typename context_t, typename ...Ts>
3046
  typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
3047
0
  {
3048
0
    if (unlikely (!c->may_dispatch (this, &u.format.v))) return c->no_dispatch_return_value ();
3049
0
    TRACE_DISPATCH (this, u.format.v);
3050
0
    switch (u.format.v) {
3051
0
    case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
3052
0
    case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
3053
0
    case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
3054
#ifndef HB_NO_BEYOND_64K
3055
    case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...));
3056
    case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...));
3057
#endif
3058
0
    default:return_trace (c->default_return_value ());
3059
0
    }
3060
0
  }
Unexecuted instantiation: hb_sanitize_context_t::return_t OT::Context::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Context::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::Context::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Context::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Context::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: hb_subset_context_t::return_t OT::Context::dispatch<hb_subset_context_t>(hb_subset_context_t*) const
Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::Context::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const
Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::Context::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const
Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::Context::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const
Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::Context::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const
Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::Context::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const
Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::Context::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const
Unexecuted instantiation: hb_collect_glyph_alternates_dispatch_t::return_t OT::Context::dispatch<hb_collect_glyph_alternates_dispatch_t, hb_map_t*&, hb_map_t*&>(hb_collect_glyph_alternates_dispatch_t*, hb_map_t*&, hb_map_t*&) const
Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::Context::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const
3061
3062
  protected:
3063
  union {
3064
  struct { HBUINT16 v; }  format;   /* Format identifier */
3065
  ContextFormat1_4<SmallTypes>  format1;
3066
  ContextFormat2_5<SmallTypes>  format2;
3067
  ContextFormat3    format3;
3068
#ifndef HB_NO_BEYOND_64K
3069
  ContextFormat1_4<MediumTypes> format4;
3070
  ContextFormat2_5<MediumTypes> format5;
3071
#endif
3072
  } u;
3073
};
3074
3075
3076
/* Chaining Contextual lookups */
3077
3078
struct ChainContextClosureLookupContext
3079
{
3080
  ContextClosureFuncs funcs;
3081
  ContextFormat context_format;
3082
  const void *intersects_data[3];
3083
  void *intersects_cache[3];
3084
  void *intersected_glyphs_cache;
3085
};
3086
3087
struct ChainContextCollectGlyphsLookupContext
3088
{
3089
  ContextCollectGlyphsFuncs funcs;
3090
  const void *collect_data[3];
3091
};
3092
3093
struct ChainContextApplyLookupContext
3094
{
3095
  ChainContextApplyFuncs funcs;
3096
  const void *match_data[3];
3097
};
3098
3099
template <typename HBUINT>
3100
static inline bool chain_context_intersects (const hb_set_t *glyphs,
3101
               unsigned int backtrackCount,
3102
               const HBUINT backtrack[],
3103
               unsigned int inputCount, /* Including the first glyph (not matched) */
3104
               const HBUINT input[], /* Array of input values--start with second glyph */
3105
               unsigned int lookaheadCount,
3106
               const HBUINT lookahead[],
3107
               ChainContextClosureLookupContext &lookup_context)
3108
0
{
3109
0
  return array_is_subset_of (glyphs,
3110
0
           backtrackCount, backtrack,
3111
0
           lookup_context.funcs.intersects,
3112
0
           lookup_context.intersects_data[0],
3113
0
           lookup_context.intersects_cache[0])
3114
0
      && array_is_subset_of (glyphs,
3115
0
           inputCount ? inputCount - 1 : 0, input,
3116
0
           lookup_context.funcs.intersects,
3117
0
           lookup_context.intersects_data[1],
3118
0
           lookup_context.intersects_cache[1])
3119
0
      && array_is_subset_of (glyphs,
3120
0
           lookaheadCount, lookahead,
3121
0
           lookup_context.funcs.intersects,
3122
0
           lookup_context.intersects_data[2],
3123
0
           lookup_context.intersects_cache[2]);
3124
0
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-face.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::chain_context_intersects<OT::NumType<true, unsigned short, 2u> >(hb_set_t const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, OT::ChainContextClosureLookupContext&)
3125
3126
template <typename HBUINT>
3127
static inline void chain_context_closure_lookup (hb_closure_context_t *c,
3128
             unsigned int backtrackCount,
3129
             const HBUINT backtrack[],
3130
             unsigned int inputCount, /* Including the first glyph (not matched) */
3131
             const HBUINT input[], /* Array of input values--start with second glyph */
3132
             unsigned int lookaheadCount,
3133
             const HBUINT lookahead[],
3134
             unsigned int lookupCount,
3135
             const LookupRecord lookupRecord[],
3136
             unsigned value,
3137
             ChainContextClosureLookupContext &lookup_context)
3138
0
{
3139
0
  if (chain_context_intersects (c->glyphs,
3140
0
        backtrackCount, backtrack,
3141
0
        inputCount, input,
3142
0
        lookaheadCount, lookahead,
3143
0
        lookup_context))
3144
0
    context_closure_recurse_lookups (c,
3145
0
         inputCount, input,
3146
0
         lookupCount, lookupRecord,
3147
0
         value,
3148
0
         lookup_context.context_format,
3149
0
         lookup_context.intersects_data[1],
3150
0
         lookup_context.funcs.intersected_glyphs,
3151
0
         lookup_context.intersected_glyphs_cache);
3152
0
}
Unexecuted instantiation: hb-aat-layout.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-face.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-layout.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
Unexecuted instantiation: gsubgpos-context.cc:void OT::chain_context_closure_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_closure_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, unsigned int, OT::ChainContextClosureLookupContext&)
3153
3154
template <typename HBUINT>
3155
static inline void chain_context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c,
3156
              unsigned int backtrackCount,
3157
              const HBUINT backtrack[],
3158
              unsigned int inputCount, /* Including the first glyph (not matched) */
3159
              const HBUINT input[], /* Array of input values--start with second glyph */
3160
              unsigned int lookaheadCount,
3161
              const HBUINT lookahead[],
3162
              unsigned int lookupCount,
3163
              const LookupRecord lookupRecord[],
3164
              ChainContextCollectGlyphsLookupContext &lookup_context)
3165
0
{
3166
0
  collect_array (c, c->before,
3167
0
     backtrackCount, backtrack,
3168
0
     lookup_context.funcs.collect, lookup_context.collect_data[0]);
3169
0
  collect_array (c, c->input,
3170
0
     inputCount ? inputCount - 1 : 0, input,
3171
0
     lookup_context.funcs.collect, lookup_context.collect_data[1]);
3172
0
  collect_array (c, c->after,
3173
0
     lookaheadCount, lookahead,
3174
0
     lookup_context.funcs.collect, lookup_context.collect_data[2]);
3175
0
  recurse_lookups (c,
3176
0
       lookupCount, lookupRecord);
3177
0
}
Unexecuted instantiation: hb-aat-layout.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-face.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-layout.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-plan-layout.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-layout.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-var.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-cff.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-color.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: hb-subset-table-other.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
Unexecuted instantiation: gsubgpos-context.cc:void OT::chain_context_collect_glyphs_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_collect_glyphs_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextCollectGlyphsLookupContext&)
3178
3179
template <typename HBUINT>
3180
static inline bool chain_context_would_apply_lookup (hb_would_apply_context_t *c,
3181
                 unsigned int backtrackCount,
3182
                 const HBUINT backtrack[] HB_UNUSED,
3183
                 unsigned int inputCount, /* Including the first glyph (not matched) */
3184
                 const HBUINT input[], /* Array of input values--start with second glyph */
3185
                 unsigned int lookaheadCount,
3186
                 const HBUINT lookahead[] HB_UNUSED,
3187
                 unsigned int lookupCount HB_UNUSED,
3188
                 const LookupRecord lookupRecord[] HB_UNUSED,
3189
                 const ChainContextApplyLookupContext &lookup_context)
3190
0
{
3191
0
  return (c->zero_context ? !backtrackCount && !lookaheadCount : true)
3192
0
      && would_match_input (c,
3193
0
          inputCount, input,
3194
0
          lookup_context.funcs.match[1], lookup_context.match_data[1]);
3195
0
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-face.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::chain_context_would_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_would_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
3196
3197
template <typename HBUINT>
3198
static inline bool chain_context_apply_lookup (hb_ot_apply_context_t *c,
3199
                 unsigned int backtrackCount,
3200
                 const HBUINT backtrack[],
3201
                 unsigned int inputCount, /* Including the first glyph (not matched) */
3202
                 const HBUINT input[], /* Array of input values--start with second glyph */
3203
                 unsigned int lookaheadCount,
3204
                 const HBUINT lookahead[],
3205
                 unsigned int lookupCount,
3206
                 const LookupRecord lookupRecord[],
3207
                 const ChainContextApplyLookupContext &lookup_context)
3208
1.60M
{
3209
1.60M
  if (unlikely (inputCount > HB_MAX_CONTEXT_LENGTH)) return false;
3210
3211
1.60M
  unsigned start_index = c->buffer->out_len;
3212
1.60M
  unsigned end_index = c->buffer->idx;
3213
1.60M
  unsigned match_end = 0;
3214
1.60M
  bool ret = true;
3215
1.60M
  if (!(match_input (c,
3216
1.60M
         inputCount, input,
3217
1.60M
         lookup_context.funcs.match[1], lookup_context.match_data[1],
3218
1.60M
         &match_end) && (end_index = match_end)
3219
1.51M
       && match_lookahead (c,
3220
1.51M
         lookaheadCount, lookahead,
3221
1.51M
         lookup_context.funcs.match[2], lookup_context.match_data[2],
3222
1.51M
         match_end, &end_index)))
3223
738k
  {
3224
738k
    c->buffer->unsafe_to_concat (c->buffer->idx, end_index);
3225
738k
    return false;
3226
738k
  }
3227
3228
865k
  if (!match_backtrack (c,
3229
865k
      backtrackCount, backtrack,
3230
865k
      lookup_context.funcs.match[0], lookup_context.match_data[0],
3231
865k
      &start_index))
3232
857k
  {
3233
857k
    c->buffer->unsafe_to_concat_from_outbuffer (start_index, end_index);
3234
857k
    return false;
3235
857k
  }
3236
3237
8.30k
  c->buffer->unsafe_to_break_from_outbuffer (start_index, end_index);
3238
8.30k
  apply_lookup (c,
3239
8.30k
    inputCount,
3240
8.30k
    lookupCount, lookupRecord,
3241
8.30k
    match_end);
3242
3243
8.30k
  return ret;
3244
865k
}
Unexecuted instantiation: hb-aat-layout.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-face.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
hb-ot-layout.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Line
Count
Source
3208
1.60M
{
3209
1.60M
  if (unlikely (inputCount > HB_MAX_CONTEXT_LENGTH)) return false;
3210
3211
1.60M
  unsigned start_index = c->buffer->out_len;
3212
1.60M
  unsigned end_index = c->buffer->idx;
3213
1.60M
  unsigned match_end = 0;
3214
1.60M
  bool ret = true;
3215
1.60M
  if (!(match_input (c,
3216
1.60M
         inputCount, input,
3217
1.60M
         lookup_context.funcs.match[1], lookup_context.match_data[1],
3218
1.60M
         &match_end) && (end_index = match_end)
3219
1.51M
       && match_lookahead (c,
3220
1.51M
         lookaheadCount, lookahead,
3221
1.51M
         lookup_context.funcs.match[2], lookup_context.match_data[2],
3222
1.51M
         match_end, &end_index)))
3223
738k
  {
3224
738k
    c->buffer->unsafe_to_concat (c->buffer->idx, end_index);
3225
738k
    return false;
3226
738k
  }
3227
3228
865k
  if (!match_backtrack (c,
3229
865k
      backtrackCount, backtrack,
3230
865k
      lookup_context.funcs.match[0], lookup_context.match_data[0],
3231
865k
      &start_index))
3232
857k
  {
3233
857k
    c->buffer->unsafe_to_concat_from_outbuffer (start_index, end_index);
3234
857k
    return false;
3235
857k
  }
3236
3237
8.30k
  c->buffer->unsafe_to_break_from_outbuffer (start_index, end_index);
3238
8.30k
  apply_lookup (c,
3239
8.30k
    inputCount,
3240
8.30k
    lookupCount, lookupRecord,
3241
8.30k
    match_end);
3242
3243
8.30k
  return ret;
3244
865k
}
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-plan-layout.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-var.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-color.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: hb-subset-table-other.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
Unexecuted instantiation: gsubgpos-context.cc:bool OT::chain_context_apply_lookup<OT::NumType<true, unsigned short, 2u> >(OT::hb_ot_apply_context_t*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::NumType<true, unsigned short, 2u> const*, unsigned int, OT::LookupRecord const*, OT::ChainContextApplyLookupContext const&)
3245
3246
template <typename Types>
3247
struct ChainRule
3248
{
3249
  template <typename T>
3250
  friend struct ChainRuleSet;
3251
3252
  bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const
3253
0
  {
3254
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3255
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3256
0
    return chain_context_intersects (glyphs,
3257
0
             backtrack.len, backtrack.arrayZ,
3258
0
             input.lenP1, input.arrayZ,
3259
0
             lookahead.len, lookahead.arrayZ,
3260
0
             lookup_context);
3261
0
  }
3262
3263
  void closure (hb_closure_context_t *c, unsigned value,
3264
    ChainContextClosureLookupContext &lookup_context) const
3265
0
  {
3266
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
3267
3268
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3269
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3270
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
3271
0
    chain_context_closure_lookup (c,
3272
0
          backtrack.len, backtrack.arrayZ,
3273
0
          input.lenP1, input.arrayZ,
3274
0
          lookahead.len, lookahead.arrayZ,
3275
0
          lookup.len, lookup.arrayZ,
3276
0
          value,
3277
0
          lookup_context);
3278
0
  }
3279
3280
  void closure_lookups (hb_closure_lookups_context_t *c,
3281
                        ChainContextClosureLookupContext &lookup_context) const
3282
0
  {
3283
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
3284
0
    if (!intersects (c->glyphs, lookup_context)) return;
3285
3286
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3287
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3288
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
3289
0
    recurse_lookups (c, lookup.len, lookup.arrayZ);
3290
0
  }
3291
3292
  void collect_glyphs (hb_collect_glyphs_context_t *c,
3293
           ChainContextCollectGlyphsLookupContext &lookup_context) const
3294
0
  {
3295
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3296
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3297
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
3298
0
    chain_context_collect_glyphs_lookup (c,
3299
0
           backtrack.len, backtrack.arrayZ,
3300
0
           input.lenP1, input.arrayZ,
3301
0
           lookahead.len, lookahead.arrayZ,
3302
0
           lookup.len, lookup.arrayZ,
3303
0
           lookup_context);
3304
0
  }
3305
3306
  bool would_apply (hb_would_apply_context_t *c,
3307
        const ChainContextApplyLookupContext &lookup_context) const
3308
0
  {
3309
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3310
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3311
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
3312
0
    return chain_context_would_apply_lookup (c,
3313
0
               backtrack.len, backtrack.arrayZ,
3314
0
               input.lenP1, input.arrayZ,
3315
0
               lookahead.len, lookahead.arrayZ, lookup.len,
3316
0
               lookup.arrayZ, lookup_context);
3317
0
  }
3318
3319
  bool apply (hb_ot_apply_context_t *c,
3320
        const ChainContextApplyLookupContext &lookup_context) const
3321
0
  {
3322
0
    TRACE_APPLY (this);
3323
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3324
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3325
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
3326
0
    return_trace (chain_context_apply_lookup (c,
3327
0
                backtrack.len, backtrack.arrayZ,
3328
0
                input.lenP1, input.arrayZ,
3329
0
                lookahead.len, lookahead.arrayZ, lookup.len,
3330
0
                lookup.arrayZ, lookup_context));
3331
0
  }
3332
3333
  template<typename Iterator,
3334
     hb_requires (hb_is_iterator (Iterator))>
3335
  void serialize_array (hb_serialize_context_t *c,
3336
      HBUINT16 len,
3337
      Iterator it) const
3338
0
  {
3339
0
    c->copy (len);
3340
0
    for (const auto g : it)
3341
0
      c->copy ((HBUINT16) g);
3342
0
  }
3343
3344
  bool serialize (hb_serialize_context_t *c,
3345
      const hb_map_t *lookup_map,
3346
      const hb_map_t *backtrack_map,
3347
      const hb_map_t *input_map = nullptr,
3348
      const hb_map_t *lookahead_map = nullptr) const
3349
0
  {
3350
0
    TRACE_SERIALIZE (this);
3351
3352
0
    const hb_map_t *mapping = backtrack_map;
3353
0
    serialize_array (c, backtrack.len, + backtrack.iter ()
3354
0
               | hb_map (mapping));
3355
3356
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3357
0
    if (input_map) mapping = input_map;
3358
0
    serialize_array (c, input.lenP1, + input.iter ()
3359
0
             | hb_map (mapping));
3360
3361
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3362
0
    if (lookahead_map) mapping = lookahead_map;
3363
0
    serialize_array (c, lookahead.len, + lookahead.iter ()
3364
0
               | hb_map (mapping));
3365
3366
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
3367
3368
0
    HBUINT16* lookupCount = c->embed (&(lookup.len));
3369
0
    if (!lookupCount) return_trace (false);
3370
3371
0
    unsigned count = serialize_lookuprecord_array (c, lookup.as_array (), lookup_map);
3372
0
    return_trace (c->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW));
3373
0
  }
3374
3375
  bool subset (hb_subset_context_t *c,
3376
         const hb_map_t *lookup_map,
3377
         const hb_map_t *backtrack_map = nullptr,
3378
         const hb_map_t *input_map = nullptr,
3379
         const hb_map_t *lookahead_map = nullptr) const
3380
0
  {
3381
0
    TRACE_SUBSET (this);
3382
3383
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3384
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3385
3386
0
    if (!backtrack_map)
3387
0
    {
3388
0
      const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
3389
0
      if (!hb_all (backtrack, glyphset) ||
3390
0
    !hb_all (input, glyphset) ||
3391
0
    !hb_all (lookahead, glyphset))
3392
0
  return_trace (false);
3393
3394
0
      serialize (c->serializer, lookup_map, c->plan->glyph_map);
3395
0
    }
3396
0
    else
3397
0
    {
3398
0
      if (!hb_all (backtrack, backtrack_map) ||
3399
0
    !hb_all (input, input_map) ||
3400
0
    !hb_all (lookahead, lookahead_map))
3401
0
  return_trace (false);
3402
3403
0
      serialize (c->serializer, lookup_map, backtrack_map, input_map, lookahead_map);
3404
0
    }
3405
3406
0
    return_trace (true);
3407
0
  }
3408
3409
  bool sanitize (hb_sanitize_context_t *c) const
3410
0
  {
3411
0
    TRACE_SANITIZE (this);
3412
    /* Hyper-optimized sanitized because this is really hot. */
3413
0
    if (unlikely (!backtrack.len.sanitize (c))) return_trace (false);
3414
0
    hb_barrier ();
3415
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
3416
0
    if (unlikely (!input.lenP1.sanitize (c))) return_trace (false);
3417
0
    hb_barrier ();
3418
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
3419
0
    if (unlikely (!lookahead.len.sanitize (c))) return_trace (false);
3420
0
    hb_barrier ();
3421
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
3422
0
    return_trace (likely (lookup.sanitize (c)));
3423
0
  }
3424
3425
  protected:
3426
  Array16Of<typename Types::HBUINT>
3427
    backtrack;    /* Array of backtracking values
3428
           * (to be matched before the input
3429
           * sequence) */
3430
  HeadlessArray16Of<typename Types::HBUINT>
3431
    inputX;     /* Array of input values (start with
3432
           * second glyph) */
3433
  Array16Of<typename Types::HBUINT>
3434
    lookaheadX;   /* Array of lookahead values's (to be
3435
           * matched after the input sequence) */
3436
  Array16Of<LookupRecord>
3437
    lookupX;    /* Array of LookupRecords--in
3438
           * design order) */
3439
  public:
3440
  DEFINE_SIZE_MIN (8);
3441
};
3442
3443
template <typename Types>
3444
struct ChainRuleSet
3445
{
3446
  using ChainRule = OT::ChainRule<Types>;
3447
3448
  bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const
3449
0
  {
3450
0
    return
3451
0
    + hb_iter (rule)
3452
0
    | hb_map (hb_add (this))
3453
0
    | hb_map ([&] (const ChainRule &_) { return _.intersects (glyphs, lookup_context); })
3454
0
    | hb_any
3455
0
    ;
3456
0
  }
3457
  void closure (hb_closure_context_t *c, unsigned value, ChainContextClosureLookupContext &lookup_context) const
3458
0
  {
3459
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
3460
3461
0
    return
3462
0
    + hb_iter (rule)
3463
0
    | hb_map (hb_add (this))
3464
0
    | hb_apply ([&] (const ChainRule &_) { _.closure (c, value, lookup_context); })
3465
0
    ;
3466
0
  }
3467
3468
  void closure_lookups (hb_closure_lookups_context_t *c,
3469
                        ChainContextClosureLookupContext &lookup_context) const
3470
0
  {
3471
0
    if (unlikely (c->lookup_limit_exceeded ())) return;
3472
3473
0
    + hb_iter (rule)
3474
0
    | hb_map (hb_add (this))
3475
0
    | hb_apply ([&] (const ChainRule &_) { _.closure_lookups (c, lookup_context); })
3476
0
    ;
3477
0
  }
3478
3479
  void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const
3480
0
  {
3481
0
    return
3482
0
    + hb_iter (rule)
3483
0
    | hb_map (hb_add (this))
3484
0
    | hb_apply ([&] (const ChainRule &_) { _.collect_glyphs (c, lookup_context); })
3485
0
    ;
3486
0
  }
3487
3488
  bool would_apply (hb_would_apply_context_t *c,
3489
        const ChainContextApplyLookupContext &lookup_context) const
3490
0
  {
3491
0
    return
3492
0
    + hb_iter (rule)
3493
0
    | hb_map (hb_add (this))
3494
0
    | hb_map ([&] (const ChainRule &_) { return _.would_apply (c, lookup_context); })
3495
0
    | hb_any
3496
0
    ;
3497
0
  }
3498
3499
  bool apply (hb_ot_apply_context_t *c,
3500
        const ChainContextApplyLookupContext &lookup_context) const
3501
0
  {
3502
0
    TRACE_APPLY (this);
3503
3504
0
    unsigned num_rules = rule.len;
3505
3506
0
#ifndef HB_NO_OT_RULESETS_FAST_PATH
3507
0
    if (HB_OPTIMIZE_SIZE_VAL || num_rules <= 4)
3508
0
#endif
3509
0
    {
3510
0
    slow:
3511
0
      return_trace (
3512
0
      + hb_iter (rule)
3513
0
      | hb_map (hb_add (this))
3514
0
      | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); })
3515
0
      | hb_any
3516
0
      )
3517
0
      ;
3518
0
    }
3519
3520
    /* This version is optimized for speed by matching the first & second
3521
     * components of the rule here, instead of calling into the matching code.
3522
     *
3523
     * Replicated from LigatureSet::apply(). */
3524
3525
    /* We use the iter_context instead of iter_input, to avoid skipping
3526
     * default-ignorables and such.
3527
     *
3528
     * Related: https://github.com/harfbuzz/harfbuzz/issues/4813
3529
     */
3530
0
    auto &skippy_iter = c->iter_context;
3531
0
    skippy_iter.reset (c->buffer->idx);
3532
0
    skippy_iter.set_match_func (match_always, nullptr);
3533
0
    skippy_iter.set_glyph_data ((HBUINT16 *) nullptr);
3534
0
    unsigned unsafe_to = (unsigned) -1, unsafe_to1, unsafe_to2 = 0;
3535
0
    hb_glyph_info_t *first = nullptr, *second = nullptr;
3536
0
    bool matched = skippy_iter.next ();
3537
0
    if (likely (matched))
3538
0
    {
3539
0
      if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))
3540
0
      {
3541
  /* Can't use the fast path if eg. the next char is a default-ignorable
3542
   * or other skippable. */
3543
0
        goto slow;
3544
0
      }
3545
3546
0
      first = &c->buffer->info[skippy_iter.idx];
3547
0
      unsafe_to1 = skippy_iter.idx + 1;
3548
0
    }
3549
0
    else
3550
0
    {
3551
      /* Failed to match a next glyph. Only try applying rules that have
3552
       * no further input and lookahead. */
3553
0
      return_trace (
3554
0
      + hb_iter (rule)
3555
0
      | hb_map (hb_add (this))
3556
0
      | hb_filter ([&] (const ChainRule &_)
3557
0
       {
3558
0
         const auto &input = StructAfter<decltype (_.inputX)> (_.backtrack);
3559
0
         const auto &lookahead = StructAfter<decltype (_.lookaheadX)> (input);
3560
0
         return input.lenP1 <= 1 && lookahead.len == 0;
3561
0
       })
3562
0
      | hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); })
3563
0
      | hb_any
3564
0
      )
3565
0
      ;
3566
0
    }
3567
0
    matched = skippy_iter.next ();
3568
0
    if (likely (matched))
3569
0
    {
3570
0
      if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))
3571
0
      {
3572
  /* Can't use the fast path if eg. the next char is a default-ignorable
3573
   * or other skippable. */
3574
0
        goto slow;
3575
0
      }
3576
3577
0
      second = &c->buffer->info[skippy_iter.idx];
3578
0
      unsafe_to2 = skippy_iter.idx + 1;
3579
0
    }
3580
3581
0
    auto match_input = lookup_context.funcs.match[1];
3582
0
    auto match_lookahead = lookup_context.funcs.match[2];
3583
0
    auto *input_data = lookup_context.match_data[1];
3584
0
    auto *lookahead_data = lookup_context.match_data[2];
3585
0
    for (unsigned int i = 0; i < num_rules; i++)
3586
0
    {
3587
0
      const auto &r = this+rule.arrayZ[i];
3588
3589
0
      const auto &input = StructAfter<decltype (r.inputX)> (r.backtrack);
3590
0
      const auto &lookahead = StructAfter<decltype (r.lookaheadX)> (input);
3591
3592
0
      unsigned lenP1 = input.lenP1;
3593
0
      if (lenP1 > 1 ?
3594
0
     (!match_input ||
3595
0
      match_input (*first, input.arrayZ[0], input_data))
3596
0
    :
3597
0
     (!lookahead.len || !match_lookahead ||
3598
0
      match_lookahead (*first, lookahead.arrayZ[0], lookahead_data)))
3599
0
      {
3600
0
  lenP1 = hb_max (lenP1, 1u);
3601
0
        if (!second ||
3602
0
      (lenP1 > 2 ?
3603
0
       (!match_input ||
3604
0
        match_input (*second, input.arrayZ[1], input_data))
3605
0
       :
3606
0
       (lookahead.len <= 2 - lenP1 || !match_lookahead ||
3607
0
        match_lookahead (*second, lookahead.arrayZ[2 - lenP1], lookahead_data))))
3608
0
  {
3609
0
    if (r.apply (c, lookup_context))
3610
0
    {
3611
0
      if (unsafe_to != (unsigned) -1)
3612
0
        c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to);
3613
0
      return_trace (true);
3614
0
    }
3615
0
  }
3616
0
  else
3617
0
    unsafe_to = unsafe_to2;
3618
0
      }
3619
0
      else
3620
0
      {
3621
0
  if (unsafe_to == (unsigned) -1)
3622
0
    unsafe_to = unsafe_to1;
3623
3624
0
  if (lenP1 > 1)
3625
0
  {
3626
    // Skip ahead to next possible first glyph match.
3627
0
    for (; i + 1 < num_rules; i++)
3628
0
    {
3629
0
      const auto &r2 = this+rule.arrayZ[i + 1];
3630
0
      const auto &input2 = StructAfter<decltype (r2.inputX)> (r2.backtrack);
3631
0
      if (input2.lenP1 <= 1 || input2.arrayZ[0] != input.arrayZ[0])
3632
0
        break;
3633
0
    }
3634
0
  }
3635
0
      }
3636
0
    }
3637
0
    if (likely (unsafe_to != (unsigned) -1))
3638
0
      c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to);
3639
3640
0
    return_trace (false);
3641
0
  }
3642
3643
  bool subset (hb_subset_context_t *c,
3644
         const hb_map_t *lookup_map,
3645
         const hb_map_t *backtrack_klass_map = nullptr,
3646
         const hb_map_t *input_klass_map = nullptr,
3647
         const hb_map_t *lookahead_klass_map = nullptr) const
3648
0
  {
3649
0
    TRACE_SUBSET (this);
3650
3651
0
    auto snap = c->serializer->snapshot ();
3652
0
    auto *out = c->serializer->start_embed (*this);
3653
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
3654
3655
0
    for (const Offset16To<ChainRule>& _ : rule)
3656
0
    {
3657
0
      if (!_) continue;
3658
0
      auto o_snap = c->serializer->snapshot ();
3659
0
      auto *o = out->rule.serialize_append (c->serializer);
3660
0
      if (unlikely (!o)) continue;
3661
3662
0
      if (!o->serialize_subset (c, _, this,
3663
0
        lookup_map,
3664
0
        backtrack_klass_map,
3665
0
        input_klass_map,
3666
0
        lookahead_klass_map))
3667
0
      {
3668
0
  out->rule.pop ();
3669
0
  c->serializer->revert (o_snap);
3670
0
      }
3671
0
    }
3672
3673
0
    bool ret = bool (out->rule);
3674
0
    if (!ret) c->serializer->revert (snap);
3675
3676
0
    return_trace (ret);
3677
0
  }
3678
3679
  bool sanitize (hb_sanitize_context_t *c) const
3680
0
  {
3681
0
    TRACE_SANITIZE (this);
3682
0
    return_trace (rule.sanitize (c, this));
3683
0
  }
3684
3685
  protected:
3686
  Array16OfOffset16To<ChainRule>
3687
    rule;     /* Array of ChainRule tables
3688
           * ordered by preference */
3689
  public:
3690
  DEFINE_SIZE_ARRAY (2, rule);
3691
};
3692
3693
template <typename Types>
3694
struct ChainContextFormat1_4
3695
{
3696
  using ChainRuleSet = OT::ChainRuleSet<Types>;
3697
3698
  bool intersects (const hb_set_t *glyphs) const
3699
0
  {
3700
0
    struct ChainContextClosureLookupContext lookup_context = {
3701
0
      {intersects_glyph, intersected_glyph},
3702
0
      ContextFormat::SimpleContext,
3703
0
      {nullptr, nullptr, nullptr}
3704
0
    };
3705
3706
0
    return
3707
0
    + hb_zip (this+coverage, ruleSet)
3708
0
    | hb_filter (*glyphs, hb_first)
3709
0
    | hb_map (hb_second)
3710
0
    | hb_map (hb_add (this))
3711
0
    | hb_map ([&] (const ChainRuleSet &_) { return _.intersects (glyphs, lookup_context); })
3712
0
    | hb_any
3713
0
    ;
3714
0
  }
3715
3716
  bool may_have_non_1to1 () const
3717
0
  { return true; }
3718
3719
  void closure (hb_closure_context_t *c) const
3720
0
  {
3721
0
    hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs ();
3722
0
    if (unlikely (!cur_active_glyphs)) return;
3723
0
    get_coverage ().intersect_set (c->previous_parent_active_glyphs (),
3724
0
           *cur_active_glyphs);
3725
3726
0
    struct ChainContextClosureLookupContext lookup_context = {
3727
0
      {intersects_glyph, intersected_glyph},
3728
0
      ContextFormat::SimpleContext,
3729
0
      {nullptr, nullptr, nullptr}
3730
0
    };
3731
3732
0
    + hb_zip (this+coverage, hb_range ((unsigned) ruleSet.len))
3733
0
    | hb_filter ([&] (hb_codepoint_t _) {
3734
0
      return c->previous_parent_active_glyphs ().has (_);
3735
0
    }, hb_first)
3736
0
    | hb_map ([&](const hb_pair_t<hb_codepoint_t, unsigned> _) { return hb_pair_t<unsigned, const ChainRuleSet&> (_.first, this+ruleSet[_.second]); })
3737
0
    | hb_apply ([&] (const hb_pair_t<unsigned, const ChainRuleSet&>& _) { _.second.closure (c, _.first, lookup_context); })
3738
0
    ;
3739
3740
0
    c->pop_cur_done_glyphs ();
3741
0
  }
3742
3743
  void closure_lookups (hb_closure_lookups_context_t *c) const
3744
0
  {
3745
0
    struct ChainContextClosureLookupContext lookup_context = {
3746
0
      {intersects_glyph, nullptr},
3747
0
      ContextFormat::SimpleContext,
3748
0
      {nullptr, nullptr, nullptr}
3749
0
    };
3750
3751
0
    + hb_zip (this+coverage, ruleSet)
3752
0
    | hb_filter (*c->glyphs, hb_first)
3753
0
    | hb_map (hb_second)
3754
0
    | hb_map (hb_add (this))
3755
0
    | hb_apply ([&] (const ChainRuleSet &_) { _.closure_lookups (c, lookup_context); })
3756
0
    ;
3757
0
  }
3758
3759
0
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {}
3760
3761
  void collect_glyphs (hb_collect_glyphs_context_t *c) const
3762
0
  {
3763
0
    (this+coverage).collect_coverage (c->input);
3764
3765
0
    struct ChainContextCollectGlyphsLookupContext lookup_context = {
3766
0
      {collect_glyph},
3767
0
      {nullptr, nullptr, nullptr}
3768
0
    };
3769
3770
0
    + hb_iter (ruleSet)
3771
0
    | hb_map (hb_add (this))
3772
0
    | hb_apply ([&] (const ChainRuleSet &_) { _.collect_glyphs (c, lookup_context); })
3773
0
    ;
3774
0
  }
3775
3776
  bool would_apply (hb_would_apply_context_t *c) const
3777
0
  {
3778
0
    const ChainRuleSet &rule_set = this+ruleSet[(this+coverage).get_coverage (c->glyphs[0])];
3779
0
    struct ChainContextApplyLookupContext lookup_context = {
3780
0
      {{match_glyph, match_glyph, match_glyph}},
3781
0
      {nullptr, nullptr, nullptr}
3782
0
    };
3783
0
    return rule_set.would_apply (c, lookup_context);
3784
0
  }
3785
3786
0
  const Coverage &get_coverage () const { return this+coverage; }
3787
3788
  bool apply (hb_ot_apply_context_t *c) const
3789
0
  {
3790
0
    TRACE_APPLY (this);
3791
0
    unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
3792
0
    if (index == NOT_COVERED) return_trace (false);
3793
3794
0
    const ChainRuleSet &rule_set = this+ruleSet[index];
3795
0
    struct ChainContextApplyLookupContext lookup_context = {
3796
0
      {{match_glyph, match_glyph, match_glyph}},
3797
0
      {nullptr, nullptr, nullptr}
3798
0
    };
3799
0
    return_trace (rule_set.apply (c, lookup_context));
3800
0
  }
3801
3802
  bool subset (hb_subset_context_t *c) const
3803
0
  {
3804
0
    TRACE_SUBSET (this);
3805
0
    const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
3806
0
    const hb_map_t &glyph_map = *c->plan->glyph_map;
3807
3808
0
    auto *out = c->serializer->start_embed (*this);
3809
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
3810
0
    out->format = format;
3811
3812
0
    const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
3813
0
    hb_sorted_vector_t<hb_codepoint_t> new_coverage;
3814
0
    + hb_zip (this+coverage, ruleSet)
3815
0
    | hb_filter (glyphset, hb_first)
3816
0
    | hb_filter (subset_offset_array (c, out->ruleSet, this, lookup_map), hb_second)
3817
0
    | hb_map (hb_first)
3818
0
    | hb_map (glyph_map)
3819
0
    | hb_sink (new_coverage)
3820
0
    ;
3821
3822
0
    out->coverage.serialize_serialize (c->serializer, new_coverage.iter ());
3823
0
    return_trace (bool (new_coverage));
3824
0
  }
3825
3826
  bool sanitize (hb_sanitize_context_t *c) const
3827
0
  {
3828
0
    TRACE_SANITIZE (this);
3829
0
    return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this));
3830
0
  }
3831
3832
  protected:
3833
  HBUINT16  format;     /* Format identifier--format = 1 */
3834
  typename Types::template OffsetTo<Coverage>
3835
    coverage;   /* Offset to Coverage table--from
3836
           * beginning of table */
3837
  Array16Of<typename Types::template OffsetTo<ChainRuleSet>>
3838
    ruleSet;    /* Array of ChainRuleSet tables
3839
           * ordered by Coverage Index */
3840
  public:
3841
  DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ruleSet);
3842
};
3843
3844
template <typename Types>
3845
struct ChainContextFormat2_5
3846
{
3847
  using ChainRuleSet = OT::ChainRuleSet<SmallTypes>;
3848
3849
  bool intersects (const hb_set_t *glyphs) const
3850
0
  {
3851
0
    if (!(this+coverage).intersects (glyphs))
3852
0
      return false;
3853
3854
0
    const ClassDef &backtrack_class_def = this+backtrackClassDef;
3855
0
    const ClassDef &input_class_def = this+inputClassDef;
3856
0
    const ClassDef &lookahead_class_def = this+lookaheadClassDef;
3857
3858
0
    hb_map_t caches[3] = {};
3859
0
    struct ChainContextClosureLookupContext lookup_context = {
3860
0
      {intersects_class, nullptr},
3861
0
      ContextFormat::ClassBasedContext,
3862
0
      {&backtrack_class_def,
3863
0
       &input_class_def,
3864
0
       &lookahead_class_def},
3865
0
      {&caches[0], &caches[1], &caches[2]}
3866
0
    };
3867
3868
0
    hb_set_t retained_coverage_glyphs;
3869
0
    (this+coverage).intersect_set (*glyphs, retained_coverage_glyphs);
3870
3871
0
    hb_set_t coverage_glyph_classes;
3872
0
    input_class_def.intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes);
3873
3874
0
    return
3875
0
    + hb_iter (ruleSet)
3876
0
    | hb_map (hb_add (this))
3877
0
    | hb_enumerate
3878
0
    | hb_map ([&] (const hb_pair_t<unsigned, const ChainRuleSet &> p)
3879
0
        { return input_class_def.intersects_class (glyphs, p.first) &&
3880
0
           coverage_glyph_classes.has (p.first) &&
3881
0
           p.second.intersects (glyphs, lookup_context); })
3882
0
    | hb_any
3883
0
    ;
3884
0
  }
3885
3886
  bool may_have_non_1to1 () const
3887
0
  { return true; }
3888
3889
  void closure (hb_closure_context_t *c) const
3890
0
  {
3891
0
    if (!(this+coverage).intersects (c->glyphs))
3892
0
      return;
3893
3894
0
    hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs ();
3895
0
    if (unlikely (!cur_active_glyphs)) return;
3896
0
    get_coverage ().intersect_set (c->previous_parent_active_glyphs (),
3897
0
           *cur_active_glyphs);
3898
3899
0
    const ClassDef &backtrack_class_def = this+backtrackClassDef;
3900
0
    const ClassDef &input_class_def = this+inputClassDef;
3901
0
    const ClassDef &lookahead_class_def = this+lookaheadClassDef;
3902
3903
0
    hb_map_t caches[3] = {};
3904
0
    intersected_class_cache_t intersected_cache;
3905
0
    struct ChainContextClosureLookupContext lookup_context = {
3906
0
      {intersects_class, intersected_class_glyphs},
3907
0
      ContextFormat::ClassBasedContext,
3908
0
      {&backtrack_class_def,
3909
0
       &input_class_def,
3910
0
       &lookahead_class_def},
3911
0
      {&caches[0], &caches[1], &caches[2]},
3912
0
      &intersected_cache
3913
0
    };
3914
3915
0
    + hb_enumerate (ruleSet)
3916
0
    | hb_filter ([&] (unsigned _)
3917
0
    { return input_class_def.intersects_class (&c->parent_active_glyphs (), _); },
3918
0
     hb_first)
3919
0
    | hb_apply ([&] (const hb_pair_t<unsigned, const typename Types::template OffsetTo<ChainRuleSet>&> _)
3920
0
                {
3921
0
                  const ChainRuleSet& chainrule_set = this+_.second;
3922
0
                  chainrule_set.closure (c, _.first, lookup_context);
3923
0
                })
3924
0
    ;
3925
3926
0
    c->pop_cur_done_glyphs ();
3927
0
  }
3928
3929
  void closure_lookups (hb_closure_lookups_context_t *c) const
3930
0
  {
3931
0
    if (!(this+coverage).intersects (c->glyphs))
3932
0
      return;
3933
3934
0
    const ClassDef &backtrack_class_def = this+backtrackClassDef;
3935
0
    const ClassDef &input_class_def = this+inputClassDef;
3936
0
    const ClassDef &lookahead_class_def = this+lookaheadClassDef;
3937
3938
0
    hb_map_t caches[3] = {};
3939
0
    struct ChainContextClosureLookupContext lookup_context = {
3940
0
      {intersects_class, nullptr},
3941
0
      ContextFormat::ClassBasedContext,
3942
0
      {&backtrack_class_def,
3943
0
       &input_class_def,
3944
0
       &lookahead_class_def},
3945
0
      {&caches[0], &caches[1], &caches[2]}
3946
0
    };
3947
3948
0
    + hb_iter (ruleSet)
3949
0
    | hb_map (hb_add (this))
3950
0
    | hb_enumerate
3951
0
    | hb_filter([&] (unsigned klass)
3952
0
    { return input_class_def.intersects_class (c->glyphs, klass); }, hb_first)
3953
0
    | hb_map (hb_second)
3954
0
    | hb_apply ([&] (const ChainRuleSet &_)
3955
0
    { _.closure_lookups (c, lookup_context); })
3956
0
    ;
3957
0
  }
3958
3959
0
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {}
3960
3961
  void collect_glyphs (hb_collect_glyphs_context_t *c) const
3962
0
  {
3963
0
    (this+coverage).collect_coverage (c->input);
3964
3965
0
    const ClassDef &backtrack_class_def = this+backtrackClassDef;
3966
0
    const ClassDef &input_class_def = this+inputClassDef;
3967
0
    const ClassDef &lookahead_class_def = this+lookaheadClassDef;
3968
3969
0
    struct ChainContextCollectGlyphsLookupContext lookup_context = {
3970
0
      {collect_class},
3971
0
      {&backtrack_class_def,
3972
0
       &input_class_def,
3973
0
       &lookahead_class_def}
3974
0
    };
3975
3976
0
    + hb_iter (ruleSet)
3977
0
    | hb_map (hb_add (this))
3978
0
    | hb_apply ([&] (const ChainRuleSet &_) { _.collect_glyphs (c, lookup_context); })
3979
0
    ;
3980
0
  }
3981
3982
  bool would_apply (hb_would_apply_context_t *c) const
3983
0
  {
3984
0
    const ClassDef &backtrack_class_def = this+backtrackClassDef;
3985
0
    const ClassDef &input_class_def = this+inputClassDef;
3986
0
    const ClassDef &lookahead_class_def = this+lookaheadClassDef;
3987
3988
0
    unsigned int index = input_class_def.get_class (c->glyphs[0]);
3989
0
    const ChainRuleSet &rule_set = this+ruleSet[index];
3990
0
    struct ChainContextApplyLookupContext lookup_context = {
3991
0
      {{match_class, match_class, match_class}},
3992
0
      {&backtrack_class_def,
3993
0
       &input_class_def,
3994
0
       &lookahead_class_def}
3995
0
    };
3996
0
    return rule_set.would_apply (c, lookup_context);
3997
0
  }
3998
3999
0
  const Coverage &get_coverage () const { return this+coverage; }
4000
4001
  unsigned cache_cost () const
4002
0
  {
4003
0
    return (this+inputClassDef).cost () + (this+lookaheadClassDef).cost ();
4004
0
  }
4005
  static bool cache_func (hb_ot_apply_context_t *c, hb_ot_subtable_cache_op_t op)
4006
0
  {
4007
0
    return context_cache_func (c, op);
4008
0
  }
4009
4010
  struct external_cache_t
4011
  {
4012
    hb_ot_layout_binary_cache_t coverage;
4013
  };
4014
  void *external_cache_create () const
4015
0
  {
4016
0
    external_cache_t *cache = (external_cache_t *) hb_malloc (sizeof (external_cache_t));
4017
0
    if (likely (cache))
4018
0
    {
4019
0
      cache->coverage.clear ();
4020
0
    }
4021
0
    return cache;
4022
0
  }
4023
0
  bool apply_cached (hb_ot_apply_context_t *c, void *external_cache) const { return _apply (c, true, external_cache); }
4024
0
  bool apply (hb_ot_apply_context_t *c, void *external_cache) const { return _apply (c, false, external_cache); }
4025
  bool _apply (hb_ot_apply_context_t *c, bool cached, void *external_cache) const
4026
0
  {
4027
0
    TRACE_APPLY (this);
4028
0
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4029
0
    external_cache_t *cache = (external_cache_t *) external_cache;
4030
0
    unsigned int index = (this+coverage).get_coverage_binary (c->buffer->cur().codepoint, cache ? &cache->coverage : nullptr);
4031
#else
4032
    unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
4033
#endif
4034
0
    if (index == NOT_COVERED) return_trace (false);
4035
4036
0
    const ClassDef &backtrack_class_def = this+backtrackClassDef;
4037
0
    const ClassDef &input_class_def = this+inputClassDef;
4038
0
    const ClassDef &lookahead_class_def = this+lookaheadClassDef;
4039
4040
    /* match_class_caches1 is slightly faster. Use it for lookahead,
4041
     * which is typically longer. */
4042
0
    struct ChainContextApplyLookupContext lookup_context = {
4043
0
      {{cached && &backtrack_class_def == &lookahead_class_def ? match_class_cached1 : match_class,
4044
0
        cached ? match_class_cached2 : match_class,
4045
0
        cached ? match_class_cached1 : match_class}},
4046
0
      {&backtrack_class_def,
4047
0
       &input_class_def,
4048
0
       &lookahead_class_def}
4049
0
    };
4050
4051
0
    index = cached
4052
0
         ? get_class_cached2 (input_class_def, c->buffer->cur())
4053
0
          : input_class_def.get_class (c->buffer->cur().codepoint);
4054
0
    const ChainRuleSet &rule_set = this+ruleSet[index];
4055
0
    return_trace (rule_set.apply (c, lookup_context));
4056
0
  }
4057
4058
  bool subset (hb_subset_context_t *c) const
4059
0
  {
4060
0
    TRACE_SUBSET (this);
4061
0
    auto *out = c->serializer->start_embed (*this);
4062
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
4063
0
    out->format = format;
4064
0
    out->coverage.serialize_subset (c, coverage, this);
4065
4066
0
    hb_map_t backtrack_klass_map;
4067
0
    hb_map_t input_klass_map;
4068
0
    hb_map_t lookahead_klass_map;
4069
4070
0
    out->backtrackClassDef.serialize_subset (c, backtrackClassDef, this, &backtrack_klass_map);
4071
    // TODO: subset inputClassDef based on glyphs survived in Coverage subsetting
4072
0
    out->inputClassDef.serialize_subset (c, inputClassDef, this, &input_klass_map);
4073
0
    out->lookaheadClassDef.serialize_subset (c, lookaheadClassDef, this, &lookahead_klass_map);
4074
4075
0
    if (unlikely (!c->serializer->propagate_error (backtrack_klass_map,
4076
0
               input_klass_map,
4077
0
               lookahead_klass_map)))
4078
0
      return_trace (false);
4079
4080
0
    const hb_set_t* glyphset = c->plan->glyphset_gsub ();
4081
0
    hb_set_t retained_coverage_glyphs;
4082
0
    (this+coverage).intersect_set (*glyphset, retained_coverage_glyphs);
4083
4084
0
    hb_set_t coverage_glyph_classes;
4085
0
    (this+inputClassDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes);
4086
4087
0
    int non_zero_index = -1, index = 0;
4088
0
    bool ret = true;
4089
0
    const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
4090
0
    auto last_non_zero = c->serializer->snapshot ();
4091
0
    for (const auto& _ : + hb_enumerate (ruleSet)
4092
0
       | hb_filter (input_klass_map, hb_first))
4093
0
    {
4094
0
      auto *o = out->ruleSet.serialize_append (c->serializer);
4095
0
      if (unlikely (!o))
4096
0
      {
4097
0
  ret = false;
4098
0
  break;
4099
0
      }
4100
0
      if (coverage_glyph_classes.has (_.first) &&
4101
0
          o->serialize_subset (c, _.second, this,
4102
0
             lookup_map,
4103
0
             &backtrack_klass_map,
4104
0
             &input_klass_map,
4105
0
             &lookahead_klass_map))
4106
0
      {
4107
0
        last_non_zero = c->serializer->snapshot ();
4108
0
  non_zero_index = index;
4109
0
      }
4110
4111
0
      index++;
4112
0
    }
4113
4114
0
    if (!ret || non_zero_index == -1) return_trace (false);
4115
4116
    // prune empty trailing ruleSets
4117
0
    if (index > non_zero_index) {
4118
0
      c->serializer->revert (last_non_zero);
4119
0
      out->ruleSet.len = non_zero_index + 1;
4120
0
    }
4121
4122
0
    return_trace (bool (out->ruleSet));
4123
0
  }
4124
4125
  bool sanitize (hb_sanitize_context_t *c) const
4126
0
  {
4127
0
    TRACE_SANITIZE (this);
4128
0
    return_trace (coverage.sanitize (c, this) &&
4129
0
      backtrackClassDef.sanitize (c, this) &&
4130
0
      inputClassDef.sanitize (c, this) &&
4131
0
      lookaheadClassDef.sanitize (c, this) &&
4132
0
      ruleSet.sanitize (c, this));
4133
0
  }
4134
4135
  protected:
4136
  HBUINT16  format;     /* Format identifier--format = 2 */
4137
  typename Types::template OffsetTo<Coverage>
4138
    coverage;   /* Offset to Coverage table--from
4139
           * beginning of table */
4140
  typename Types::template OffsetTo<ClassDef>
4141
    backtrackClassDef;  /* Offset to glyph ClassDef table
4142
           * containing backtrack sequence
4143
           * data--from beginning of table */
4144
  typename Types::template OffsetTo<ClassDef>
4145
    inputClassDef;    /* Offset to glyph ClassDef
4146
           * table containing input sequence
4147
           * data--from beginning of table */
4148
  typename Types::template OffsetTo<ClassDef>
4149
    lookaheadClassDef;  /* Offset to glyph ClassDef table
4150
           * containing lookahead sequence
4151
           * data--from beginning of table */
4152
  Array16Of<typename Types::template OffsetTo<ChainRuleSet>>
4153
    ruleSet;    /* Array of ChainRuleSet tables
4154
           * ordered by class */
4155
  public:
4156
  DEFINE_SIZE_ARRAY (4 + 4 * Types::size, ruleSet);
4157
};
4158
4159
struct ChainContextFormat3
4160
{
4161
  using RuleSet = OT::RuleSet<SmallTypes>;
4162
4163
  bool intersects (const hb_set_t *glyphs) const
4164
0
  {
4165
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4166
4167
0
    if (!(this+input[0]).intersects (glyphs))
4168
0
      return false;
4169
4170
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4171
0
    struct ChainContextClosureLookupContext lookup_context = {
4172
0
      {intersects_coverage, nullptr},
4173
0
      ContextFormat::CoverageBasedContext,
4174
0
      {this, this, this}
4175
0
    };
4176
0
    return chain_context_intersects (glyphs,
4177
0
             backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
4178
0
             input.len, (const HBUINT16 *) input.arrayZ + 1,
4179
0
             lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
4180
0
             lookup_context);
4181
0
  }
4182
4183
  bool may_have_non_1to1 () const
4184
0
  { return true; }
4185
4186
  void closure (hb_closure_context_t *c) const
4187
0
  {
4188
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4189
4190
0
    if (!(this+input[0]).intersects (c->glyphs))
4191
0
      return;
4192
4193
0
    hb_set_t* cur_active_glyphs = c->push_cur_active_glyphs ();
4194
0
    if (unlikely (!cur_active_glyphs))
4195
0
      return;
4196
0
    get_coverage ().intersect_set (c->previous_parent_active_glyphs (),
4197
0
           *cur_active_glyphs);
4198
4199
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4200
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
4201
0
    struct ChainContextClosureLookupContext lookup_context = {
4202
0
      {intersects_coverage, intersected_coverage_glyphs},
4203
0
      ContextFormat::CoverageBasedContext,
4204
0
      {this, this, this}
4205
0
    };
4206
0
    chain_context_closure_lookup (c,
4207
0
          backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
4208
0
          input.len, (const HBUINT16 *) input.arrayZ + 1,
4209
0
          lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
4210
0
          lookup.len, lookup.arrayZ,
4211
0
          0, lookup_context);
4212
4213
0
    c->pop_cur_done_glyphs ();
4214
0
  }
4215
4216
  void closure_lookups (hb_closure_lookups_context_t *c) const
4217
0
  {
4218
0
    if (!intersects (c->glyphs))
4219
0
      return;
4220
4221
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4222
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4223
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
4224
0
    recurse_lookups (c, lookup.len, lookup.arrayZ);
4225
0
  }
4226
4227
0
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const {}
4228
4229
  void collect_glyphs (hb_collect_glyphs_context_t *c) const
4230
0
  {
4231
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4232
4233
0
    (this+input[0]).collect_coverage (c->input);
4234
4235
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4236
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
4237
4238
0
    struct ChainContextCollectGlyphsLookupContext lookup_context = {
4239
0
      {collect_coverage},
4240
0
      {this, this, this}
4241
0
    };
4242
0
    chain_context_collect_glyphs_lookup (c,
4243
0
           backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
4244
0
           input.len, (const HBUINT16 *) input.arrayZ + 1,
4245
0
           lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
4246
0
           lookup.len, lookup.arrayZ,
4247
0
           lookup_context);
4248
0
  }
4249
4250
  bool would_apply (hb_would_apply_context_t *c) const
4251
0
  {
4252
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4253
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4254
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
4255
0
    struct ChainContextApplyLookupContext lookup_context = {
4256
0
      {{match_coverage, match_coverage, match_coverage}},
4257
0
      {this, this, this}
4258
0
    };
4259
0
    return chain_context_would_apply_lookup (c,
4260
0
               backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
4261
0
               input.len, (const HBUINT16 *) input.arrayZ + 1,
4262
0
               lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
4263
0
               lookup.len, lookup.arrayZ, lookup_context);
4264
0
  }
4265
4266
  const Coverage &get_coverage () const
4267
902
  {
4268
902
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4269
902
    return this+input[0];
4270
902
  }
4271
4272
  bool apply (hb_ot_apply_context_t *c) const
4273
2.01M
  {
4274
2.01M
    TRACE_APPLY (this);
4275
2.01M
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4276
4277
2.01M
    unsigned int index = (this+input[0]).get_coverage (c->buffer->cur().codepoint);
4278
2.01M
    if (index == NOT_COVERED) return_trace (false);
4279
4280
1.60M
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4281
1.60M
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
4282
1.60M
    struct ChainContextApplyLookupContext lookup_context = {
4283
1.60M
      {{match_coverage, match_coverage, match_coverage}},
4284
1.60M
      {this, this, this}
4285
1.60M
    };
4286
1.60M
    return_trace (chain_context_apply_lookup (c,
4287
2.01M
                backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
4288
2.01M
                input.len, (const HBUINT16 *) input.arrayZ + 1,
4289
2.01M
                lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
4290
2.01M
                lookup.len, lookup.arrayZ, lookup_context));
4291
2.01M
  }
4292
4293
  template<typename Iterator,
4294
     hb_requires (hb_is_iterator (Iterator))>
4295
  bool serialize_coverage_offsets (hb_subset_context_t *c, Iterator it, const void* base) const
4296
0
  {
4297
0
    TRACE_SERIALIZE (this);
4298
0
    auto *out = c->serializer->start_embed<Array16OfOffset16To<Coverage>> ();
4299
4300
0
    if (unlikely (!c->serializer->allocate_size<HBUINT16> (HBUINT16::static_size)))
4301
0
      return_trace (false);
4302
4303
0
    for (auto& offset : it) {
4304
0
      auto *o = out->serialize_append (c->serializer);
4305
0
      if (unlikely (!o) || !o->serialize_subset (c, offset, base))
4306
0
        return_trace (false);
4307
0
    }
4308
4309
0
    return_trace (true);
4310
0
  }
4311
4312
  bool subset (hb_subset_context_t *c) const
4313
0
  {
4314
0
    TRACE_SUBSET (this);
4315
4316
0
    if (unlikely (!c->serializer->embed (this->format))) return_trace (false);
4317
4318
0
    if (!serialize_coverage_offsets (c, backtrack.iter (), this))
4319
0
      return_trace (false);
4320
4321
0
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4322
0
    if (!serialize_coverage_offsets (c, input.iter (), this))
4323
0
      return_trace (false);
4324
4325
0
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4326
0
    if (!serialize_coverage_offsets (c, lookahead.iter (), this))
4327
0
      return_trace (false);
4328
4329
0
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
4330
0
    const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
4331
4332
0
    HBUINT16 *lookupCount = c->serializer->copy<HBUINT16> (lookup.len);
4333
0
    if (!lookupCount) return_trace (false);
4334
4335
0
    unsigned count = serialize_lookuprecord_array (c->serializer, lookup.as_array (), lookup_map);
4336
0
    return_trace (c->serializer->check_assign (*lookupCount, count, HB_SERIALIZE_ERROR_INT_OVERFLOW));
4337
0
  }
4338
4339
  bool sanitize (hb_sanitize_context_t *c) const
4340
2.54k
  {
4341
2.54k
    TRACE_SANITIZE (this);
4342
2.54k
    if (unlikely (!backtrack.sanitize (c, this))) return_trace (false);
4343
2.54k
    hb_barrier ();
4344
2.54k
    const auto &input = StructAfter<decltype (inputX)> (backtrack);
4345
2.54k
    if (unlikely (!input.sanitize (c, this))) return_trace (false);
4346
2.54k
    hb_barrier ();
4347
2.54k
    if (unlikely (!input.len)) return_trace (false); /* To be consistent with Context. */
4348
2.54k
    const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
4349
2.54k
    if (unlikely (!lookahead.sanitize (c, this))) return_trace (false);
4350
2.54k
    hb_barrier ();
4351
2.54k
    const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
4352
2.54k
    return_trace (likely (lookup.sanitize (c)));
4353
2.54k
  }
4354
4355
  protected:
4356
  HBUINT16  format;     /* Format identifier--format = 3 */
4357
  Array16OfOffset16To<Coverage>
4358
    backtrack;    /* Array of coverage tables
4359
           * in backtracking sequence, in  glyph
4360
           * sequence order */
4361
  Array16OfOffset16To<Coverage>
4362
    inputX    ; /* Array of coverage
4363
           * tables in input sequence, in glyph
4364
           * sequence order */
4365
  Array16OfOffset16To<Coverage>
4366
    lookaheadX;   /* Array of coverage tables
4367
           * in lookahead sequence, in glyph
4368
           * sequence order */
4369
  Array16Of<LookupRecord>
4370
    lookupX;    /* Array of LookupRecords--in
4371
           * design order) */
4372
  public:
4373
  DEFINE_SIZE_MIN (10);
4374
};
4375
4376
struct ChainContext
4377
{
4378
  template <typename context_t, typename ...Ts>
4379
  typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
4380
3.44k
  {
4381
3.44k
    if (unlikely (!c->may_dispatch (this, &u.format.v))) return c->no_dispatch_return_value ();
4382
3.44k
    TRACE_DISPATCH (this, u.format.v);
4383
3.44k
    switch (u.format.v) {
4384
0
    case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
4385
0
    case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
4386
3.44k
    case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
4387
#ifndef HB_NO_BEYOND_64K
4388
    case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...));
4389
    case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...));
4390
#endif
4391
0
    default:return_trace (c->default_return_value ());
4392
3.44k
    }
4393
3.44k
  }
hb_sanitize_context_t::return_t OT::ChainContext::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const
Line
Count
Source
4380
2.54k
  {
4381
2.54k
    if (unlikely (!c->may_dispatch (this, &u.format.v))) return c->no_dispatch_return_value ();
4382
2.54k
    TRACE_DISPATCH (this, u.format.v);
4383
2.54k
    switch (u.format.v) {
4384
0
    case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
4385
0
    case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
4386
2.54k
    case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
4387
#ifndef HB_NO_BEYOND_64K
4388
    case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...));
4389
    case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...));
4390
#endif
4391
0
    default:return_trace (c->default_return_value ());
4392
2.54k
    }
4393
2.54k
  }
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::ChainContext::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::ChainContext::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::ChainContext::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::ChainContext::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: hb_subset_context_t::return_t OT::ChainContext::dispatch<hb_subset_context_t>(hb_subset_context_t*) const
Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::ChainContext::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const
OT::hb_accelerate_subtables_context_t::return_t OT::ChainContext::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const
Line
Count
Source
4380
902
  {
4381
902
    if (unlikely (!c->may_dispatch (this, &u.format.v))) return c->no_dispatch_return_value ();
4382
902
    TRACE_DISPATCH (this, u.format.v);
4383
902
    switch (u.format.v) {
4384
0
    case 1: hb_barrier (); return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
4385
0
    case 2: hb_barrier (); return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
4386
902
    case 3: hb_barrier (); return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
4387
#ifndef HB_NO_BEYOND_64K
4388
    case 4: hb_barrier (); return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...));
4389
    case 5: hb_barrier (); return_trace (c->dispatch (u.format5, std::forward<Ts> (ds)...));
4390
#endif
4391
0
    default:return_trace (c->default_return_value ());
4392
902
    }
4393
902
  }
Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::ChainContext::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const
Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::ChainContext::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const
Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::ChainContext::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const
Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::ChainContext::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const
Unexecuted instantiation: hb_collect_glyph_alternates_dispatch_t::return_t OT::ChainContext::dispatch<hb_collect_glyph_alternates_dispatch_t, hb_map_t*&, hb_map_t*&>(hb_collect_glyph_alternates_dispatch_t*, hb_map_t*&, hb_map_t*&) const
Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::ChainContext::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const
4394
4395
  protected:
4396
  union {
4397
  struct { HBUINT16 v; }    format; /* Format identifier */
4398
  ChainContextFormat1_4<SmallTypes> format1;
4399
  ChainContextFormat2_5<SmallTypes> format2;
4400
  ChainContextFormat3     format3;
4401
#ifndef HB_NO_BEYOND_64K
4402
  ChainContextFormat1_4<MediumTypes>  format4;
4403
  ChainContextFormat2_5<MediumTypes>  format5;
4404
#endif
4405
  } u;
4406
};
4407
4408
4409
template <typename T>
4410
struct ExtensionFormat1
4411
{
4412
0
  unsigned int get_type () const { return extensionLookupType; }
Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::get_type() const
Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::get_type() const
4413
4414
  template <typename X>
4415
  const X& get_subtable () const
4416
0
  { return this + reinterpret_cast<const Offset32To<typename T::SubTable> &> (extensionOffset); }
Unexecuted instantiation: OT::Layout::GSUB_impl::SubstLookupSubTable const& OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::get_subtable<OT::Layout::GSUB_impl::SubstLookupSubTable>() const
Unexecuted instantiation: OT::Layout::GPOS_impl::PosLookupSubTable const& OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::get_subtable<OT::Layout::GPOS_impl::PosLookupSubTable>() const
4417
4418
  template <typename context_t, typename ...Ts>
4419
  typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
4420
0
  {
4421
0
    if (unlikely (!c->may_dispatch (this, this))) return c->no_dispatch_return_value ();
4422
0
    TRACE_DISPATCH (this, format);
4423
0
    return_trace (get_subtable<typename T::SubTable> ().dispatch (c, get_type (), std::forward<Ts> (ds)...));
4424
0
  }
Unexecuted instantiation: hb_sanitize_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: hb_sanitize_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const
Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const
Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const
Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const
Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const
Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const
Unexecuted instantiation: hb_collect_glyph_alternates_dispatch_t::return_t OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_collect_glyph_alternates_dispatch_t, hb_map_t*&, hb_map_t*&>(hb_collect_glyph_alternates_dispatch_t*, hb_map_t*&, hb_map_t*&) const
Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const
4425
4426
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
4427
  { dispatch (c); }
4428
4429
  /* This is called from may_dispatch() above with hb_sanitize_context_t. */
4430
  bool sanitize (hb_sanitize_context_t *c) const
4431
0
  {
4432
0
    TRACE_SANITIZE (this);
4433
0
    return_trace (c->check_struct (this) &&
4434
0
      hb_barrier () &&
4435
0
      extensionLookupType != T::SubTable::Extension);
4436
0
  }
Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::sanitize(hb_sanitize_context_t*) const
Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::sanitize(hb_sanitize_context_t*) const
4437
4438
  bool subset (hb_subset_context_t *c) const
4439
0
  {
4440
0
    TRACE_SUBSET (this);
4441
4442
0
    auto *out = c->serializer->start_embed (this);
4443
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
4444
4445
0
    out->format = format;
4446
0
    out->extensionLookupType = extensionLookupType;
4447
4448
0
    const auto& src_offset =
4449
0
        reinterpret_cast<const Offset32To<typename T::SubTable> &> (extensionOffset);
4450
0
    auto& dest_offset =
4451
0
        reinterpret_cast<Offset32To<typename T::SubTable> &> (out->extensionOffset);
4452
4453
0
    return_trace (dest_offset.serialize_subset (c, src_offset, this, get_type ()));
4454
0
  }
Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GPOS_impl::ExtensionPos>::subset(hb_subset_context_t*) const
Unexecuted instantiation: OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::subset(hb_subset_context_t*) const
4455
4456
  protected:
4457
  HBUINT16  format;     /* Format identifier. Set to 1. */
4458
  HBUINT16  extensionLookupType;  /* Lookup type of subtable referenced
4459
           * by ExtensionOffset (i.e. the
4460
           * extension subtable). */
4461
  Offset32  extensionOffset;  /* Offset to the extension subtable,
4462
           * of lookup type subtable. */
4463
  public:
4464
  DEFINE_SIZE_STATIC (8);
4465
};
4466
4467
template <typename T>
4468
struct Extension
4469
{
4470
  unsigned int get_type () const
4471
0
  {
4472
0
    switch (u.format.v) {
4473
0
    case 1: hb_barrier (); return u.format1.get_type ();
4474
0
    default:return 0;
4475
0
    }
4476
0
  }
Unexecuted instantiation: OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::get_type() const
Unexecuted instantiation: OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::get_type() const
4477
  template <typename X>
4478
  const X& get_subtable () const
4479
  {
4480
    switch (u.format.v) {
4481
    case 1: hb_barrier (); return u.format1.template get_subtable<typename T::SubTable> ();
4482
    default:return Null (typename T::SubTable);
4483
    }
4484
  }
4485
4486
  // Specialization of dispatch for subset. dispatch() normally just
4487
  // dispatches to the sub table this points too, but for subset
4488
  // we need to run subset on this subtable too.
4489
  template <typename ...Ts>
4490
  typename hb_subset_context_t::return_t dispatch (hb_subset_context_t *c, Ts&&... ds) const
4491
0
  {
4492
0
    switch (u.format.v) {
4493
0
    case 1: hb_barrier (); return u.format1.subset (c);
4494
0
    default: return c->default_return_value ();
4495
0
    }
4496
0
  }
Unexecuted instantiation: bool OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<>(hb_subset_context_t*) const
Unexecuted instantiation: bool OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<>(hb_subset_context_t*) const
4497
4498
  template <typename context_t, typename ...Ts>
4499
  typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
4500
0
  {
4501
0
    if (unlikely (!c->may_dispatch (this, &u.format.v))) return c->no_dispatch_return_value ();
4502
0
    TRACE_DISPATCH (this, u.format.v);
4503
0
    switch (u.format.v) {
4504
0
    case 1: hb_barrier (); return_trace (u.format1.dispatch (c, std::forward<Ts> (ds)...));
4505
0
    default:return_trace (c->default_return_value ());
4506
0
    }
4507
0
  }
Unexecuted instantiation: hb_sanitize_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: hb_sanitize_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_sanitize_context_t>(hb_sanitize_context_t*) const
Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_collect_variation_indices_context_t>(OT::hb_collect_variation_indices_context_t*) const
Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_have_non_1to1_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_have_non_1to1_context_t>(OT::hb_have_non_1to1_context_t*) const
Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_context_t>(OT::hb_closure_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const
Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const
Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_get_glyph_alternates_dispatch_t, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&>(hb_get_glyph_alternates_dispatch_t*, unsigned int&, unsigned int&, unsigned int*&, unsigned int*&) const
Unexecuted instantiation: hb_collect_glyph_alternates_dispatch_t::return_t OT::Extension<OT::Layout::GSUB_impl::ExtensionSubst>::dispatch<hb_collect_glyph_alternates_dispatch_t, hb_map_t*&, hb_map_t*&>(hb_collect_glyph_alternates_dispatch_t*, hb_map_t*&, hb_map_t*&) const
Unexecuted instantiation: hb_position_single_dispatch_t::return_t OT::Extension<OT::Layout::GPOS_impl::ExtensionPos>::dispatch<hb_position_single_dispatch_t, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&>(hb_position_single_dispatch_t*, hb_font_t*&, hb_blob_t*&, hb_direction_t&, unsigned int&, hb_glyph_position_t&) const
4508
4509
  protected:
4510
  union {
4511
  struct { HBUINT16 v; }  format;   /* Format identifier */
4512
  ExtensionFormat1<T> format1;
4513
  } u;
4514
};
4515
4516
4517
/*
4518
 * GSUB/GPOS Common
4519
 */
4520
4521
struct hb_ot_layout_lookup_accelerator_t
4522
{
4523
  template <typename TLookup>
4524
  static hb_ot_layout_lookup_accelerator_t *create (const TLookup &lookup)
4525
975
  {
4526
975
    unsigned count = lookup.get_subtable_count ();
4527
4528
975
    unsigned size = sizeof (hb_ot_layout_lookup_accelerator_t) -
4529
975
        HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) +
4530
975
        count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t);
4531
4532
    /* The following is a calloc because when we are collecting subtables,
4533
     * some of them might be invalid and hence not collect; as a result,
4534
     * we might not fill in all the count entries of the subtables array.
4535
     * Zeroing it allows the set digest to gatekeep it without having to
4536
     * initialize it further. */
4537
975
    auto *thiz = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (1, size);
4538
975
    if (unlikely (!thiz))
4539
0
      return nullptr;
4540
4541
975
    hb_accelerate_subtables_context_t c_accelerate_subtables (thiz->subtables);
4542
975
    lookup.dispatch (&c_accelerate_subtables);
4543
4544
975
    thiz->digest.init ();
4545
975
    for (auto& subtable : hb_iter (thiz->subtables, count))
4546
1.67k
      thiz->digest.union_ (subtable.digest);
4547
4548
975
    thiz->count = count;
4549
4550
975
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4551
975
    thiz->subtable_cache_user_idx = c_accelerate_subtables.subtable_cache_user_idx;
4552
4553
2.65k
    for (unsigned i = 0; i < count; i++)
4554
1.67k
      if (i != thiz->subtable_cache_user_idx)
4555
1.67k
       thiz->subtables[i].apply_cached_func = thiz->subtables[i].apply_func;
4556
975
#endif
4557
4558
975
    return thiz;
4559
975
  }
OT::hb_ot_layout_lookup_accelerator_t* OT::hb_ot_layout_lookup_accelerator_t::create<OT::Layout::GPOS_impl::PosLookup>(OT::Layout::GPOS_impl::PosLookup const&)
Line
Count
Source
4525
878
  {
4526
878
    unsigned count = lookup.get_subtable_count ();
4527
4528
878
    unsigned size = sizeof (hb_ot_layout_lookup_accelerator_t) -
4529
878
        HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) +
4530
878
        count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t);
4531
4532
    /* The following is a calloc because when we are collecting subtables,
4533
     * some of them might be invalid and hence not collect; as a result,
4534
     * we might not fill in all the count entries of the subtables array.
4535
     * Zeroing it allows the set digest to gatekeep it without having to
4536
     * initialize it further. */
4537
878
    auto *thiz = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (1, size);
4538
878
    if (unlikely (!thiz))
4539
0
      return nullptr;
4540
4541
878
    hb_accelerate_subtables_context_t c_accelerate_subtables (thiz->subtables);
4542
878
    lookup.dispatch (&c_accelerate_subtables);
4543
4544
878
    thiz->digest.init ();
4545
878
    for (auto& subtable : hb_iter (thiz->subtables, count))
4546
1.58k
      thiz->digest.union_ (subtable.digest);
4547
4548
878
    thiz->count = count;
4549
4550
878
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4551
878
    thiz->subtable_cache_user_idx = c_accelerate_subtables.subtable_cache_user_idx;
4552
4553
2.46k
    for (unsigned i = 0; i < count; i++)
4554
1.58k
      if (i != thiz->subtable_cache_user_idx)
4555
1.58k
       thiz->subtables[i].apply_cached_func = thiz->subtables[i].apply_func;
4556
878
#endif
4557
4558
878
    return thiz;
4559
878
  }
OT::hb_ot_layout_lookup_accelerator_t* OT::hb_ot_layout_lookup_accelerator_t::create<OT::Layout::GSUB_impl::SubstLookup>(OT::Layout::GSUB_impl::SubstLookup const&)
Line
Count
Source
4525
97
  {
4526
97
    unsigned count = lookup.get_subtable_count ();
4527
4528
97
    unsigned size = sizeof (hb_ot_layout_lookup_accelerator_t) -
4529
97
        HB_VAR_ARRAY * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t) +
4530
97
        count * sizeof (hb_accelerate_subtables_context_t::hb_applicable_t);
4531
4532
    /* The following is a calloc because when we are collecting subtables,
4533
     * some of them might be invalid and hence not collect; as a result,
4534
     * we might not fill in all the count entries of the subtables array.
4535
     * Zeroing it allows the set digest to gatekeep it without having to
4536
     * initialize it further. */
4537
97
    auto *thiz = (hb_ot_layout_lookup_accelerator_t *) hb_calloc (1, size);
4538
97
    if (unlikely (!thiz))
4539
0
      return nullptr;
4540
4541
97
    hb_accelerate_subtables_context_t c_accelerate_subtables (thiz->subtables);
4542
97
    lookup.dispatch (&c_accelerate_subtables);
4543
4544
97
    thiz->digest.init ();
4545
97
    for (auto& subtable : hb_iter (thiz->subtables, count))
4546
97
      thiz->digest.union_ (subtable.digest);
4547
4548
97
    thiz->count = count;
4549
4550
97
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4551
97
    thiz->subtable_cache_user_idx = c_accelerate_subtables.subtable_cache_user_idx;
4552
4553
194
    for (unsigned i = 0; i < count; i++)
4554
97
      if (i != thiz->subtable_cache_user_idx)
4555
97
       thiz->subtables[i].apply_cached_func = thiz->subtables[i].apply_func;
4556
97
#endif
4557
4558
97
    return thiz;
4559
97
  }
4560
4561
  void fini ()
4562
0
  {
4563
0
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4564
0
    for (unsigned i = 0; i < count; i++)
4565
0
      hb_free (subtables[i].external_cache);
4566
0
#endif
4567
0
  }
4568
4569
  bool may_have (hb_codepoint_t g) const
4570
0
  { return digest.may_have (g); }
4571
4572
#ifndef HB_OPTIMIZE_SIZE
4573
  HB_ALWAYS_INLINE
4574
#endif
4575
  bool apply (hb_ot_apply_context_t *c, bool use_cache) const
4576
157M
  {
4577
157M
    c->lookup_accel = this;
4578
157M
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4579
157M
    if (use_cache)
4580
0
    {
4581
0
      return
4582
0
      + hb_iter (hb_iter (subtables, count))
4583
0
      | hb_map ([&c] (const hb_accelerate_subtables_context_t::hb_applicable_t &_) { return _.apply_cached (c); })
4584
0
      | hb_any
4585
0
      ;
4586
0
    }
4587
157M
    else
4588
157M
#endif
4589
157M
    {
4590
157M
      return
4591
157M
      + hb_iter (hb_iter (subtables, count))
4592
158M
      | hb_map ([&c] (const hb_accelerate_subtables_context_t::hb_applicable_t &_) { return _.apply (c); })
4593
157M
      | hb_any
4594
157M
      ;
4595
157M
    }
4596
0
    return false;
4597
157M
  }
4598
4599
  bool cache_enter (hb_ot_apply_context_t *c) const
4600
7.60M
  {
4601
7.60M
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4602
7.60M
    return subtable_cache_user_idx != (unsigned) -1 &&
4603
0
     subtables[subtable_cache_user_idx].cache_enter (c);
4604
#else
4605
    return false;
4606
#endif
4607
7.60M
  }
4608
  void cache_leave (hb_ot_apply_context_t *c) const
4609
0
  {
4610
0
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4611
0
    subtables[subtable_cache_user_idx].cache_leave (c);
4612
0
#endif
4613
0
  }
4614
4615
4616
  hb_set_digest_t digest;
4617
  private:
4618
  unsigned count = 0; /* Number of subtables in the array. */
4619
#ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE
4620
  unsigned subtable_cache_user_idx = (unsigned) -1;
4621
#endif
4622
  hb_accelerate_subtables_context_t::hb_applicable_t subtables[HB_VAR_ARRAY];
4623
};
4624
4625
template <typename Types>
4626
struct GSUBGPOSVersion1_2
4627
{
4628
  friend struct GSUBGPOS;
4629
4630
  protected:
4631
  FixedVersion<>version;  /* Version of the GSUB/GPOS table--initially set
4632
         * to 0x00010000u */
4633
  typename Types:: template OffsetTo<ScriptList>
4634
    scriptList; /* ScriptList table */
4635
  typename Types::template OffsetTo<FeatureList>
4636
    featureList;  /* FeatureList table */
4637
  typename Types::template OffsetTo<LookupList<Types>>
4638
    lookupList; /* LookupList table */
4639
  Offset32To<FeatureVariations>
4640
    featureVars;  /* Offset to Feature Variations
4641
           table--from beginning of table
4642
         * (may be NULL).  Introduced
4643
         * in version 0x00010001. */
4644
  public:
4645
  DEFINE_SIZE_MIN (4 + 3 * Types::size);
4646
4647
  unsigned int get_size () const
4648
0
  {
4649
0
    return min_size +
4650
0
     (version.to_int () >= 0x00010001u ? featureVars.static_size : 0);
4651
0
  }
4652
4653
  const typename Types::template OffsetTo<LookupList<Types>>* get_lookup_list_offset () const
4654
0
  {
4655
0
    return &lookupList;
4656
0
  }
4657
4658
  template <typename TLookup>
4659
  bool sanitize (hb_sanitize_context_t *c) const
4660
124
  {
4661
124
    TRACE_SANITIZE (this);
4662
124
    typedef List16OfOffsetTo<TLookup, typename Types::HBUINT> TLookupList;
4663
124
    if (unlikely (!(scriptList.sanitize (c, this) &&
4664
124
        featureList.sanitize (c, this) &&
4665
124
        reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList).sanitize (c, this))))
4666
0
      return_trace (false);
4667
4668
124
#ifndef HB_NO_VAR
4669
124
    if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this))))
4670
0
      return_trace (false);
4671
124
#endif
4672
4673
124
    return_trace (true);
4674
124
  }
bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::sanitize<OT::Layout::GSUB_impl::SubstLookup>(hb_sanitize_context_t*) const
Line
Count
Source
4660
62
  {
4661
62
    TRACE_SANITIZE (this);
4662
62
    typedef List16OfOffsetTo<TLookup, typename Types::HBUINT> TLookupList;
4663
62
    if (unlikely (!(scriptList.sanitize (c, this) &&
4664
62
        featureList.sanitize (c, this) &&
4665
62
        reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList).sanitize (c, this))))
4666
0
      return_trace (false);
4667
4668
62
#ifndef HB_NO_VAR
4669
62
    if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this))))
4670
0
      return_trace (false);
4671
62
#endif
4672
4673
62
    return_trace (true);
4674
62
  }
bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::sanitize<OT::Layout::GPOS_impl::PosLookup>(hb_sanitize_context_t*) const
Line
Count
Source
4660
62
  {
4661
62
    TRACE_SANITIZE (this);
4662
62
    typedef List16OfOffsetTo<TLookup, typename Types::HBUINT> TLookupList;
4663
62
    if (unlikely (!(scriptList.sanitize (c, this) &&
4664
62
        featureList.sanitize (c, this) &&
4665
62
        reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList).sanitize (c, this))))
4666
0
      return_trace (false);
4667
4668
62
#ifndef HB_NO_VAR
4669
62
    if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this))))
4670
0
      return_trace (false);
4671
62
#endif
4672
4673
62
    return_trace (true);
4674
62
  }
4675
4676
  template <typename TLookup>
4677
  bool subset (hb_subset_layout_context_t *c) const
4678
0
  {
4679
0
    TRACE_SUBSET (this);
4680
4681
0
    auto *out = c->subset_context->serializer->start_embed (this);
4682
0
    if (unlikely (!c->subset_context->serializer->extend_min (out))) return_trace (false);
4683
4684
0
    out->version = version;
4685
4686
0
    typedef LookupOffsetList<TLookup, typename Types::HBUINT> TLookupList;
4687
0
    reinterpret_cast<typename Types::template OffsetTo<TLookupList> &> (out->lookupList)
4688
0
  .serialize_subset (c->subset_context,
4689
0
         reinterpret_cast<const typename Types::template OffsetTo<TLookupList> &> (lookupList),
4690
0
         this,
4691
0
         c);
4692
4693
0
    reinterpret_cast<typename Types::template OffsetTo<RecordListOfFeature> &> (out->featureList)
4694
0
  .serialize_subset (c->subset_context,
4695
0
         reinterpret_cast<const typename Types::template OffsetTo<RecordListOfFeature> &> (featureList),
4696
0
         this,
4697
0
         c);
4698
4699
0
    out->scriptList.serialize_subset (c->subset_context,
4700
0
              scriptList,
4701
0
              this,
4702
0
              c);
4703
4704
0
#ifndef HB_NO_VAR
4705
0
    if (version.to_int () >= 0x00010001u)
4706
0
    {
4707
0
      auto snapshot = c->subset_context->serializer->snapshot ();
4708
0
      if (!c->subset_context->serializer->extend_min (&out->featureVars))
4709
0
        return_trace (false);
4710
4711
      // if all axes are pinned all feature vars are dropped.
4712
0
      bool ret = !c->subset_context->plan->all_axes_pinned
4713
0
                 && out->featureVars.serialize_subset (c->subset_context, featureVars, this, c);
4714
0
      if (!ret && version.major == 1)
4715
0
      {
4716
0
        c->subset_context->serializer->revert (snapshot);
4717
0
  out->version.major = 1;
4718
0
  out->version.minor = 0;
4719
0
      }
4720
0
    }
4721
0
#endif
4722
4723
0
    return_trace (true);
4724
0
  }
Unexecuted instantiation: bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::subset<OT::Layout::GPOS_impl::PosLookup>(OT::hb_subset_layout_context_t*) const
Unexecuted instantiation: bool OT::GSUBGPOSVersion1_2<OT::Layout::SmallTypes>::subset<OT::Layout::GSUB_impl::SubstLookup>(OT::hb_subset_layout_context_t*) const
4725
};
4726
4727
struct GSUBGPOS
4728
{
4729
  unsigned int get_size () const
4730
0
  {
4731
0
    switch (u.version.major) {
4732
0
    case 1: hb_barrier (); return u.version1.get_size ();
4733
#ifndef HB_NO_BEYOND_64K
4734
    case 2: hb_barrier (); return u.version2.get_size ();
4735
#endif
4736
0
    default: return u.version.static_size;
4737
0
    }
4738
0
  }
4739
4740
  template <typename TLookup>
4741
  bool sanitize (hb_sanitize_context_t *c) const
4742
124
  {
4743
124
    TRACE_SANITIZE (this);
4744
124
    if (unlikely (!u.version.sanitize (c))) return_trace (false);
4745
124
    hb_barrier ();
4746
124
    switch (u.version.major) {
4747
124
    case 1: hb_barrier (); return_trace (u.version1.sanitize<TLookup> (c));
4748
#ifndef HB_NO_BEYOND_64K
4749
    case 2: hb_barrier (); return_trace (u.version2.sanitize<TLookup> (c));
4750
#endif
4751
0
    default: return_trace (true);
4752
124
    }
4753
124
  }
bool OT::GSUBGPOS::sanitize<OT::Layout::GSUB_impl::SubstLookup>(hb_sanitize_context_t*) const
Line
Count
Source
4742
62
  {
4743
62
    TRACE_SANITIZE (this);
4744
62
    if (unlikely (!u.version.sanitize (c))) return_trace (false);
4745
62
    hb_barrier ();
4746
62
    switch (u.version.major) {
4747
62
    case 1: hb_barrier (); return_trace (u.version1.sanitize<TLookup> (c));
4748
#ifndef HB_NO_BEYOND_64K
4749
    case 2: hb_barrier (); return_trace (u.version2.sanitize<TLookup> (c));
4750
#endif
4751
0
    default: return_trace (true);
4752
62
    }
4753
62
  }
bool OT::GSUBGPOS::sanitize<OT::Layout::GPOS_impl::PosLookup>(hb_sanitize_context_t*) const
Line
Count
Source
4742
62
  {
4743
62
    TRACE_SANITIZE (this);
4744
62
    if (unlikely (!u.version.sanitize (c))) return_trace (false);
4745
62
    hb_barrier ();
4746
62
    switch (u.version.major) {
4747
62
    case 1: hb_barrier (); return_trace (u.version1.sanitize<TLookup> (c));
4748
#ifndef HB_NO_BEYOND_64K
4749
    case 2: hb_barrier (); return_trace (u.version2.sanitize<TLookup> (c));
4750
#endif
4751
0
    default: return_trace (true);
4752
62
    }
4753
62
  }
4754
4755
  template <typename TLookup>
4756
  bool subset (hb_subset_layout_context_t *c) const
4757
0
  {
4758
0
    switch (u.version.major) {
4759
0
    case 1: hb_barrier (); return u.version1.subset<TLookup> (c);
4760
#ifndef HB_NO_BEYOND_64K
4761
    case 2: hb_barrier (); return u.version2.subset<TLookup> (c);
4762
#endif
4763
0
    default: return false;
4764
0
    }
4765
0
  }
Unexecuted instantiation: bool OT::GSUBGPOS::subset<OT::Layout::GPOS_impl::PosLookup>(OT::hb_subset_layout_context_t*) const
Unexecuted instantiation: bool OT::GSUBGPOS::subset<OT::Layout::GSUB_impl::SubstLookup>(OT::hb_subset_layout_context_t*) const
4766
4767
  const ScriptList &get_script_list () const
4768
127k
  {
4769
127k
    switch (u.version.major) {
4770
127k
    case 1: hb_barrier (); return this+u.version1.scriptList;
4771
#ifndef HB_NO_BEYOND_64K
4772
    case 2: hb_barrier (); return this+u.version2.scriptList;
4773
#endif
4774
0
    default: return Null (ScriptList);
4775
127k
    }
4776
127k
  }
4777
  const FeatureList &get_feature_list () const
4778
81.1k
  {
4779
81.1k
    switch (u.version.major) {
4780
81.1k
    case 1: hb_barrier (); return this+u.version1.featureList;
4781
#ifndef HB_NO_BEYOND_64K
4782
    case 2: hb_barrier (); return this+u.version2.featureList;
4783
#endif
4784
0
    default: return Null (FeatureList);
4785
81.1k
    }
4786
81.1k
  }
4787
  unsigned int get_lookup_count () const
4788
28.4k
  {
4789
28.4k
    switch (u.version.major) {
4790
28.4k
    case 1: hb_barrier (); return (this+u.version1.lookupList).len;
4791
#ifndef HB_NO_BEYOND_64K
4792
    case 2: hb_barrier (); return (this+u.version2.lookupList).len;
4793
#endif
4794
0
    default: return 0;
4795
28.4k
    }
4796
28.4k
  }
4797
  const Lookup& get_lookup (unsigned int i) const
4798
7.61M
  {
4799
7.61M
    switch (u.version.major) {
4800
7.61M
    case 1: hb_barrier (); return (this+u.version1.lookupList)[i];
4801
#ifndef HB_NO_BEYOND_64K
4802
    case 2: hb_barrier (); return (this+u.version2.lookupList)[i];
4803
#endif
4804
0
    default: return Null (Lookup);
4805
7.61M
    }
4806
7.61M
  }
4807
  const FeatureVariations &get_feature_variations () const
4808
62.4M
  {
4809
62.4M
    switch (u.version.major) {
4810
62.4M
    case 1: hb_barrier (); return (u.version.to_int () >= 0x00010001u && hb_barrier () ? this+u.version1.featureVars : Null (FeatureVariations));
4811
#ifndef HB_NO_BEYOND_64K
4812
    case 2: hb_barrier (); return this+u.version2.featureVars;
4813
#endif
4814
0
    default: return Null (FeatureVariations);
4815
62.4M
    }
4816
62.4M
  }
4817
4818
24.6k
  bool has_data () const { return u.version.to_int (); }
4819
  unsigned int get_script_count () const
4820
417
  { return get_script_list ().len; }
4821
  const Tag& get_script_tag (unsigned int i) const
4822
0
  { return get_script_list ().get_tag (i); }
4823
  unsigned int get_script_tags (unsigned int start_offset,
4824
        unsigned int *script_count /* IN/OUT */,
4825
        hb_tag_t     *script_tags /* OUT */) const
4826
0
  { return get_script_list ().get_tags (start_offset, script_count, script_tags); }
4827
  const Script& get_script (unsigned int i) const
4828
77.5k
  { return get_script_list ()[i]; }
4829
  bool find_script_index (hb_tag_t tag, unsigned int *index) const
4830
49.6k
  { return get_script_list ().find_index (tag, index); }
4831
4832
  unsigned int get_feature_count () const
4833
5.01k
  { return get_feature_list ().len; }
4834
  hb_tag_t get_feature_tag (unsigned int i) const
4835
72.5k
  { return i == Index::NOT_FOUND_INDEX ? HB_TAG_NONE : get_feature_list ().get_tag (i); }
4836
  unsigned int get_feature_tags (unsigned int start_offset,
4837
         unsigned int *feature_count /* IN/OUT */,
4838
         hb_tag_t     *feature_tags /* OUT */) const
4839
0
  { return get_feature_list ().get_tags (start_offset, feature_count, feature_tags); }
4840
  const Feature& get_feature (unsigned int i) const
4841
28.2k
  { return get_feature_list ()[i]; }
4842
  bool find_feature_index (hb_tag_t tag, unsigned int *index) const
4843
0
  { return get_feature_list ().find_index (tag, index); }
4844
4845
  bool find_variations_index (const int *coords, unsigned int num_coords,
4846
            unsigned int *index,
4847
            ItemVarStoreInstancer *instancer) const
4848
62.4M
  {
4849
#ifdef HB_NO_VAR
4850
    *index = FeatureVariations::NOT_FOUND_INDEX;
4851
    return false;
4852
#endif
4853
62.4M
    return get_feature_variations ().find_index (coords, num_coords, index, instancer);
4854
62.4M
  }
4855
  const Feature& get_feature_variation (unsigned int feature_index,
4856
          unsigned int variations_index) const
4857
28.2k
  {
4858
28.2k
#ifndef HB_NO_VAR
4859
28.2k
    if (FeatureVariations::NOT_FOUND_INDEX != variations_index &&
4860
0
  u.version.to_int () >= 0x00010001u)
4861
0
    {
4862
0
      const Feature *feature = get_feature_variations ().find_substitute (variations_index,
4863
0
                    feature_index);
4864
0
      if (feature)
4865
0
  return *feature;
4866
0
    }
4867
28.2k
#endif
4868
28.2k
    return get_feature (feature_index);
4869
28.2k
  }
4870
4871
  void feature_variation_collect_lookups (const hb_set_t *feature_indexes,
4872
            const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map,
4873
            hb_set_t       *lookup_indexes /* OUT */) const
4874
417
  {
4875
417
#ifndef HB_NO_VAR
4876
417
    get_feature_variations ().collect_lookups (feature_indexes, feature_record_cond_idx_map, lookup_indexes);
4877
417
#endif
4878
417
  }
4879
4880
#ifndef HB_NO_VAR
4881
  void collect_feature_substitutes_with_variations (hb_collect_feature_substitutes_with_var_context_t *c) const
4882
0
  { get_feature_variations ().collect_feature_substitutes_with_variations (c); }
4883
#endif
4884
4885
  template <typename TLookup>
4886
  void closure_lookups (hb_face_t      *face,
4887
      const hb_set_t *glyphs,
4888
      hb_set_t       *lookup_indexes /* IN/OUT */) const
4889
0
  {
4890
0
    hb_set_t visited_lookups, inactive_lookups;
4891
0
    hb_closure_lookups_context_t c (face, glyphs, &visited_lookups, &inactive_lookups);
4892
4893
0
    c.set_recurse_func (TLookup::template dispatch_recurse_func<hb_closure_lookups_context_t>);
4894
4895
0
    for (unsigned lookup_index : *lookup_indexes)
4896
0
      reinterpret_cast<const TLookup &> (get_lookup (lookup_index)).closure_lookups (&c, lookup_index);
4897
4898
0
    hb_set_union (lookup_indexes, &visited_lookups);
4899
0
    hb_set_subtract (lookup_indexes, &inactive_lookups);
4900
0
  }
Unexecuted instantiation: void OT::GSUBGPOS::closure_lookups<OT::Layout::GPOS_impl::PosLookup>(hb_face_t*, hb_set_t const*, hb_set_t*) const
Unexecuted instantiation: void OT::GSUBGPOS::closure_lookups<OT::Layout::GSUB_impl::SubstLookup>(hb_face_t*, hb_set_t const*, hb_set_t*) const
4901
4902
  void prune_langsys (const hb_map_t *duplicate_feature_map,
4903
                      const hb_set_t *layout_scripts,
4904
                      hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *script_langsys_map,
4905
                      hb_set_t       *new_feature_indexes /* OUT */) const
4906
0
  {
4907
0
    hb_prune_langsys_context_t c (this, script_langsys_map, duplicate_feature_map, new_feature_indexes);
4908
4909
0
    unsigned count = get_script_count ();
4910
0
    for (unsigned script_index = 0; script_index < count; script_index++)
4911
0
    {
4912
0
      const Tag& tag = get_script_tag (script_index);
4913
0
      if (!layout_scripts->has (tag)) continue;
4914
0
      const Script& s = get_script (script_index);
4915
0
      s.prune_langsys (&c, script_index);
4916
0
    }
4917
0
  }
4918
4919
  void prune_features (const hb_map_t *lookup_indices, /* IN */
4920
           const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map, /* IN */
4921
           const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map, /* IN */
4922
           hb_set_t       *feature_indices /* IN/OUT */) const
4923
0
  {
4924
0
#ifndef HB_NO_VAR
4925
    // This is the set of feature indices which have alternate versions defined
4926
    // if the FeatureVariation's table and the alternate version(s) intersect the
4927
    // set of lookup indices.
4928
0
    hb_set_t alternate_feature_indices;
4929
0
    get_feature_variations ().closure_features (lookup_indices, feature_record_cond_idx_map, &alternate_feature_indices);
4930
0
    if (unlikely (alternate_feature_indices.in_error()))
4931
0
    {
4932
0
      feature_indices->err ();
4933
0
      return;
4934
0
    }
4935
0
#endif
4936
4937
0
    for (unsigned i : hb_iter (feature_indices))
4938
0
    {
4939
0
      hb_tag_t tag =  get_feature_tag (i);
4940
0
      if (tag == HB_TAG ('p', 'r', 'e', 'f'))
4941
        // Note: Never ever drop feature 'pref', even if it's empty.
4942
        // HarfBuzz chooses shaper for Khmer based on presence of this
4943
        // feature. See thread at:
4944
  // http://lists.freedesktop.org/archives/harfbuzz/2012-November/002660.html
4945
0
        continue;
4946
4947
4948
0
      const Feature *f = &(get_feature (i));
4949
0
      const Feature** p = nullptr;
4950
0
      if (feature_substitutes_map->has (i, &p))
4951
0
        f = *p;
4952
4953
0
      if (!f->featureParams.is_null () &&
4954
0
          tag == HB_TAG ('s', 'i', 'z', 'e'))
4955
0
        continue;
4956
4957
0
      if (!f->intersects_lookup_indexes (lookup_indices)
4958
0
#ifndef HB_NO_VAR
4959
0
          && !alternate_feature_indices.has (i)
4960
0
#endif
4961
0
    )
4962
0
  feature_indices->del (i);
4963
0
    }
4964
0
  }
4965
4966
  void collect_name_ids (const hb_map_t *feature_index_map,
4967
                         hb_set_t *nameids_to_retain /* OUT */) const
4968
0
  {
4969
0
    unsigned count = get_feature_count ();
4970
0
    for (unsigned i = 0 ; i < count; i++)
4971
0
    {
4972
0
      if (!feature_index_map->has (i)) continue;
4973
0
      hb_tag_t tag = get_feature_tag (i);
4974
0
      get_feature (i).collect_name_ids (tag, nameids_to_retain);
4975
0
    }
4976
0
  }
4977
4978
  template <typename T>
4979
  struct accelerator_t
4980
  {
4981
    accelerator_t (hb_face_t *face)
4982
124
    {
4983
124
      hb_sanitize_context_t sc;
4984
124
      sc.lazy_some_gpos = true;
4985
124
      this->table = sc.reference_table<T> (face);
4986
4987
124
      if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face)))
4988
0
      {
4989
0
  hb_blob_destroy (this->table.get_blob ());
4990
0
  this->table = hb_blob_get_empty ();
4991
0
      }
4992
4993
124
      this->lookup_count = table->get_lookup_count ();
4994
4995
124
      this->accels = (hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *) hb_calloc (this->lookup_count, sizeof (*accels));
4996
124
      if (unlikely (!this->accels))
4997
0
      {
4998
0
  this->lookup_count = 0;
4999
0
  this->table.destroy ();
5000
0
  this->table = hb_blob_get_empty ();
5001
0
      }
5002
124
    }
OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::accelerator_t(hb_face_t*)
Line
Count
Source
4982
62
    {
4983
62
      hb_sanitize_context_t sc;
4984
62
      sc.lazy_some_gpos = true;
4985
62
      this->table = sc.reference_table<T> (face);
4986
4987
62
      if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face)))
4988
0
      {
4989
0
  hb_blob_destroy (this->table.get_blob ());
4990
0
  this->table = hb_blob_get_empty ();
4991
0
      }
4992
4993
62
      this->lookup_count = table->get_lookup_count ();
4994
4995
62
      this->accels = (hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *) hb_calloc (this->lookup_count, sizeof (*accels));
4996
62
      if (unlikely (!this->accels))
4997
0
      {
4998
0
  this->lookup_count = 0;
4999
0
  this->table.destroy ();
5000
0
  this->table = hb_blob_get_empty ();
5001
0
      }
5002
62
    }
OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::accelerator_t(hb_face_t*)
Line
Count
Source
4982
62
    {
4983
62
      hb_sanitize_context_t sc;
4984
62
      sc.lazy_some_gpos = true;
4985
62
      this->table = sc.reference_table<T> (face);
4986
4987
62
      if (unlikely (this->table->is_blocklisted (this->table.get_blob (), face)))
4988
0
      {
4989
0
  hb_blob_destroy (this->table.get_blob ());
4990
0
  this->table = hb_blob_get_empty ();
4991
0
      }
4992
4993
62
      this->lookup_count = table->get_lookup_count ();
4994
4995
62
      this->accels = (hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *) hb_calloc (this->lookup_count, sizeof (*accels));
4996
62
      if (unlikely (!this->accels))
4997
0
      {
4998
0
  this->lookup_count = 0;
4999
0
  this->table.destroy ();
5000
0
  this->table = hb_blob_get_empty ();
5001
0
      }
5002
62
    }
5003
    ~accelerator_t ()
5004
0
    {
5005
0
      for (unsigned int i = 0; i < this->lookup_count; i++)
5006
0
      {
5007
0
  auto *accel = this->accels[i].get_relaxed ();
5008
0
  if (accel)
5009
0
    accel->fini ();
5010
0
  hb_free (accel);
5011
0
      }
5012
0
      hb_free (this->accels);
5013
0
      this->table.destroy ();
5014
0
    }
Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::~accelerator_t()
Unexecuted instantiation: OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::~accelerator_t()
5015
5016
62.4M
    hb_blob_t *get_blob () const { return table.get_blob (); }
OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::get_blob() const
Line
Count
Source
5016
31.2M
    hb_blob_t *get_blob () const { return table.get_blob (); }
OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::get_blob() const
Line
Count
Source
5016
31.2M
    hb_blob_t *get_blob () const { return table.get_blob (); }
5017
5018
    hb_ot_layout_lookup_accelerator_t *get_accel (unsigned lookup_index) const
5019
127M
    {
5020
127M
      if (unlikely (lookup_index >= lookup_count)) return nullptr;
5021
5022
127M
    retry:
5023
127M
      auto *accel = accels[lookup_index].get_acquire ();
5024
127M
      if (unlikely (!accel))
5025
975
      {
5026
975
  accel = hb_ot_layout_lookup_accelerator_t::create (table->get_lookup (lookup_index));
5027
975
  if (unlikely (!accel))
5028
0
    return nullptr;
5029
5030
975
  if (unlikely (!accels[lookup_index].cmpexch (nullptr, accel)))
5031
0
  {
5032
0
    accel->fini ();
5033
0
    hb_free (accel);
5034
0
    goto retry;
5035
0
  }
5036
975
      }
5037
5038
127M
      return accel;
5039
127M
    }
OT::GSUBGPOS::accelerator_t<OT::Layout::GPOS>::get_accel(unsigned int) const
Line
Count
Source
5019
116M
    {
5020
116M
      if (unlikely (lookup_index >= lookup_count)) return nullptr;
5021
5022
116M
    retry:
5023
116M
      auto *accel = accels[lookup_index].get_acquire ();
5024
116M
      if (unlikely (!accel))
5025
878
      {
5026
878
  accel = hb_ot_layout_lookup_accelerator_t::create (table->get_lookup (lookup_index));
5027
878
  if (unlikely (!accel))
5028
0
    return nullptr;
5029
5030
878
  if (unlikely (!accels[lookup_index].cmpexch (nullptr, accel)))
5031
0
  {
5032
0
    accel->fini ();
5033
0
    hb_free (accel);
5034
0
    goto retry;
5035
0
  }
5036
878
      }
5037
5038
116M
      return accel;
5039
116M
    }
OT::GSUBGPOS::accelerator_t<OT::Layout::GSUB>::get_accel(unsigned int) const
Line
Count
Source
5019
10.9M
    {
5020
10.9M
      if (unlikely (lookup_index >= lookup_count)) return nullptr;
5021
5022
10.9M
    retry:
5023
10.9M
      auto *accel = accels[lookup_index].get_acquire ();
5024
10.9M
      if (unlikely (!accel))
5025
97
      {
5026
97
  accel = hb_ot_layout_lookup_accelerator_t::create (table->get_lookup (lookup_index));
5027
97
  if (unlikely (!accel))
5028
0
    return nullptr;
5029
5030
97
  if (unlikely (!accels[lookup_index].cmpexch (nullptr, accel)))
5031
0
  {
5032
0
    accel->fini ();
5033
0
    hb_free (accel);
5034
0
    goto retry;
5035
0
  }
5036
97
      }
5037
5038
10.9M
      return accel;
5039
10.9M
    }
5040
5041
    hb_blob_ptr_t<T> table;
5042
    unsigned int lookup_count;
5043
    hb_atomic_t<hb_ot_layout_lookup_accelerator_t *> *accels;
5044
  };
5045
5046
  protected:
5047
  union {
5048
  FixedVersion<>      version;  /* Version identifier */
5049
  GSUBGPOSVersion1_2<SmallTypes>  version1;
5050
#ifndef HB_NO_BEYOND_64K
5051
  GSUBGPOSVersion1_2<MediumTypes> version2;
5052
#endif
5053
  } u;
5054
  public:
5055
  DEFINE_SIZE_MIN (4);
5056
};
5057
5058
5059
} /* namespace OT */
5060
5061
5062
#endif /* HB_OT_LAYOUT_GSUBGPOS_HH */