Coverage Report

Created: 2026-07-16 06:17

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