Coverage Report

Created: 2025-12-31 10:39

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