Coverage Report

Created: 2025-12-31 07:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pango/subprojects/harfbuzz/src/hb-ot-layout-common.hh
Line
Count
Source
1
/*
2
 * Copyright © 2007,2008,2009  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_COMMON_HH
30
#define HB_OT_LAYOUT_COMMON_HH
31
32
#include "hb.hh"
33
#include "hb-ot-layout.hh"
34
#include "hb-open-type.hh"
35
#include "hb-set.hh"
36
#include "hb-bimap.hh"
37
38
#include "OT/Layout/Common/Coverage.hh"
39
#include "OT/Layout/types.hh"
40
41
// TODO(garretrieger): cleanup these after migration.
42
using OT::Layout::Common::Coverage;
43
using OT::Layout::Common::RangeRecord;
44
using OT::Layout::SmallTypes;
45
using OT::Layout::MediumTypes;
46
47
48
namespace OT {
49
50
template<typename Iterator>
51
static inline bool ClassDef_serialize (hb_serialize_context_t *c,
52
               Iterator it);
53
54
static bool ClassDef_remap_and_serialize (
55
    hb_serialize_context_t *c,
56
    const hb_set_t &klasses,
57
    bool use_class_zero,
58
    hb_sorted_vector_t<hb_codepoint_pair_t> &glyph_and_klass, /* IN/OUT */
59
    hb_map_t *klass_map /*IN/OUT*/);
60
61
struct hb_collect_feature_substitutes_with_var_context_t
62
{
63
  const hb_map_t *axes_index_tag_map;
64
  const hb_hashmap_t<hb_tag_t, Triple> *axes_location;
65
  hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *record_cond_idx_map;
66
  hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map;
67
  hb_set_t& catch_all_record_feature_idxes;
68
69
  // not stored in subset_plan
70
  hb_set_t *feature_indices;
71
  bool apply;
72
  bool variation_applied;
73
  bool universal;
74
  unsigned cur_record_idx;
75
  hb_hashmap_t<hb::shared_ptr<hb_map_t>, unsigned> *conditionset_map;
76
};
77
78
struct hb_prune_langsys_context_t
79
{
80
  hb_prune_langsys_context_t (const void         *table_,
81
                              hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *script_langsys_map_,
82
                              const hb_map_t     *duplicate_feature_map_,
83
                              hb_set_t           *new_collected_feature_indexes_)
84
      :table (table_),
85
      script_langsys_map (script_langsys_map_),
86
      duplicate_feature_map (duplicate_feature_map_),
87
      new_feature_indexes (new_collected_feature_indexes_),
88
0
      script_count (0),langsys_feature_count (0) {}
89
90
  bool visitScript ()
91
0
  { return script_count++ < HB_MAX_SCRIPTS; }
92
93
  bool visitLangsys (unsigned feature_count)
94
0
  {
95
0
    langsys_feature_count += feature_count;
96
0
    return langsys_feature_count < HB_MAX_LANGSYS_FEATURE_COUNT;
97
0
  }
98
99
  public:
100
  const void *table;
101
  hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *script_langsys_map;
102
  const hb_map_t     *duplicate_feature_map;
103
  hb_set_t           *new_feature_indexes;
104
105
  private:
106
  unsigned script_count;
107
  unsigned langsys_feature_count;
108
};
109
110
struct hb_subset_layout_context_t :
111
  hb_dispatch_context_t<hb_subset_layout_context_t, hb_empty_t, HB_DEBUG_SUBSET>
112
{
113
0
  const char *get_name () { return "SUBSET_LAYOUT"; }
114
0
  static return_t default_return_value () { return hb_empty_t (); }
115
116
  bool visitScript ()
117
0
  {
118
0
    return script_count++ < HB_MAX_SCRIPTS;
119
0
  }
120
121
  bool visitLangSys ()
122
0
  {
123
0
    return langsys_count++ < HB_MAX_LANGSYS;
124
0
  }
125
126
  bool visitFeatureIndex (int count)
127
0
  {
128
0
    feature_index_count += count;
129
0
    return feature_index_count < HB_MAX_FEATURE_INDICES;
130
0
  }
131
132
  bool visitLookupIndex()
133
0
  {
134
0
    lookup_index_count++;
135
0
    return lookup_index_count < HB_MAX_LOOKUP_VISIT_COUNT;
136
0
  }
137
138
  hb_subset_context_t *subset_context;
139
  const hb_tag_t table_tag;
140
  const hb_map_t *lookup_index_map;
141
  const hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *script_langsys_map;
142
  const hb_map_t *feature_index_map;
143
  const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map;
144
  hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map;
145
  const hb_set_t *catch_all_record_feature_idxes;
146
  const hb_hashmap_t<unsigned, hb_pair_t<const void*, const void*>> *feature_idx_tag_map;
147
148
  unsigned cur_script_index;
149
  unsigned cur_feature_var_record_idx;
150
151
  hb_subset_layout_context_t (hb_subset_context_t *c_,
152
            hb_tag_t tag_) :
153
        subset_context (c_),
154
        table_tag (tag_),
155
        cur_script_index (0xFFFFu),
156
        cur_feature_var_record_idx (0u),
157
        script_count (0),
158
        langsys_count (0),
159
        feature_index_count (0),
160
        lookup_index_count (0)
161
0
  {
162
0
    if (tag_ == HB_OT_TAG_GSUB)
163
0
    {
164
0
      lookup_index_map = &c_->plan->gsub_lookups;
165
0
      script_langsys_map = &c_->plan->gsub_langsys;
166
0
      feature_index_map = &c_->plan->gsub_features;
167
0
      feature_substitutes_map = &c_->plan->gsub_feature_substitutes_map;
168
0
      feature_record_cond_idx_map = c_->plan->user_axes_location.is_empty () ? nullptr : &c_->plan->gsub_feature_record_cond_idx_map;
169
0
      catch_all_record_feature_idxes = &c_->plan->gsub_old_features;
170
0
      feature_idx_tag_map = &c_->plan->gsub_old_feature_idx_tag_map;
171
0
    }
172
0
    else
173
0
    {
174
0
      lookup_index_map = &c_->plan->gpos_lookups;
175
0
      script_langsys_map = &c_->plan->gpos_langsys;
176
0
      feature_index_map = &c_->plan->gpos_features;
177
0
      feature_substitutes_map = &c_->plan->gpos_feature_substitutes_map;
178
0
      feature_record_cond_idx_map = c_->plan->user_axes_location.is_empty () ? nullptr : &c_->plan->gpos_feature_record_cond_idx_map;
179
0
      catch_all_record_feature_idxes = &c_->plan->gpos_old_features;
180
0
      feature_idx_tag_map = &c_->plan->gpos_old_feature_idx_tag_map;
181
0
    }
182
0
  }
183
184
  private:
185
  unsigned script_count;
186
  unsigned langsys_count;
187
  unsigned feature_index_count;
188
  unsigned lookup_index_count;
189
};
190
191
struct ItemVariationStore;
192
struct hb_collect_variation_indices_context_t :
193
       hb_dispatch_context_t<hb_collect_variation_indices_context_t>
194
{
195
  template <typename T>
196
0
  return_t dispatch (const T &obj) { obj.collect_variation_indices (this); return hb_empty_t (); }
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat1>(OT::Layout::GPOS_impl::SinglePosFormat1 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_context_t::dispatch<OT::Layout::GPOS_impl::SinglePosFormat2>(OT::Layout::GPOS_impl::SinglePosFormat2 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_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_variation_indices_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_variation_indices_context_t::dispatch<OT::Layout::GPOS_impl::CursivePosFormat1>(OT::Layout::GPOS_impl::CursivePosFormat1 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_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_variation_indices_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_variation_indices_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_variation_indices_context_t::dispatch<OT::ContextFormat1_4<OT::Layout::SmallTypes> >(OT::ContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_context_t::dispatch<OT::ContextFormat2_5<OT::Layout::SmallTypes> >(OT::ContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_context_t::dispatch<OT::ContextFormat3>(OT::ContextFormat3 const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_context_t::dispatch<OT::ChainContextFormat1_4<OT::Layout::SmallTypes> >(OT::ChainContextFormat1_4<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_context_t::dispatch<OT::ChainContextFormat2_5<OT::Layout::SmallTypes> >(OT::ChainContextFormat2_5<OT::Layout::SmallTypes> const&)
Unexecuted instantiation: hb_empty_t OT::hb_collect_variation_indices_context_t::dispatch<OT::ChainContextFormat3>(OT::ChainContextFormat3 const&)
197
0
  static return_t default_return_value () { return hb_empty_t (); }
198
199
  hb_set_t *layout_variation_indices;
200
  const hb_set_t *glyph_set;
201
  const hb_map_t *gpos_lookups;
202
203
  hb_collect_variation_indices_context_t (hb_set_t *layout_variation_indices_,
204
            const hb_set_t *glyph_set_,
205
            const hb_map_t *gpos_lookups_) :
206
          layout_variation_indices (layout_variation_indices_),
207
          glyph_set (glyph_set_),
208
0
          gpos_lookups (gpos_lookups_) {}
209
};
210
211
template<typename OutputArray>
212
struct subset_offset_array_t
213
{
214
  subset_offset_array_t (hb_subset_context_t *subset_context_,
215
       OutputArray& out_,
216
       const void *base_) : subset_context (subset_context_),
217
                out (out_), base (base_) {}
218
219
  template <typename T>
220
  bool operator () (T&& offset)
221
0
  {
222
0
    auto snap = subset_context->serializer->snapshot ();
223
0
    auto *o = out.serialize_append (subset_context->serializer);
224
0
    if (unlikely (!o)) return false;
225
0
    bool ret = o->serialize_subset (subset_context, offset, base);
226
0
    if (!ret)
227
0
    {
228
0
      out.pop ();
229
0
      subset_context->serializer->revert (snap);
230
0
    }
231
0
    return ret;
232
0
  }
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true> const&>(OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::BaseCoord, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >::operator()<OT::OffsetTo<OT::BaseCoord, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::BaseCoord, OT::IntType<unsigned short, 2u>, void, true> const&)
233
234
  private:
235
  hb_subset_context_t *subset_context;
236
  OutputArray &out;
237
  const void *base;
238
};
239
240
241
template<typename OutputArray, typename Arg>
242
struct subset_offset_array_arg_t
243
{
244
  subset_offset_array_arg_t (hb_subset_context_t *subset_context_,
245
           OutputArray& out_,
246
           const void *base_,
247
           Arg &&arg_) : subset_context (subset_context_), out (out_),
248
            base (base_), arg (arg_) {}
249
250
  template <typename T>
251
  bool operator () (T&& offset)
252
0
  {
253
0
    auto snap = subset_context->serializer->snapshot ();
254
0
    auto *o = out.serialize_append (subset_context->serializer);
255
0
    if (unlikely (!o)) return false;
256
0
    bool ret = o->serialize_subset (subset_context, offset, base, arg);
257
0
    if (!ret)
258
0
    {
259
0
      out.pop ();
260
0
      subset_context->serializer->revert (snap);
261
0
    }
262
0
    return ret;
263
0
  }
Unexecuted instantiation: bool OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>::operator()<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>::operator()<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>::operator()<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>::operator()<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>::operator()<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&)
Unexecuted instantiation: bool OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>::operator()<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&>(OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true> const&)
264
265
  private:
266
  hb_subset_context_t *subset_context;
267
  OutputArray &out;
268
  const void *base;
269
  Arg &&arg;
270
};
271
272
/*
273
 * Helper to subset an array of offsets. Subsets the thing pointed to by each offset
274
 * and discards the offset in the array if the subset operation results in an empty
275
 * thing.
276
 */
277
struct
278
{
279
  template<typename OutputArray>
280
  subset_offset_array_t<OutputArray>
281
  operator () (hb_subset_context_t *subset_context, OutputArray& out,
282
         const void *base) const
283
0
  { return subset_offset_array_t<OutputArray> (subset_context, out, base); }
Unexecuted instantiation: hb-face.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-font.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-font.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::BaseCoord, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::BaseCoord, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::BaseCoord, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-metrics.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-var.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-static.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-color.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Sequence<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::AlternateSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Condition, OT::IntType<unsigned int, 4u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::AttachPoint, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::CaretValue, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_t<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::LigGlyph, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_t<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > > OT::$_40::operator()<OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> > >(hb_subset_context_t*, OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> >&, void const*) const
284
285
  /* Variant with one extra argument passed to serialize_subset */
286
  template<typename OutputArray, typename Arg>
287
  subset_offset_array_arg_t<OutputArray, Arg>
288
  operator () (hb_subset_context_t *subset_context, OutputArray& out,
289
         const void *base, Arg &&arg) const
290
0
  { return subset_offset_array_arg_t<OutputArray, Arg> (subset_context, out, base, arg); }
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::LigatureSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::Ligature<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, unsigned int&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, unsigned int&) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::RuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_offset_array_arg_t<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&> OT::$_40::operator()<OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >, hb_map_t const*&>(hb_subset_context_t*, OT::ArrayOf<OT::OffsetTo<OT::ChainRuleSet<OT::Layout::SmallTypes>, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >&, void const*, hb_map_t const*&) const
291
}
292
HB_FUNCOBJ (subset_offset_array);
293
294
template<typename OutputArray>
295
struct subset_record_array_t
296
{
297
  subset_record_array_t (hb_subset_layout_context_t *c_, OutputArray* out_,
298
       const void *base_) : subset_layout_context (c_),
299
                out (out_), base (base_) {}
300
301
  template <typename T>
302
  void
303
  operator () (T&& record)
304
0
  {
305
0
    auto snap = subset_layout_context->subset_context->serializer->snapshot ();
306
0
    bool ret = record.subset (subset_layout_context, base);
307
0
    if (!ret) subset_layout_context->subset_context->serializer->revert (snap);
308
0
    else out->len++;
309
0
  }
Unexecuted instantiation: void OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> >::operator()<OT::Record<OT::LangSys> const&>(OT::Record<OT::LangSys> const&)
Unexecuted instantiation: void OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >::operator()<OT::FeatureTableSubstitutionRecord const&>(OT::FeatureTableSubstitutionRecord const&)
Unexecuted instantiation: void OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >::operator()<OT::FeatureVariationRecord const&>(OT::FeatureVariationRecord const&)
310
311
  private:
312
  hb_subset_layout_context_t *subset_layout_context;
313
  OutputArray *out;
314
  const void *base;
315
};
316
317
template<typename OutputArray, typename Arg>
318
struct subset_record_array_arg_t
319
{
320
  subset_record_array_arg_t (hb_subset_layout_context_t *c_, OutputArray* out_,
321
           const void *base_,
322
           Arg &&arg_) : subset_layout_context (c_),
323
             out (out_), base (base_), arg (arg_) {}
324
325
  template <typename T>
326
  void
327
  operator () (T&& record)
328
0
  {
329
0
    auto snap = subset_layout_context->subset_context->serializer->snapshot ();
330
0
    bool ret = record.subset (subset_layout_context, base, arg);
331
0
    if (!ret) subset_layout_context->subset_context->serializer->revert (snap);
332
0
    else out->len++;
333
0
  }
Unexecuted instantiation: void OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&>::operator()<OT::Record<OT::Feature> const&>(OT::Record<OT::Feature> const&)
Unexecuted instantiation: void OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>::operator()<OT::FeatureVariationRecord const&>(OT::FeatureVariationRecord const&)
334
335
  private:
336
  hb_subset_layout_context_t *subset_layout_context;
337
  OutputArray *out;
338
  const void *base;
339
  Arg &&arg;
340
};
341
342
/*
343
 * Helper to subset a RecordList/record array. Subsets each Record in the array and
344
 * discards the record if the subset operation returns false.
345
 */
346
struct
347
{
348
  template<typename OutputArray>
349
  subset_record_array_t<OutputArray>
350
  operator () (hb_subset_layout_context_t *c, OutputArray* out,
351
         const void *base) const
352
0
  { return subset_record_array_t<OutputArray> (c, out, base); }
Unexecuted instantiation: hb-face.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_38::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-face.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-face.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-font.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_38::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-font.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-font.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_37::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-font.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_37::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-font.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-font.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_37::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-metrics.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_38::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-metrics.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-metrics.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-var.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_38::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-var.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-var.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-static.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_37::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-static.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-static.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_37::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_38::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_38::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-color.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_37::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-color.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-color.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_38::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_record_array_t<OT::RecordArrayOf<OT::LangSys> > OT::$_37::operator()<OT::RecordArrayOf<OT::LangSys> >(OT::hb_subset_layout_context_t*, OT::RecordArrayOf<OT::LangSys>*, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureTableSubstitutionRecord, OT::IntType<unsigned short, 2u> >*, void const*) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_record_array_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > > OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> > >(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*) const
353
354
  /* Variant with one extra argument passed to subset */
355
  template<typename OutputArray, typename Arg>
356
  subset_record_array_arg_t<OutputArray, Arg>
357
  operator () (hb_subset_layout_context_t *c, OutputArray* out,
358
               const void *base, Arg &&arg) const
359
0
  { return subset_record_array_arg_t<OutputArray, Arg> (c, out, base, arg); }
Unexecuted instantiation: hb-face.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_38::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-face.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-font.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_38::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-font.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_37::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-face.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-font.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_37::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-font.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_37::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-layout.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-metrics.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_38::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-metrics.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-var.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_38::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-var.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-static.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_37::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-static.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_37::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-aat-layout.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_38::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_38::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-color.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_37::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-color.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_38::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_38::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_record_array_arg_t<OT::RecordListOfFeature, OT::Feature const*&> OT::$_37::operator()<OT::RecordListOfFeature, OT::Feature const*&>(OT::hb_subset_layout_context_t*, OT::RecordListOfFeature*, void const*, OT::Feature const*&) const
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::subset_record_array_arg_t<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&> OT::$_37::operator()<OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >, bool&>(OT::hb_subset_layout_context_t*, OT::ArrayOf<OT::FeatureVariationRecord, OT::IntType<unsigned int, 4u> >*, void const*, bool&) const
360
}
361
HB_FUNCOBJ (subset_record_array);
362
363
364
template<typename OutputArray>
365
struct serialize_math_record_array_t
366
{
367
  serialize_math_record_array_t (hb_serialize_context_t *serialize_context_,
368
                         OutputArray& out_,
369
                         const void *base_) : serialize_context (serialize_context_),
370
                                              out (out_), base (base_) {}
371
372
  template <typename T>
373
  bool operator () (T&& record)
374
  {
375
    if (!serialize_context->copy (record, base)) return false;
376
    out.len++;
377
    return true;
378
  }
379
380
  private:
381
  hb_serialize_context_t *serialize_context;
382
  OutputArray &out;
383
  const void *base;
384
};
385
386
/*
387
 * Helper to serialize an array of MATH records.
388
 */
389
struct
390
{
391
  template<typename OutputArray>
392
  serialize_math_record_array_t<OutputArray>
393
  operator () (hb_serialize_context_t *serialize_context, OutputArray& out,
394
               const void *base) const
395
  { return serialize_math_record_array_t<OutputArray> (serialize_context, out, base); }
396
397
}
398
HB_FUNCOBJ (serialize_math_record_array);
399
400
/*
401
 *
402
 * OpenType Layout Common Table Formats
403
 *
404
 */
405
406
407
/*
408
 * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList
409
 */
410
411
struct IndexArray : Array16Of<Index>
412
{
413
  bool intersects (const hb_map_t *indexes) const
414
0
  { return hb_any (*this, indexes); }
415
416
  template <typename Iterator,
417
      hb_requires (hb_is_iterator (Iterator))>
418
  void serialize (hb_serialize_context_t *c,
419
      hb_subset_layout_context_t *l,
420
      Iterator it)
421
0
  {
422
0
    if (!it) return;
423
0
    if (unlikely (!c->extend_min ((*this)))) return;
424
0
425
0
    for (const auto _ : it)
426
0
    {
427
0
      if (!l->visitLookupIndex()) break;
428
0
429
0
      Index i;
430
0
      i = _;
431
0
      c->copy (i);
432
0
      this->len++;
433
0
    }
434
0
  }
Unexecuted instantiation: hb-face.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-font.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-face.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_11LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-font.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_11LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-metrics.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-var.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-static.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_11LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-cff1-table.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-cff2-table.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-color.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_10LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_11LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT10IndexArray9serializeI13hb_map_iter_tI16hb_filter_iter_tI10hb_array_tIKNS_5IndexEERPK8hb_map_tRK4$_11LPv0EESB_L24hb_function_sortedness_t0ELSF_0EETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSK_6item_tEEE5valueEvE4typeELSF_0EEEvP22hb_serialize_context_tPNS_26hb_subset_layout_context_tESK_
435
436
  unsigned int get_indexes (unsigned int start_offset,
437
          unsigned int *_count /* IN/OUT */,
438
          unsigned int *_indexes /* OUT */) const
439
0
  {
440
0
    if (_count)
441
0
    {
442
0
      + this->as_array ().sub_array (start_offset, _count)
443
0
      | hb_sink (hb_array (_indexes, *_count))
444
0
      ;
445
0
    }
446
0
    return this->len;
447
0
  }
448
449
  void add_indexes_to (hb_set_t* output /* OUT */) const
450
0
  {
451
0
    output->add_array (as_array ());
452
0
  }
453
};
454
455
456
/* https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
457
struct FeatureParamsSize
458
{
459
  bool sanitize (hb_sanitize_context_t *c) const
460
0
  {
461
0
    TRACE_SANITIZE (this);
462
0
    if (unlikely (!c->check_struct (this))) return_trace (false);
463
0
    hb_barrier ();
464
465
    /* This subtable has some "history", if you will.  Some earlier versions of
466
     * Adobe tools calculated the offset of the FeatureParams subtable from the
467
     * beginning of the FeatureList table!  Now, that is dealt with in the
468
     * Feature implementation.  But we still need to be able to tell junk from
469
     * real data.  Note: We don't check that the nameID actually exists.
470
     *
471
     * Read Roberts wrote on 9/15/06 on opentype-list@indx.co.uk :
472
     *
473
     * Yes, it is correct that a new version of the AFDKO (version 2.0) will be
474
     * coming out soon, and that the makeotf program will build a font with a
475
     * 'size' feature that is correct by the specification.
476
     *
477
     * The specification for this feature tag is in the "OpenType Layout Tag
478
     * Registry". You can see a copy of this at:
479
     * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#tag-size
480
     *
481
     * Here is one set of rules to determine if the 'size' feature is built
482
     * correctly, or as by the older versions of MakeOTF. You may be able to do
483
     * better.
484
     *
485
     * Assume that the offset to the size feature is according to specification,
486
     * and make the following value checks. If it fails, assume the size
487
     * feature is calculated as versions of MakeOTF before the AFDKO 2.0 built it.
488
     * If this fails, reject the 'size' feature. The older makeOTF's calculated the
489
     * offset from the beginning of the FeatureList table, rather than from the
490
     * beginning of the 'size' Feature table.
491
     *
492
     * If "design size" == 0:
493
     *     fails check
494
     *
495
     * Else if ("subfamily identifier" == 0 and
496
     *     "range start" == 0 and
497
     *     "range end" == 0 and
498
     *     "range start" == 0 and
499
     *     "menu name ID" == 0)
500
     *     passes check: this is the format used when there is a design size
501
     * specified, but there is no recommended size range.
502
     *
503
     * Else if ("design size" <  "range start" or
504
     *     "design size" >   "range end" or
505
     *     "range end" <= "range start" or
506
     *     "menu name ID"  < 256 or
507
     *     "menu name ID"  > 32767 or
508
     *     menu name ID is not a name ID which is actually in the name table)
509
     *     fails test
510
     * Else
511
     *     passes test.
512
     */
513
514
0
    if (!designSize)
515
0
      return_trace (false);
516
0
    else if (subfamilyID == 0 &&
517
0
       subfamilyNameID == 0 &&
518
0
       rangeStart == 0 &&
519
0
       rangeEnd == 0)
520
0
      return_trace (true);
521
0
    else if (designSize < rangeStart ||
522
0
       designSize > rangeEnd ||
523
0
       subfamilyNameID < 256 ||
524
0
       subfamilyNameID > 32767)
525
0
      return_trace (false);
526
0
    else
527
0
      return_trace (true);
528
0
  }
529
530
  void collect_name_ids (hb_set_t *nameids_to_retain /* OUT */) const
531
0
  { nameids_to_retain->add (subfamilyNameID); }
532
533
  bool subset (hb_subset_context_t *c) const
534
0
  {
535
0
    TRACE_SUBSET (this);
536
0
    return_trace ((bool) c->serializer->embed (*this));
537
0
  }
538
539
  HBUINT16  designSize; /* Represents the design size in 720/inch
540
         * units (decipoints).  The design size entry
541
         * must be non-zero.  When there is a design
542
         * size but no recommended size range, the
543
         * rest of the array will consist of zeros. */
544
  HBUINT16  subfamilyID;  /* Has no independent meaning, but serves
545
         * as an identifier that associates fonts
546
         * in a subfamily. All fonts which share a
547
         * Preferred or Font Family name and which
548
         * differ only by size range shall have the
549
         * same subfamily value, and no fonts which
550
         * differ in weight or style shall have the
551
         * same subfamily value. If this value is
552
         * zero, the remaining fields in the array
553
         * will be ignored. */
554
  NameID  subfamilyNameID;/* If the preceding value is non-zero, this
555
         * value must be set in the range 256 - 32767
556
         * (inclusive). It records the value of a
557
         * field in the name table, which must
558
         * contain English-language strings encoded
559
         * in Windows Unicode and Macintosh Roman,
560
         * and may contain additional strings
561
         * localized to other scripts and languages.
562
         * Each of these strings is the name an
563
         * application should use, in combination
564
         * with the family name, to represent the
565
         * subfamily in a menu.  Applications will
566
         * choose the appropriate version based on
567
         * their selection criteria. */
568
  HBUINT16  rangeStart; /* Large end of the recommended usage range
569
         * (inclusive), stored in 720/inch units
570
         * (decipoints). */
571
  HBUINT16  rangeEnd; /* Small end of the recommended usage range
572
           (exclusive), stored in 720/inch units
573
         * (decipoints). */
574
  public:
575
  DEFINE_SIZE_STATIC (10);
576
};
577
578
/* https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#ssxx */
579
struct FeatureParamsStylisticSet
580
{
581
  bool sanitize (hb_sanitize_context_t *c) const
582
0
  {
583
0
    TRACE_SANITIZE (this);
584
    /* Right now minorVersion is at zero.  Which means, any table supports
585
     * the uiNameID field. */
586
0
    return_trace (c->check_struct (this));
587
0
  }
588
589
  void collect_name_ids (hb_set_t *nameids_to_retain /* OUT */) const
590
0
  { nameids_to_retain->add (uiNameID); }
591
592
  bool subset (hb_subset_context_t *c) const
593
0
  {
594
0
    TRACE_SUBSET (this);
595
0
    return_trace ((bool) c->serializer->embed (*this));
596
0
  }
597
598
  HBUINT16  version;  /* (set to 0): This corresponds to a “minor”
599
         * version number. Additional data may be
600
         * added to the end of this Feature Parameters
601
         * table in the future. */
602
603
  NameID  uiNameID; /* The 'name' table name ID that specifies a
604
         * string (or strings, for multiple languages)
605
         * for a user-interface label for this
606
         * feature.  The values of uiLabelNameId and
607
         * sampleTextNameId are expected to be in the
608
         * font-specific name ID range (256-32767),
609
         * though that is not a requirement in this
610
         * Feature Parameters specification. The
611
         * user-interface label for the feature can
612
         * be provided in multiple languages. An
613
         * English string should be included as a
614
         * fallback. The string should be kept to a
615
         * minimal length to fit comfortably with
616
         * different application interfaces. */
617
  public:
618
  DEFINE_SIZE_STATIC (4);
619
};
620
621
/* https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#cv01-cv99 */
622
struct FeatureParamsCharacterVariants
623
{
624
  unsigned
625
  get_characters (unsigned start_offset, unsigned *char_count, hb_codepoint_t *chars) const
626
0
  {
627
0
    if (char_count)
628
0
    {
629
0
      + characters.as_array ().sub_array (start_offset, char_count)
630
0
      | hb_sink (hb_array (chars, *char_count))
631
0
      ;
632
0
    }
633
0
    return characters.len;
634
0
  }
635
636
  unsigned get_size () const
637
0
  { return min_size + characters.len * HBUINT24::static_size; }
638
639
  void collect_name_ids (hb_set_t *nameids_to_retain /* OUT */) const
640
0
  {
641
0
    if (featUILableNameID) nameids_to_retain->add (featUILableNameID);
642
0
    if (featUITooltipTextNameID) nameids_to_retain->add (featUITooltipTextNameID);
643
0
    if (sampleTextNameID) nameids_to_retain->add (sampleTextNameID);
644
0
645
0
    if (!firstParamUILabelNameID || !numNamedParameters || numNamedParameters >= 0x7FFF)
646
0
      return;
647
0
648
0
    unsigned last_name_id = (unsigned) firstParamUILabelNameID + (unsigned) numNamedParameters - 1;
649
0
    if (last_name_id >= 256 && last_name_id <= 32767)
650
0
      nameids_to_retain->add_range (firstParamUILabelNameID, last_name_id);
651
0
  }
652
653
  bool subset (hb_subset_context_t *c) const
654
0
  {
655
0
    TRACE_SUBSET (this);
656
0
    return_trace ((bool) c->serializer->embed (*this));
657
0
  }
658
659
  bool sanitize (hb_sanitize_context_t *c) const
660
0
  {
661
0
    TRACE_SANITIZE (this);
662
0
    return_trace (c->check_struct (this) &&
663
0
      characters.sanitize (c));
664
0
  }
665
666
  HBUINT16  format;     /* Format number is set to 0. */
667
  NameID  featUILableNameID;  /* The ‘name’ table name ID that
668
           * specifies a string (or strings,
669
           * for multiple languages) for a
670
           * user-interface label for this
671
           * feature. (May be NULL.) */
672
  NameID  featUITooltipTextNameID;/* The ‘name’ table name ID that
673
           * specifies a string (or strings,
674
           * for multiple languages) that an
675
           * application can use for tooltip
676
           * text for this feature. (May be
677
           * nullptr.) */
678
  NameID  sampleTextNameID; /* The ‘name’ table name ID that
679
           * specifies sample text that
680
           * illustrates the effect of this
681
           * feature. (May be NULL.) */
682
  HBUINT16  numNamedParameters; /* Number of named parameters. (May
683
           * be zero.) */
684
  NameID  firstParamUILabelNameID;/* The first ‘name’ table name ID
685
           * used to specify strings for
686
           * user-interface labels for the
687
           * feature parameters. (Must be zero
688
           * if numParameters is zero.) */
689
  Array16Of<HBUINT24>
690
    characters;   /* Array of the Unicode Scalar Value
691
           * of the characters for which this
692
           * feature provides glyph variants.
693
           * (May be zero.) */
694
  public:
695
  DEFINE_SIZE_ARRAY (14, characters);
696
};
697
698
struct FeatureParams
699
{
700
  bool sanitize (hb_sanitize_context_t *c, hb_tag_t tag) const
701
0
  {
702
#ifdef HB_NO_LAYOUT_FEATURE_PARAMS
703
    return true;
704
#endif
705
0
    TRACE_SANITIZE (this);
706
0
    if (tag == HB_TAG ('s','i','z','e'))
707
0
      return_trace (u.size.sanitize (c));
708
0
    if ((tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */
709
0
      return_trace (u.stylisticSet.sanitize (c));
710
0
    if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */
711
0
      return_trace (u.characterVariants.sanitize (c));
712
0
    return_trace (true);
713
0
  }
714
715
  void collect_name_ids (hb_tag_t tag, hb_set_t *nameids_to_retain /* OUT */) const
716
0
  {
717
0
#ifdef HB_NO_LAYOUT_FEATURE_PARAMS
718
0
    return;
719
0
#endif
720
0
    if (tag == HB_TAG ('s','i','z','e'))
721
0
      return (u.size.collect_name_ids (nameids_to_retain));
722
0
    if ((tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */
723
0
      return (u.stylisticSet.collect_name_ids (nameids_to_retain));
724
0
    if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */
725
0
      return (u.characterVariants.collect_name_ids (nameids_to_retain));
726
0
  }
727
728
  bool subset (hb_subset_context_t *c, const Tag* tag) const
729
0
  {
730
0
    TRACE_SUBSET (this);
731
0
    if (!tag) return_trace (false);
732
0
    if (*tag == HB_TAG ('s','i','z','e'))
733
0
      return_trace (u.size.subset (c));
734
0
    if ((*tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */
735
0
      return_trace (u.stylisticSet.subset (c));
736
0
    if ((*tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */
737
0
      return_trace (u.characterVariants.subset (c));
738
0
    return_trace (false);
739
0
  }
740
741
#ifndef HB_NO_LAYOUT_FEATURE_PARAMS
742
  const FeatureParamsSize& get_size_params (hb_tag_t tag) const
743
0
  {
744
0
    if (tag == HB_TAG ('s','i','z','e'))
745
0
      return u.size;
746
0
    return Null (FeatureParamsSize);
747
0
  }
748
  const FeatureParamsStylisticSet& get_stylistic_set_params (hb_tag_t tag) const
749
0
  {
750
0
    if ((tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */
751
0
      return u.stylisticSet;
752
0
    return Null (FeatureParamsStylisticSet);
753
0
  }
754
  const FeatureParamsCharacterVariants& get_character_variants_params (hb_tag_t tag) const
755
0
  {
756
0
    if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */
757
0
      return u.characterVariants;
758
0
    return Null (FeatureParamsCharacterVariants);
759
0
  }
760
#endif
761
762
  private:
763
  union {
764
  FeatureParamsSize     size;
765
  FeatureParamsStylisticSet   stylisticSet;
766
  FeatureParamsCharacterVariants  characterVariants;
767
  } u;
768
  public:
769
  DEFINE_SIZE_MIN (0);
770
};
771
772
struct Record_sanitize_closure_t {
773
  hb_tag_t tag;
774
  const void *list_base;
775
};
776
777
struct Feature
778
{
779
  unsigned int get_lookup_count () const
780
0
  { return lookupIndex.len; }
781
  hb_tag_t get_lookup_index (unsigned int i) const
782
0
  { return lookupIndex[i]; }
783
  unsigned int get_lookup_indexes (unsigned int start_index,
784
           unsigned int *lookup_count /* IN/OUT */,
785
           unsigned int *lookup_tags /* OUT */) const
786
0
  { return lookupIndex.get_indexes (start_index, lookup_count, lookup_tags); }
787
  void add_lookup_indexes_to (hb_set_t *lookup_indexes) const
788
0
  { lookupIndex.add_indexes_to (lookup_indexes); }
789
790
  const FeatureParams &get_feature_params () const
791
0
  { return this+featureParams; }
792
793
  bool intersects_lookup_indexes (const hb_map_t *lookup_indexes) const
794
0
  { return lookupIndex.intersects (lookup_indexes); }
795
796
  void collect_name_ids (hb_tag_t tag, hb_set_t *nameids_to_retain /* OUT */) const
797
0
  {
798
0
    if (featureParams)
799
0
      get_feature_params ().collect_name_ids (tag, nameids_to_retain);
800
0
  }
801
802
  bool subset (hb_subset_context_t         *c,
803
         hb_subset_layout_context_t  *l,
804
         const Tag                   *tag = nullptr) const
805
0
  {
806
0
    TRACE_SUBSET (this);
807
0
    auto *out = c->serializer->start_embed (*this);
808
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
809
0
810
0
    out->featureParams.serialize_subset (c, featureParams, this, tag);
811
0
812
0
    auto it =
813
0
    + hb_iter (lookupIndex)
814
0
    | hb_filter (l->lookup_index_map)
815
0
    | hb_map (l->lookup_index_map)
816
0
    ;
817
0
818
0
    out->lookupIndex.serialize (c->serializer, l, it);
819
0
    // The decision to keep or drop this feature is already made before we get here
820
0
    // so always retain it.
821
0
    return_trace (true);
822
0
  }
823
824
  bool sanitize (hb_sanitize_context_t *c,
825
     const Record_sanitize_closure_t *closure = nullptr) const
826
0
  {
827
0
    TRACE_SANITIZE (this);
828
0
    if (unlikely (!(c->check_struct (this) && lookupIndex.sanitize (c))))
829
0
      return_trace (false);
830
0
    hb_barrier ();
831
832
    /* Some earlier versions of Adobe tools calculated the offset of the
833
     * FeatureParams subtable from the beginning of the FeatureList table!
834
     *
835
     * If sanitizing "failed" for the FeatureParams subtable, try it with the
836
     * alternative location.  We would know sanitize "failed" if old value
837
     * of the offset was non-zero, but it's zeroed now.
838
     *
839
     * Only do this for the 'size' feature, since at the time of the faulty
840
     * Adobe tools, only the 'size' feature had FeatureParams defined.
841
     */
842
843
0
    if (likely (featureParams.is_null ()))
844
0
      return_trace (true);
845
846
0
    unsigned int orig_offset = featureParams;
847
0
    if (unlikely (!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE)))
848
0
      return_trace (false);
849
0
    hb_barrier ();
850
851
0
    if (featureParams == 0 && closure &&
852
0
  closure->tag == HB_TAG ('s','i','z','e') &&
853
0
  closure->list_base && closure->list_base < this)
854
0
    {
855
0
      unsigned int new_offset_int = orig_offset -
856
0
            (((char *) this) - ((char *) closure->list_base));
857
858
0
      Offset16To<FeatureParams> new_offset;
859
      /* Check that it would not overflow. */
860
0
      new_offset = new_offset_int;
861
0
      if (new_offset == new_offset_int &&
862
0
    c->try_set (&featureParams, new_offset_int) &&
863
0
    !featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))
864
0
  return_trace (false);
865
0
    }
866
867
0
    return_trace (true);
868
0
  }
869
870
  Offset16To<FeatureParams>
871
     featureParams; /* Offset to Feature Parameters table (if one
872
         * has been defined for the feature), relative
873
         * to the beginning of the Feature Table; = Null
874
         * if not required */
875
  IndexArray   lookupIndex; /* Array of LookupList indices */
876
  public:
877
  DEFINE_SIZE_ARRAY_SIZED (4, lookupIndex);
878
};
879
880
template <typename Type>
881
struct Record
882
{
883
0
  int cmp (hb_tag_t a) const { return tag.cmp (a); }
Unexecuted instantiation: OT::Record<OT::LangSys>::cmp(unsigned int) const
Unexecuted instantiation: OT::Record<OT::Script>::cmp(unsigned int) const
Unexecuted instantiation: OT::Record<OT::Feature>::cmp(unsigned int) const
Unexecuted instantiation: OT::Record<OT::JstfLangSys>::cmp(unsigned int) const
Unexecuted instantiation: OT::Record<OT::JstfScript>::cmp(unsigned int) const
884
885
  bool subset (hb_subset_layout_context_t *c, const void *base, const void *f_sub = nullptr) const
886
0
  {
887
0
    TRACE_SUBSET (this);
888
0
    auto *out = c->subset_context->serializer->embed (this);
889
0
    if (unlikely (!out)) return_trace (false);
890
0
891
0
    if (!f_sub)
892
0
      return_trace (out->offset.serialize_subset (c->subset_context, offset, base, c, &tag));
893
0
894
0
    const Feature& f = *reinterpret_cast<const Feature *> (f_sub);
895
0
    auto *s = c->subset_context->serializer;
896
0
    s->push ();
897
0
898
0
    out->offset = 0;
899
0
    bool ret = f.subset (c->subset_context, c, &tag);
900
0
    if (ret)
901
0
      s->add_link (out->offset, s->pop_pack ());
902
0
    else
903
0
      s->pop_discard ();
904
0
905
0
    return_trace (ret);
906
0
  }
Unexecuted instantiation: OT::Record<OT::Feature>::subset(OT::hb_subset_layout_context_t*, void const*, void const*) const
Unexecuted instantiation: OT::Record<OT::LangSys>::subset(OT::hb_subset_layout_context_t*, void const*, void const*) const
Unexecuted instantiation: OT::Record<OT::Script>::subset(OT::hb_subset_layout_context_t*, void const*, void const*) const
907
908
  bool sanitize (hb_sanitize_context_t *c, const void *base) const
909
0
  {
910
0
    TRACE_SANITIZE (this);
911
0
    const Record_sanitize_closure_t closure = {tag, base};
912
0
    return_trace (c->check_struct (this) &&
913
0
      offset.sanitize (c, base, &closure));
914
0
  }
Unexecuted instantiation: OT::Record<OT::LangSys>::sanitize(hb_sanitize_context_t*, void const*) const
Unexecuted instantiation: OT::Record<OT::Script>::sanitize(hb_sanitize_context_t*, void const*) const
Unexecuted instantiation: OT::Record<OT::Feature>::sanitize(hb_sanitize_context_t*, void const*) const
Unexecuted instantiation: OT::Record<OT::JstfLangSys>::sanitize(hb_sanitize_context_t*, void const*) const
Unexecuted instantiation: OT::Record<OT::JstfScript>::sanitize(hb_sanitize_context_t*, void const*) const
915
916
  Tag           tag;            /* 4-byte Tag identifier */
917
  Offset16To<Type>
918
                offset;         /* Offset from beginning of object holding
919
                                 * the Record */
920
  public:
921
  DEFINE_SIZE_STATIC (6);
922
};
923
924
template <typename Type>
925
struct RecordArrayOf : SortedArray16Of<Record<Type>>
926
{
927
  const Offset16To<Type>& get_offset (unsigned int i) const
928
0
  { return (*this)[i].offset; }
Unexecuted instantiation: OT::RecordArrayOf<OT::Script>::get_offset(unsigned int) const
Unexecuted instantiation: OT::RecordArrayOf<OT::Feature>::get_offset(unsigned int) const
929
  Offset16To<Type>& get_offset (unsigned int i)
930
  { return (*this)[i].offset; }
931
  const Tag& get_tag (unsigned int i) const
932
0
  { return (*this)[i].tag; }
Unexecuted instantiation: OT::RecordArrayOf<OT::LangSys>::get_tag(unsigned int) const
Unexecuted instantiation: OT::RecordArrayOf<OT::Script>::get_tag(unsigned int) const
Unexecuted instantiation: OT::RecordArrayOf<OT::Feature>::get_tag(unsigned int) const
Unexecuted instantiation: OT::RecordArrayOf<OT::JstfLangSys>::get_tag(unsigned int) const
Unexecuted instantiation: OT::RecordArrayOf<OT::JstfScript>::get_tag(unsigned int) const
933
  unsigned int get_tags (unsigned int start_offset,
934
                         unsigned int *record_count /* IN/OUT */,
935
                         hb_tag_t     *record_tags /* OUT */) const
936
0
  {
937
0
    if (record_count)
938
0
    {
939
0
      + this->as_array ().sub_array (start_offset, record_count)
940
0
      | hb_map (&Record<Type>::tag)
941
0
      | hb_sink (hb_array (record_tags, *record_count))
942
0
      ;
943
0
    }
944
0
    return this->len;
945
0
  }
Unexecuted instantiation: OT::RecordArrayOf<OT::LangSys>::get_tags(unsigned int, unsigned int*, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::Script>::get_tags(unsigned int, unsigned int*, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::Feature>::get_tags(unsigned int, unsigned int*, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::JstfLangSys>::get_tags(unsigned int, unsigned int*, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::JstfScript>::get_tags(unsigned int, unsigned int*, unsigned int*) const
946
  bool find_index (hb_tag_t tag, unsigned int *index) const
947
0
  {
948
0
    return this->bfind (tag, index, HB_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX);
949
0
  }
Unexecuted instantiation: OT::RecordArrayOf<OT::LangSys>::find_index(unsigned int, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::Script>::find_index(unsigned int, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::Feature>::find_index(unsigned int, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::JstfLangSys>::find_index(unsigned int, unsigned int*) const
Unexecuted instantiation: OT::RecordArrayOf<OT::JstfScript>::find_index(unsigned int, unsigned int*) const
950
};
951
952
template <typename Type>
953
struct RecordListOf : RecordArrayOf<Type>
954
{
955
  const Type& operator [] (unsigned int i) const
956
0
  { return this+this->get_offset (i); }
Unexecuted instantiation: OT::RecordListOf<OT::Script>::operator[](unsigned int) const
Unexecuted instantiation: OT::RecordListOf<OT::Feature>::operator[](unsigned int) const
957
958
  bool subset (hb_subset_context_t *c,
959
               hb_subset_layout_context_t *l) const
960
  {
961
    TRACE_SUBSET (this);
962
    auto *out = c->serializer->start_embed (*this);
963
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
964
965
    + this->iter ()
966
    | hb_apply (subset_record_array (l, out, this))
967
    ;
968
    return_trace (true);
969
  }
970
971
  bool sanitize (hb_sanitize_context_t *c) const
972
0
  {
973
0
    TRACE_SANITIZE (this);
974
0
    return_trace (RecordArrayOf<Type>::sanitize (c, this));
975
0
  }
Unexecuted instantiation: OT::RecordListOf<OT::Script>::sanitize(hb_sanitize_context_t*) const
Unexecuted instantiation: OT::RecordListOf<OT::Feature>::sanitize(hb_sanitize_context_t*) const
976
};
977
978
struct RecordListOfFeature : RecordListOf<Feature>
979
{
980
  bool subset (hb_subset_context_t *c,
981
         hb_subset_layout_context_t *l) const
982
0
  {
983
0
    TRACE_SUBSET (this);
984
0
    auto *out = c->serializer->start_embed (*this);
985
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
986
0
987
0
    + hb_enumerate (*this)
988
0
    | hb_filter (l->feature_index_map, hb_first)
989
0
    | hb_apply ([l, out, this] (const hb_pair_t<unsigned, const Record<Feature>&>& _)
990
0
                {
991
0
                  const Feature *f_sub = nullptr;
992
0
                  const Feature **f = nullptr;
993
0
                  if (l->feature_substitutes_map->has (_.first, &f))
994
0
                    f_sub = *f;
995
0
996
0
                  subset_record_array (l, out, this, f_sub) (_.second);
997
0
                })
998
0
    ;
999
0
1000
0
    return_trace (true);
1001
0
  }
1002
};
1003
1004
typedef RecordListOf<Feature> FeatureList;
1005
1006
1007
struct LangSys
1008
{
1009
  unsigned int get_feature_count () const
1010
0
  { return featureIndex.len; }
1011
  hb_tag_t get_feature_index (unsigned int i) const
1012
0
  { return featureIndex[i]; }
1013
  unsigned int get_feature_indexes (unsigned int start_offset,
1014
            unsigned int *feature_count /* IN/OUT */,
1015
            unsigned int *feature_indexes /* OUT */) const
1016
0
  { return featureIndex.get_indexes (start_offset, feature_count, feature_indexes); }
1017
  void add_feature_indexes_to (hb_set_t *feature_indexes) const
1018
0
  { featureIndex.add_indexes_to (feature_indexes); }
1019
1020
0
  bool has_required_feature () const { return reqFeatureIndex != 0xFFFFu; }
1021
  unsigned int get_required_feature_index () const
1022
0
  {
1023
0
    if (reqFeatureIndex == 0xFFFFu)
1024
0
      return Index::NOT_FOUND_INDEX;
1025
0
   return reqFeatureIndex;
1026
0
  }
1027
1028
  LangSys* copy (hb_serialize_context_t *c) const
1029
0
  {
1030
0
    TRACE_SERIALIZE (this);
1031
0
    return_trace (c->embed (*this));
1032
0
  }
1033
1034
  bool compare (const LangSys& o, const hb_map_t *feature_index_map) const
1035
0
  {
1036
0
    if (reqFeatureIndex != o.reqFeatureIndex)
1037
0
      return false;
1038
0
1039
0
    auto iter =
1040
0
    + hb_iter (featureIndex)
1041
0
    | hb_filter (feature_index_map)
1042
0
    | hb_map (feature_index_map)
1043
0
    ;
1044
0
1045
0
    auto o_iter =
1046
0
    + hb_iter (o.featureIndex)
1047
0
    | hb_filter (feature_index_map)
1048
0
    | hb_map (feature_index_map)
1049
0
    ;
1050
0
1051
0
    for (; iter && o_iter; iter++, o_iter++)
1052
0
    {
1053
0
      unsigned a = *iter;
1054
0
      unsigned b = *o_iter;
1055
0
      if (a != b) return false;
1056
0
    }
1057
0
1058
0
    if (iter || o_iter) return false;
1059
0
1060
0
    return true;
1061
0
  }
1062
1063
  void collect_features (hb_prune_langsys_context_t *c) const
1064
0
  {
1065
0
    if (!has_required_feature () && !get_feature_count ()) return;
1066
0
    if (has_required_feature () &&
1067
0
        c->duplicate_feature_map->has (reqFeatureIndex))
1068
0
      c->new_feature_indexes->add (get_required_feature_index ());
1069
0
1070
0
    + hb_iter (featureIndex)
1071
0
    | hb_filter (c->duplicate_feature_map)
1072
0
    | hb_sink (c->new_feature_indexes)
1073
0
    ;
1074
0
  }
1075
1076
  bool subset (hb_subset_context_t        *c,
1077
         hb_subset_layout_context_t *l,
1078
         const Tag                  *tag = nullptr) const
1079
0
  {
1080
0
    TRACE_SUBSET (this);
1081
0
    auto *out = c->serializer->start_embed (*this);
1082
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
1083
0
1084
0
    const uint32_t *v;
1085
0
    out->reqFeatureIndex = l->feature_index_map->has (reqFeatureIndex, &v) ? *v : 0xFFFFu;
1086
0
1087
0
    if (!l->visitFeatureIndex (featureIndex.len))
1088
0
      return_trace (false);
1089
0
1090
0
    auto it =
1091
0
    + hb_iter (featureIndex)
1092
0
    | hb_filter (l->feature_index_map)
1093
0
    | hb_map (l->feature_index_map)
1094
0
    ;
1095
0
1096
0
    bool ret = bool (it);
1097
0
    out->featureIndex.serialize (c->serializer, l, it);
1098
0
    return_trace (ret);
1099
0
  }
1100
1101
  bool sanitize (hb_sanitize_context_t *c,
1102
     const Record_sanitize_closure_t * = nullptr) const
1103
0
  {
1104
0
    TRACE_SANITIZE (this);
1105
0
    return_trace (c->check_struct (this) && featureIndex.sanitize (c));
1106
0
  }
1107
1108
  Offset16  lookupOrderZ; /* = Null (reserved for an offset to a
1109
         * reordering table) */
1110
  HBUINT16  reqFeatureIndex;/* Index of a feature required for this
1111
         * language system--if no required features
1112
         * = 0xFFFFu */
1113
  IndexArray  featureIndex; /* Array of indices into the FeatureList */
1114
  public:
1115
  DEFINE_SIZE_ARRAY_SIZED (6, featureIndex);
1116
};
1117
DECLARE_NULL_NAMESPACE_BYTES (OT, LangSys);
1118
1119
struct Script
1120
{
1121
  unsigned int get_lang_sys_count () const
1122
0
  { return langSys.len; }
1123
  const Tag& get_lang_sys_tag (unsigned int i) const
1124
0
  { return langSys.get_tag (i); }
1125
  unsigned int get_lang_sys_tags (unsigned int start_offset,
1126
          unsigned int *lang_sys_count /* IN/OUT */,
1127
          hb_tag_t     *lang_sys_tags /* OUT */) const
1128
0
  { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); }
1129
  const LangSys& get_lang_sys (unsigned int i) const
1130
0
  {
1131
0
    if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys ();
1132
0
    return this+langSys[i].offset;
1133
0
  }
1134
  bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const
1135
0
  { return langSys.find_index (tag, index); }
1136
1137
0
  bool has_default_lang_sys () const           { return defaultLangSys != 0; }
1138
0
  const LangSys& get_default_lang_sys () const { return this+defaultLangSys; }
1139
1140
  void prune_langsys (hb_prune_langsys_context_t *c,
1141
                      unsigned script_index) const
1142
0
  {
1143
0
    if (!has_default_lang_sys () && !get_lang_sys_count ()) return;
1144
0
    if (!c->visitScript ()) return;
1145
0
1146
0
    if (!c->script_langsys_map->has (script_index))
1147
0
    {
1148
0
      if (unlikely (!c->script_langsys_map->set (script_index, hb::unique_ptr<hb_set_t> {hb_set_create ()})))
1149
0
  return;
1150
0
    }
1151
0
1152
0
    if (has_default_lang_sys ())
1153
0
    {
1154
0
      //only collect features from non-redundant langsys
1155
0
      const LangSys& d = get_default_lang_sys ();
1156
0
      if (c->visitLangsys (d.get_feature_count ())) {
1157
0
        d.collect_features (c);
1158
0
      }
1159
0
1160
0
      for (auto _ : + hb_enumerate (langSys))
1161
0
      {
1162
0
        const LangSys& l = this+_.second.offset;
1163
0
        if (!c->visitLangsys (l.get_feature_count ())) continue;
1164
0
        if (l.compare (d, c->duplicate_feature_map)) continue;
1165
0
1166
0
        l.collect_features (c);
1167
0
        c->script_langsys_map->get (script_index)->add (_.first);
1168
0
      }
1169
0
    }
1170
0
    else
1171
0
    {
1172
0
      for (auto _ : + hb_enumerate (langSys))
1173
0
      {
1174
0
        const LangSys& l = this+_.second.offset;
1175
0
        if (!c->visitLangsys (l.get_feature_count ())) continue;
1176
0
        l.collect_features (c);
1177
0
        c->script_langsys_map->get (script_index)->add (_.first);
1178
0
      }
1179
0
    }
1180
0
  }
1181
1182
  bool subset (hb_subset_context_t         *c,
1183
         hb_subset_layout_context_t  *l,
1184
         const Tag                   *tag) const
1185
0
  {
1186
0
    TRACE_SUBSET (this);
1187
0
    if (!l->visitScript ()) return_trace (false);
1188
0
    if (tag && !c->plan->layout_scripts.has (*tag))
1189
0
      return false;
1190
0
1191
0
    auto *out = c->serializer->start_embed (*this);
1192
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
1193
0
1194
0
    bool defaultLang = false;
1195
0
    if (has_default_lang_sys ())
1196
0
    {
1197
0
      c->serializer->push ();
1198
0
      const LangSys& ls = this+defaultLangSys;
1199
0
      bool ret = ls.subset (c, l);
1200
0
      if (!ret && tag && *tag != HB_TAG ('D', 'F', 'L', 'T'))
1201
0
      {
1202
0
  c->serializer->pop_discard ();
1203
0
  out->defaultLangSys = 0;
1204
0
      }
1205
0
      else
1206
0
      {
1207
0
  c->serializer->add_link (out->defaultLangSys, c->serializer->pop_pack ());
1208
0
  defaultLang = true;
1209
0
      }
1210
0
    }
1211
0
1212
0
    const hb_set_t *active_langsys = l->script_langsys_map->get (l->cur_script_index);
1213
0
    if (active_langsys)
1214
0
    {
1215
0
      + hb_enumerate (langSys)
1216
0
      | hb_filter (active_langsys, hb_first)
1217
0
      | hb_map (hb_second)
1218
0
      | hb_filter ([=] (const Record<LangSys>& record) {return l->visitLangSys (); })
1219
0
      | hb_apply (subset_record_array (l, &(out->langSys), this))
1220
0
      ;
1221
0
    }
1222
0
1223
0
    return_trace (bool (out->langSys.len) || defaultLang || l->table_tag == HB_OT_TAG_GSUB);
1224
0
  }
1225
1226
  bool sanitize (hb_sanitize_context_t *c,
1227
     const Record_sanitize_closure_t * = nullptr) const
1228
0
  {
1229
0
    TRACE_SANITIZE (this);
1230
0
    return_trace (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this));
1231
0
  }
1232
1233
  protected:
1234
  Offset16To<LangSys>
1235
    defaultLangSys; /* Offset to DefaultLangSys table--from
1236
         * beginning of Script table--may be Null */
1237
  RecordArrayOf<LangSys>
1238
    langSys;  /* Array of LangSysRecords--listed
1239
         * alphabetically by LangSysTag */
1240
  public:
1241
  DEFINE_SIZE_ARRAY_SIZED (4, langSys);
1242
};
1243
1244
struct RecordListOfScript : RecordListOf<Script>
1245
{
1246
  bool subset (hb_subset_context_t *c,
1247
               hb_subset_layout_context_t *l) const
1248
0
  {
1249
0
    TRACE_SUBSET (this);
1250
0
    auto *out = c->serializer->start_embed (*this);
1251
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
1252
0
1253
0
    for (auto _ : + hb_enumerate (*this))
1254
0
    {
1255
0
      auto snap = c->serializer->snapshot ();
1256
0
      l->cur_script_index = _.first;
1257
0
      bool ret = _.second.subset (l, this);
1258
0
      if (!ret) c->serializer->revert (snap);
1259
0
      else out->len++;
1260
0
    }
1261
0
1262
0
    return_trace (true);
1263
0
  }
1264
};
1265
1266
typedef RecordListOfScript ScriptList;
1267
1268
1269
1270
struct LookupFlag : HBUINT16
1271
{
1272
  enum Flags {
1273
    RightToLeft   = 0x0001u,
1274
    IgnoreBaseGlyphs  = 0x0002u,
1275
    IgnoreLigatures = 0x0004u,
1276
    IgnoreMarks   = 0x0008u,
1277
    IgnoreFlags   = 0x000Eu,
1278
    UseMarkFilteringSet = 0x0010u,
1279
    Reserved    = 0x00E0u,
1280
    MarkAttachmentType  = 0xFF00u
1281
  };
1282
  public:
1283
  DEFINE_SIZE_STATIC (2);
1284
};
1285
1286
} /* namespace OT */
1287
/* This has to be outside the namespace. */
1288
HB_MARK_AS_FLAG_T (OT::LookupFlag::Flags);
1289
namespace OT {
1290
1291
struct Lookup
1292
{
1293
0
  unsigned int get_subtable_count () const { return subTable.len; }
1294
1295
  template <typename TSubTable>
1296
  const Array16OfOffset16To<TSubTable>& get_subtables () const
1297
0
  { return reinterpret_cast<const Array16OfOffset16To<TSubTable> &> (subTable); }
Unexecuted instantiation: OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > const& OT::Lookup::get_subtables<OT::Layout::GPOS_impl::PosLookupSubTable>() const
Unexecuted instantiation: OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> > const& OT::Lookup::get_subtables<OT::Layout::GSUB_impl::SubstLookupSubTable>() const
1298
  template <typename TSubTable>
1299
  Array16OfOffset16To<TSubTable>& get_subtables ()
1300
0
  { return reinterpret_cast<Array16OfOffset16To<TSubTable> &> (subTable); }
Unexecuted instantiation: OT::ArrayOf<OT::OffsetTo<OT::Layout::GPOS_impl::PosLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >& OT::Lookup::get_subtables<OT::Layout::GPOS_impl::PosLookupSubTable>()
Unexecuted instantiation: OT::ArrayOf<OT::OffsetTo<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::IntType<unsigned short, 2u>, void, true>, OT::IntType<unsigned short, 2u> >& OT::Lookup::get_subtables<OT::Layout::GSUB_impl::SubstLookupSubTable>()
1301
1302
  template <typename TSubTable>
1303
  const TSubTable& get_subtable (unsigned int i) const
1304
0
  { return this+get_subtables<TSubTable> ()[i]; }
Unexecuted instantiation: OT::Layout::GPOS_impl::PosLookupSubTable const& OT::Lookup::get_subtable<OT::Layout::GPOS_impl::PosLookupSubTable>(unsigned int) const
Unexecuted instantiation: OT::Layout::GSUB_impl::SubstLookupSubTable const& OT::Lookup::get_subtable<OT::Layout::GSUB_impl::SubstLookupSubTable>(unsigned int) const
1305
  template <typename TSubTable>
1306
  TSubTable& get_subtable (unsigned int i)
1307
  { return this+get_subtables<TSubTable> ()[i]; }
1308
1309
  unsigned int get_size () const
1310
0
  {
1311
0
    const HBUINT16 &markFilteringSet = StructAfter<const HBUINT16> (subTable);
1312
0
    if (lookupFlag & LookupFlag::UseMarkFilteringSet)
1313
0
      return (const char *) &StructAfter<const char> (markFilteringSet) - (const char *) this;
1314
0
    return (const char *) &markFilteringSet - (const char *) this;
1315
0
  }
1316
1317
0
  unsigned int get_type () const { return lookupType; }
1318
1319
  /* lookup_props is a 32-bit integer where the lower 16-bit is LookupFlag and
1320
   * higher 16-bit is mark-filtering-set if the lookup uses one.
1321
   * Not to be confused with glyph_props which is very similar. */
1322
  uint32_t get_props () const
1323
0
  {
1324
0
    unsigned int flag = lookupFlag;
1325
0
    if (unlikely (flag & LookupFlag::UseMarkFilteringSet))
1326
0
    {
1327
0
      const HBUINT16 &markFilteringSet = StructAfter<HBUINT16> (subTable);
1328
0
      flag += (markFilteringSet << 16);
1329
0
    }
1330
0
    return flag;
1331
0
  }
1332
1333
  template <typename TSubTable, typename context_t, typename ...Ts>
1334
  typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
1335
0
  {
1336
0
    unsigned int lookup_type = get_type ();
1337
0
    TRACE_DISPATCH (this, lookup_type);
1338
0
    unsigned int count = get_subtable_count ();
1339
0
    for (unsigned int i = 0; i < count; i++) {
1340
0
      typename context_t::return_t r = get_subtable<TSubTable> (i).dispatch (c, lookup_type, std::forward<Ts> (ds)...);
1341
0
      if (c->stop_sublookup_iteration (r))
1342
0
  return_trace (r);
1343
0
    }
1344
0
    return_trace (c->default_return_value ());
1345
0
  }
Unexecuted instantiation: OT::hb_ot_apply_context_t::return_t OT::Lookup::dispatch<OT::Layout::GPOS_impl::PosLookupSubTable, OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Lookup::dispatch<OT::Layout::GPOS_impl::PosLookupSubTable, OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Lookup::dispatch<OT::Layout::GPOS_impl::PosLookupSubTable, OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Lookup::dispatch<OT::Layout::GPOS_impl::PosLookupSubTable, OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: OT::hb_collect_variation_indices_context_t::return_t OT::Lookup::dispatch<OT::Layout::GPOS_impl::PosLookupSubTable, 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::Lookup::dispatch<OT::Layout::GPOS_impl::PosLookupSubTable, 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::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, 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::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::hb_ot_apply_context_t>(OT::hb_ot_apply_context_t*) const
Unexecuted instantiation: OT::hb_intersects_context_t::return_t OT::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::hb_intersects_context_t>(OT::hb_intersects_context_t*) const
Unexecuted instantiation: OT::hb_closure_context_t::return_t OT::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::hb_closure_context_t>(OT::hb_closure_context_t*) const
Unexecuted instantiation: OT::hb_closure_lookups_context_t::return_t OT::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::hb_closure_lookups_context_t>(OT::hb_closure_lookups_context_t*) const
Unexecuted instantiation: OT::hb_collect_glyphs_context_t::return_t OT::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::hb_collect_glyphs_context_t>(OT::hb_collect_glyphs_context_t*) const
Unexecuted instantiation: OT::hb_would_apply_context_t::return_t OT::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::hb_would_apply_context_t>(OT::hb_would_apply_context_t*) const
Unexecuted instantiation: OT::hb_accelerate_subtables_context_t::return_t OT::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, OT::hb_accelerate_subtables_context_t>(OT::hb_accelerate_subtables_context_t*) const
Unexecuted instantiation: hb_get_glyph_alternates_dispatch_t::return_t OT::Lookup::dispatch<OT::Layout::GSUB_impl::SubstLookupSubTable, 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_position_single_dispatch_t::return_t OT::Lookup::dispatch<OT::Layout::GPOS_impl::PosLookupSubTable, 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
1346
1347
  bool serialize (hb_serialize_context_t *c,
1348
      unsigned int lookup_type,
1349
      uint32_t lookup_props,
1350
      unsigned int num_subtables)
1351
0
  {
1352
0
    TRACE_SERIALIZE (this);
1353
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
1354
0
    lookupType = lookup_type;
1355
0
    lookupFlag = lookup_props & 0xFFFFu;
1356
0
    if (unlikely (!subTable.serialize (c, num_subtables))) return_trace (false);
1357
0
    if (lookupFlag & LookupFlag::UseMarkFilteringSet)
1358
0
    {
1359
0
      if (unlikely (!c->extend (this))) return_trace (false);
1360
0
      HBUINT16 &markFilteringSet = StructAfter<HBUINT16> (subTable);
1361
0
      markFilteringSet = lookup_props >> 16;
1362
0
    }
1363
0
    return_trace (true);
1364
0
  }
1365
1366
  template <typename TSubTable>
1367
  bool subset (hb_subset_context_t *c) const
1368
0
  {
1369
0
    TRACE_SUBSET (this);
1370
0
    auto *out = c->serializer->start_embed (*this);
1371
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
1372
0
    out->lookupType = lookupType;
1373
0
    out->lookupFlag = lookupFlag;
1374
0
1375
0
    const hb_set_t *glyphset = c->plan->glyphset_gsub ();
1376
0
    unsigned int lookup_type = get_type ();
1377
0
    + hb_iter (get_subtables <TSubTable> ())
1378
0
    | hb_filter ([this, glyphset, lookup_type] (const Offset16To<TSubTable> &_) { return (this+_).intersects (glyphset, lookup_type); })
1379
0
    | hb_apply (subset_offset_array (c, out->get_subtables<TSubTable> (), this, lookup_type))
1380
0
    ;
1381
0
1382
0
    if (lookupFlag & LookupFlag::UseMarkFilteringSet)
1383
0
    {
1384
0
      const HBUINT16 &markFilteringSet = StructAfter<HBUINT16> (subTable);
1385
0
      hb_codepoint_t *idx;
1386
0
      if (!c->plan->used_mark_sets_map.has (markFilteringSet, &idx))
1387
0
      {
1388
0
        unsigned new_flag = lookupFlag;
1389
0
        new_flag &= ~LookupFlag::UseMarkFilteringSet;
1390
0
        out->lookupFlag = new_flag;
1391
0
      }
1392
0
      else
1393
0
      {
1394
0
        if (unlikely (!c->serializer->extend (out))) return_trace (false);
1395
0
        HBUINT16 &outMarkFilteringSet = StructAfter<HBUINT16> (out->subTable);
1396
0
        outMarkFilteringSet = *idx;
1397
0
      }
1398
0
    }
1399
0
1400
0
    // Always keep the lookup even if it's empty. The rest of layout subsetting depends on lookup
1401
0
    // indices being consistent with those computed during planning. So if an empty lookup is
1402
0
    // discarded during the subset phase it will invalidate all subsequent lookup indices.
1403
0
    // Generally we shouldn't end up with an empty lookup as we pre-prune them during the planning
1404
0
    // phase, but it can happen in rare cases such as when during closure subtable is considered
1405
0
    // degenerate (see: https://github.com/harfbuzz/harfbuzz/issues/3853)
1406
0
    return_trace (true);
1407
0
  }
Unexecuted instantiation: bool OT::Lookup::subset<OT::Layout::GPOS_impl::PosLookupSubTable>(hb_subset_context_t*) const
Unexecuted instantiation: bool OT::Lookup::subset<OT::Layout::GSUB_impl::SubstLookupSubTable>(hb_subset_context_t*) const
1408
1409
  template <typename TSubTable>
1410
  bool sanitize (hb_sanitize_context_t *c) const
1411
0
  {
1412
0
    TRACE_SANITIZE (this);
1413
0
    if (!(c->check_struct (this) && subTable.sanitize (c))) return_trace (false);
1414
0
    hb_barrier ();
1415
1416
0
    unsigned subtables = get_subtable_count ();
1417
0
    if (unlikely (!c->visit_subtables (subtables))) return_trace (false);
1418
1419
0
    if (lookupFlag & LookupFlag::UseMarkFilteringSet)
1420
0
    {
1421
0
      const HBUINT16 &markFilteringSet = StructAfter<HBUINT16> (subTable);
1422
0
      if (!markFilteringSet.sanitize (c)) return_trace (false);
1423
0
    }
1424
1425
0
    if (unlikely (!get_subtables<TSubTable> ().sanitize (c, this, get_type ())))
1426
0
      return_trace (false);
1427
1428
0
    if (unlikely (get_type () == TSubTable::Extension && !c->get_edit_count ()))
1429
0
    {
1430
0
      hb_barrier ();
1431
1432
      /* The spec says all subtables of an Extension lookup should
1433
       * have the same type, which shall not be the Extension type
1434
       * itself (but we already checked for that).
1435
       * This is specially important if one has a reverse type!
1436
       *
1437
       * We only do this if sanitizer edit_count is zero.  Otherwise,
1438
       * some of the subtables might have become insane after they
1439
       * were sanity-checked by the edits of subsequent subtables.
1440
       * https://bugs.chromium.org/p/chromium/issues/detail?id=960331
1441
       */
1442
0
      unsigned int type = get_subtable<TSubTable> (0).u.extension.get_type ();
1443
0
      for (unsigned int i = 1; i < subtables; i++)
1444
0
  if (get_subtable<TSubTable> (i).u.extension.get_type () != type)
1445
0
    return_trace (false);
1446
0
    }
1447
0
    return_trace (true);
1448
0
  }
Unexecuted instantiation: bool OT::Lookup::sanitize<OT::Layout::GPOS_impl::PosLookupSubTable>(hb_sanitize_context_t*) const
Unexecuted instantiation: bool OT::Lookup::sanitize<OT::Layout::GSUB_impl::SubstLookupSubTable>(hb_sanitize_context_t*) const
1449
1450
  protected:
1451
  HBUINT16  lookupType;   /* Different enumerations for GSUB and GPOS */
1452
  HBUINT16  lookupFlag;   /* Lookup qualifiers */
1453
  Array16Of<Offset16>
1454
    subTable;   /* Array of SubTables */
1455
/*HBUINT16  markFilteringSetX[HB_VAR_ARRAY];*//* Index (base 0) into GDEF mark glyph sets
1456
           * structure. This field is only present if bit
1457
           * UseMarkFilteringSet of lookup flags is set. */
1458
  public:
1459
  DEFINE_SIZE_ARRAY (6, subTable);
1460
};
1461
1462
template <typename Types>
1463
using LookupList = List16OfOffsetTo<Lookup, typename Types::HBUINT>;
1464
1465
template <typename TLookup, typename OffsetType>
1466
struct LookupOffsetList : List16OfOffsetTo<TLookup, OffsetType>
1467
{
1468
  bool subset (hb_subset_context_t        *c,
1469
         hb_subset_layout_context_t *l) const
1470
0
  {
1471
0
    TRACE_SUBSET (this);
1472
0
    auto *out = c->serializer->start_embed (this);
1473
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
1474
0
1475
0
    + hb_enumerate (*this)
1476
0
    | hb_filter (l->lookup_index_map, hb_first)
1477
0
    | hb_map (hb_second)
1478
0
    | hb_apply (subset_offset_array (c, *out, this))
1479
0
    ;
1480
0
    return_trace (true);
1481
0
  }
Unexecuted instantiation: OT::LookupOffsetList<OT::Layout::GPOS_impl::PosLookup, OT::IntType<unsigned short, 2u> >::subset(hb_subset_context_t*, OT::hb_subset_layout_context_t*) const
Unexecuted instantiation: OT::LookupOffsetList<OT::Layout::GSUB_impl::SubstLookup, OT::IntType<unsigned short, 2u> >::subset(hb_subset_context_t*, OT::hb_subset_layout_context_t*) const
1482
1483
  bool sanitize (hb_sanitize_context_t *c) const
1484
  {
1485
    TRACE_SANITIZE (this);
1486
    return_trace (List16OfOffset16To<TLookup>::sanitize (c, this));
1487
  }
1488
};
1489
1490
1491
/*
1492
 * Coverage Table
1493
 */
1494
1495
1496
static bool ClassDef_remap_and_serialize (hb_serialize_context_t *c,
1497
            const hb_set_t &klasses,
1498
                                          bool use_class_zero,
1499
                                          hb_sorted_vector_t<hb_codepoint_pair_t> &glyph_and_klass, /* IN/OUT */
1500
            hb_map_t *klass_map /*IN/OUT*/)
1501
0
{
1502
0
  if (!klass_map)
1503
0
    return ClassDef_serialize (c, glyph_and_klass.iter ());
1504
0
1505
0
  /* any glyph not assigned a class value falls into Class zero (0),
1506
0
   * if any glyph assigned to class 0, remapping must start with 0->0*/
1507
0
  if (!use_class_zero)
1508
0
    klass_map->set (0, 0);
1509
0
1510
0
  unsigned idx = klass_map->has (0) ? 1 : 0;
1511
0
  for (const unsigned k: klasses)
1512
0
  {
1513
0
    if (klass_map->has (k)) continue;
1514
0
    klass_map->set (k, idx);
1515
0
    idx++;
1516
0
  }
1517
0
1518
0
1519
0
  for (unsigned i = 0; i < glyph_and_klass.length; i++)
1520
0
  {
1521
0
    hb_codepoint_t klass = glyph_and_klass[i].second;
1522
0
    glyph_and_klass[i].second = klass_map->get (klass);
1523
0
  }
1524
0
1525
0
  c->propagate_error (glyph_and_klass, klasses);
1526
0
  return ClassDef_serialize (c, glyph_and_klass.iter ());
1527
0
}
Unexecuted instantiation: hb-face.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-font.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-face.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-font.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-layout.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-metrics.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-var.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-static.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-aat-layout.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-color.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
Unexecuted instantiation: hb-ot-shape-fallback.cc:OT::ClassDef_remap_and_serialize(hb_serialize_context_t*, hb_set_t const&, bool, hb_vector_t<hb_pair_t<unsigned int, unsigned int>, true>&, hb_map_t*)
1528
1529
/*
1530
 * Class Definition Table
1531
 */
1532
1533
template <typename Types>
1534
struct ClassDefFormat1_3
1535
{
1536
  friend struct ClassDef;
1537
1538
  private:
1539
  unsigned int get_class (hb_codepoint_t glyph_id) const
1540
0
  {
1541
0
    return classValue[(unsigned int) (glyph_id - startGlyph)];
1542
0
  }
1543
1544
  unsigned get_population () const
1545
0
  {
1546
0
    return classValue.len;
1547
0
  }
1548
1549
  template<typename Iterator,
1550
     hb_requires (hb_is_sorted_source_of (Iterator, hb_codepoint_t))>
1551
  bool serialize (hb_serialize_context_t *c,
1552
      Iterator it)
1553
0
  {
1554
0
    TRACE_SERIALIZE (this);
1555
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
1556
0
1557
0
    if (unlikely (!it))
1558
0
    {
1559
0
      classFormat = 1;
1560
0
      startGlyph = 0;
1561
0
      classValue.len = 0;
1562
0
      return_trace (true);
1563
0
    }
1564
0
1565
0
    hb_codepoint_t glyph_min = (*it).first;
1566
0
    hb_codepoint_t glyph_max = + it
1567
0
             | hb_map (hb_first)
1568
0
             | hb_reduce (hb_max, 0u);
1569
0
    unsigned glyph_count = glyph_max - glyph_min + 1;
1570
0
1571
0
    startGlyph = glyph_min;
1572
0
    if (unlikely (!classValue.serialize (c, glyph_count))) return_trace (false);
1573
0
    for (const hb_pair_t<hb_codepoint_t, uint32_t> gid_klass_pair : + it)
1574
0
    {
1575
0
      unsigned idx = gid_klass_pair.first - glyph_min;
1576
0
      classValue[idx] = gid_klass_pair.second;
1577
0
    }
1578
0
    return_trace (true);
1579
0
  }
Unexecuted instantiation: hb-face.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-font.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-face.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-font.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_31RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-metrics.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-var.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-static.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_31RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-cff1-table.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-cff2-table.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-color.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_31RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT17ClassDefFormat1_3INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
1580
1581
  bool subset (hb_subset_context_t *c,
1582
         hb_map_t *klass_map = nullptr /*OUT*/,
1583
               bool keep_empty_table = true,
1584
               bool use_class_zero = true,
1585
               const Coverage* glyph_filter = nullptr) const
1586
0
  {
1587
0
    TRACE_SUBSET (this);
1588
0
    const hb_map_t &glyph_map = c->plan->glyph_map_gsub;
1589
0
1590
0
    hb_sorted_vector_t<hb_codepoint_pair_t> glyph_and_klass;
1591
0
    hb_set_t orig_klasses;
1592
0
1593
0
    hb_codepoint_t start = startGlyph;
1594
0
    hb_codepoint_t end   = start + classValue.len;
1595
0
1596
0
    for (const hb_codepoint_t gid : + hb_range (start, end))
1597
0
    {
1598
0
      hb_codepoint_t new_gid = glyph_map[gid];
1599
0
      if (new_gid == HB_MAP_VALUE_INVALID) continue;
1600
0
      if (glyph_filter && !glyph_filter->has(gid)) continue;
1601
0
1602
0
      unsigned klass = classValue[gid - start];
1603
0
      if (!klass) continue;
1604
0
1605
0
      glyph_and_klass.push (hb_pair (new_gid, klass));
1606
0
      orig_klasses.add (klass);
1607
0
    }
1608
0
1609
0
    if (use_class_zero)
1610
0
    {
1611
0
      unsigned glyph_count = glyph_filter
1612
0
           ? hb_len (hb_iter (glyph_map.keys()) | hb_filter (glyph_filter))
1613
0
           : glyph_map.get_population ();
1614
0
      use_class_zero = glyph_count <= glyph_and_klass.length;
1615
0
    }
1616
0
    if (!ClassDef_remap_and_serialize (c->serializer,
1617
0
                                       orig_klasses,
1618
0
                                       use_class_zero,
1619
0
                                       glyph_and_klass,
1620
0
                                       klass_map))
1621
0
      return_trace (false);
1622
0
    return_trace (keep_empty_table || (bool) glyph_and_klass);
1623
0
  }
1624
1625
  bool sanitize (hb_sanitize_context_t *c) const
1626
0
  {
1627
0
    TRACE_SANITIZE (this);
1628
0
    return_trace (c->check_struct (this) && classValue.sanitize (c));
1629
0
  }
1630
1631
0
  unsigned cost () const { return 1; }
1632
1633
  template <typename set_t>
1634
  bool collect_coverage (set_t *glyphs) const
1635
0
  {
1636
0
    unsigned int start = 0;
1637
0
    unsigned int count = classValue.len;
1638
0
    for (unsigned int i = 0; i < count; i++)
1639
0
    {
1640
0
      if (classValue[i])
1641
0
  continue;
1642
1643
0
      if (start != i)
1644
0
  if (unlikely (!glyphs->add_range (startGlyph + start, startGlyph + i)))
1645
0
    return false;
1646
1647
0
      start = i + 1;
1648
0
    }
1649
0
    if (start != count)
1650
0
      if (unlikely (!glyphs->add_range (startGlyph + start, startGlyph + count)))
1651
0
  return false;
1652
1653
0
    return true;
1654
0
  }
1655
1656
  template <typename set_t>
1657
  bool collect_class (set_t *glyphs, unsigned klass) const
1658
0
  {
1659
0
    unsigned int count = classValue.len;
1660
0
    for (unsigned int i = 0; i < count; i++)
1661
0
      if (classValue[i] == klass) glyphs->add (startGlyph + i);
1662
0
    return true;
1663
0
  }
1664
1665
  bool intersects (const hb_set_t *glyphs) const
1666
0
  {
1667
0
    hb_codepoint_t start = startGlyph;
1668
0
    hb_codepoint_t end = startGlyph + classValue.len;
1669
0
    for (hb_codepoint_t iter = startGlyph - 1;
1670
0
   glyphs->next (&iter) && iter < end;)
1671
0
      if (classValue[iter - start]) return true;
1672
0
    return false;
1673
0
  }
1674
  bool intersects_class (const hb_set_t *glyphs, uint16_t klass) const
1675
0
  {
1676
0
    unsigned int count = classValue.len;
1677
0
    if (klass == 0)
1678
0
    {
1679
      /* Match if there's any glyph that is not listed! */
1680
0
      hb_codepoint_t g = HB_SET_VALUE_INVALID;
1681
0
      if (!glyphs->next (&g)) return false;
1682
0
      if (g < startGlyph) return true;
1683
0
      g = startGlyph + count - 1;
1684
0
      if (glyphs->next (&g)) return true;
1685
      /* Fall through. */
1686
0
    }
1687
    /* TODO Speed up, using set overlap first? */
1688
    /* TODO(iter) Rewrite as dagger. */
1689
0
    const HBUINT16 *arr = classValue.arrayZ;
1690
0
    for (unsigned int i = 0; i < count; i++)
1691
0
      if (arr[i] == klass && glyphs->has (startGlyph + i))
1692
0
  return true;
1693
0
    return false;
1694
0
  }
1695
1696
  void intersected_class_glyphs (const hb_set_t *glyphs, unsigned klass, hb_set_t *intersect_glyphs) const
1697
0
  {
1698
0
    unsigned count = classValue.len;
1699
0
    if (klass == 0)
1700
0
    {
1701
0
      unsigned start_glyph = startGlyph;
1702
0
      for (uint32_t g = HB_SET_VALUE_INVALID;
1703
0
     glyphs->next (&g) && g < start_glyph;)
1704
0
  intersect_glyphs->add (g);
1705
1706
0
      for (uint32_t g = startGlyph + count - 1;
1707
0
     glyphs-> next (&g);)
1708
0
  intersect_glyphs->add (g);
1709
1710
0
      return;
1711
0
    }
1712
1713
0
    for (unsigned i = 0; i < count; i++)
1714
0
      if (classValue[i] == klass && glyphs->has (startGlyph + i))
1715
0
  intersect_glyphs->add (startGlyph + i);
1716
1717
#if 0
1718
    /* The following implementation is faster asymptotically, but slower
1719
     * in practice. */
1720
    unsigned start_glyph = startGlyph;
1721
    unsigned end_glyph = start_glyph + count;
1722
    for (unsigned g = startGlyph - 1;
1723
   glyphs->next (&g) && g < end_glyph;)
1724
      if (classValue.arrayZ[g - start_glyph] == klass)
1725
        intersect_glyphs->add (g);
1726
#endif
1727
0
  }
1728
1729
  void intersected_classes (const hb_set_t *glyphs, hb_set_t *intersect_classes) const
1730
0
  {
1731
0
    if (glyphs->is_empty ()) return;
1732
0
    hb_codepoint_t end_glyph = startGlyph + classValue.len - 1;
1733
0
    if (glyphs->get_min () < startGlyph ||
1734
0
        glyphs->get_max () > end_glyph)
1735
0
      intersect_classes->add (0);
1736
0
1737
0
    for (const auto& _ : + hb_enumerate (classValue))
1738
0
    {
1739
0
      hb_codepoint_t g = startGlyph + _.first;
1740
0
      if (glyphs->has (g))
1741
0
        intersect_classes->add (_.second);
1742
0
    }
1743
0
  }
1744
1745
  protected:
1746
  HBUINT16  classFormat;  /* Format identifier--format = 1 */
1747
  typename Types::HBGlyphID
1748
     startGlyph;  /* First GlyphID of the classValueArray */
1749
  typename Types::template ArrayOf<HBUINT16>
1750
    classValue; /* Array of Class Values--one per GlyphID */
1751
  public:
1752
  DEFINE_SIZE_ARRAY (2 + 2 * Types::size, classValue);
1753
};
1754
1755
template <typename Types>
1756
struct ClassDefFormat2_4
1757
{
1758
  friend struct ClassDef;
1759
1760
  private:
1761
  unsigned int get_class (hb_codepoint_t glyph_id) const
1762
0
  {
1763
0
    return rangeRecord.bsearch (glyph_id).value;
1764
0
  }
1765
1766
  unsigned get_population () const
1767
0
  {
1768
0
    typename Types::large_int ret = 0;
1769
0
    for (const auto &r : rangeRecord)
1770
0
      ret += r.get_population ();
1771
0
    return ret > UINT_MAX ? UINT_MAX : (unsigned) ret;
1772
0
  }
1773
1774
  template<typename Iterator,
1775
     hb_requires (hb_is_sorted_source_of (Iterator, hb_codepoint_t))>
1776
  bool serialize (hb_serialize_context_t *c,
1777
      Iterator it)
1778
0
  {
1779
0
    TRACE_SERIALIZE (this);
1780
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
1781
0
1782
0
    if (unlikely (!it))
1783
0
    {
1784
0
      classFormat = 2;
1785
0
      rangeRecord.len = 0;
1786
0
      return_trace (true);
1787
0
    }
1788
0
1789
0
    unsigned unsorted = false;
1790
0
    unsigned num_ranges = 1;
1791
0
    hb_codepoint_t prev_gid = (*it).first;
1792
0
    unsigned prev_klass = (*it).second;
1793
0
1794
0
    RangeRecord<Types> range_rec;
1795
0
    range_rec.first = prev_gid;
1796
0
    range_rec.last = prev_gid;
1797
0
    range_rec.value = prev_klass;
1798
0
1799
0
    auto *record = c->copy (range_rec);
1800
0
    if (unlikely (!record)) return_trace (false);
1801
0
1802
0
    for (const auto gid_klass_pair : + (++it))
1803
0
    {
1804
0
      hb_codepoint_t cur_gid = gid_klass_pair.first;
1805
0
      unsigned cur_klass = gid_klass_pair.second;
1806
0
1807
0
      if (cur_gid != prev_gid + 1 ||
1808
0
    cur_klass != prev_klass)
1809
0
      {
1810
0
1811
0
  if (unlikely (cur_gid < prev_gid))
1812
0
    unsorted = true;
1813
0
1814
0
  if (unlikely (!record)) break;
1815
0
  record->last = prev_gid;
1816
0
  num_ranges++;
1817
0
1818
0
  range_rec.first = cur_gid;
1819
0
  range_rec.last = cur_gid;
1820
0
  range_rec.value = cur_klass;
1821
0
1822
0
  record = c->copy (range_rec);
1823
0
      }
1824
0
1825
0
      prev_klass = cur_klass;
1826
0
      prev_gid = cur_gid;
1827
0
    }
1828
0
1829
0
    if (unlikely (c->in_error ())) return_trace (false);
1830
0
1831
0
    if (likely (record)) record->last = prev_gid;
1832
0
    rangeRecord.len = num_ranges;
1833
0
1834
0
    if (unlikely (unsorted))
1835
0
      rangeRecord.as_array ().qsort (RangeRecord<Types>::cmp_range);
1836
0
1837
0
    return_trace (true);
1838
0
  }
Unexecuted instantiation: hb-face.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-font.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-face.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-font.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_31RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-metrics.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-var.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-static.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_31RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-cff1-table.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-cff2-table.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_33RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-color.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK4$_31RK4$_10LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT17ClassDefFormat2_4INS_6Layout10SmallTypesEE9serializeI16hb_filter_iter_tI17hb_sorted_array_tIK9hb_pair_tIjjEERK3$_6RK4$_11LPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSK_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSK_
1839
1840
  bool subset (hb_subset_context_t *c,
1841
         hb_map_t *klass_map = nullptr /*OUT*/,
1842
               bool keep_empty_table = true,
1843
               bool use_class_zero = true,
1844
               const Coverage* glyph_filter = nullptr) const
1845
0
  {
1846
0
    TRACE_SUBSET (this);
1847
0
    const hb_map_t &glyph_map = c->plan->glyph_map_gsub;
1848
0
    const hb_set_t &glyph_set = *c->plan->glyphset_gsub ();
1849
0
1850
0
    hb_sorted_vector_t<hb_codepoint_pair_t> glyph_and_klass;
1851
0
    hb_set_t orig_klasses;
1852
0
1853
0
    if (glyph_set.get_population () * hb_bit_storage ((unsigned) rangeRecord.len) / 2
1854
0
  < get_population ())
1855
0
    {
1856
0
      for (hb_codepoint_t g : glyph_set)
1857
0
      {
1858
0
  unsigned klass = get_class (g);
1859
0
  if (!klass) continue;
1860
0
  hb_codepoint_t new_gid = glyph_map[g];
1861
0
  if (new_gid == HB_MAP_VALUE_INVALID) continue;
1862
0
  if (glyph_filter && !glyph_filter->has (g)) continue;
1863
0
  glyph_and_klass.push (hb_pair (new_gid, klass));
1864
0
  orig_klasses.add (klass);
1865
0
      }
1866
0
    }
1867
0
    else
1868
0
    {
1869
0
      unsigned num_source_glyphs = c->plan->source->get_num_glyphs ();
1870
0
      for (auto &range : rangeRecord)
1871
0
      {
1872
0
  unsigned klass = range.value;
1873
0
  if (!klass) continue;
1874
0
  hb_codepoint_t start = range.first;
1875
0
  hb_codepoint_t end   = hb_min (range.last + 1, num_source_glyphs);
1876
0
  for (hb_codepoint_t g = start; g < end; g++)
1877
0
  {
1878
0
    hb_codepoint_t new_gid = glyph_map[g];
1879
0
    if (new_gid == HB_MAP_VALUE_INVALID) continue;
1880
0
    if (glyph_filter && !glyph_filter->has (g)) continue;
1881
0
1882
0
    glyph_and_klass.push (hb_pair (new_gid, klass));
1883
0
    orig_klasses.add (klass);
1884
0
  }
1885
0
      }
1886
0
    }
1887
0
1888
0
    const hb_set_t& glyphset = *c->plan->glyphset_gsub ();
1889
0
    unsigned glyph_count = glyph_filter
1890
0
                           ? hb_len (hb_iter (glyphset) | hb_filter (glyph_filter))
1891
0
                           : glyph_map.get_population ();
1892
0
    use_class_zero = use_class_zero && glyph_count <= glyph_and_klass.length;
1893
0
    if (!ClassDef_remap_and_serialize (c->serializer,
1894
0
                                       orig_klasses,
1895
0
                                       use_class_zero,
1896
0
                                       glyph_and_klass,
1897
0
                                       klass_map))
1898
0
      return_trace (false);
1899
0
    return_trace (keep_empty_table || (bool) glyph_and_klass);
1900
0
  }
1901
1902
  bool sanitize (hb_sanitize_context_t *c) const
1903
0
  {
1904
0
    TRACE_SANITIZE (this);
1905
0
    return_trace (rangeRecord.sanitize (c));
1906
0
  }
1907
1908
0
  unsigned cost () const { return hb_bit_storage ((unsigned) rangeRecord.len); /* bsearch cost */ }
1909
1910
  template <typename set_t>
1911
  bool collect_coverage (set_t *glyphs) const
1912
0
  {
1913
0
    for (auto &range : rangeRecord)
1914
0
      if (range.value)
1915
0
  if (unlikely (!range.collect_coverage (glyphs)))
1916
0
    return false;
1917
0
    return true;
1918
0
  }
1919
1920
  template <typename set_t>
1921
  bool collect_class (set_t *glyphs, unsigned int klass) const
1922
0
  {
1923
0
    for (auto &range : rangeRecord)
1924
0
    {
1925
0
      if (range.value == klass)
1926
0
  if (unlikely (!range.collect_coverage (glyphs)))
1927
0
    return false;
1928
0
    }
1929
0
    return true;
1930
0
  }
1931
1932
  bool intersects (const hb_set_t *glyphs) const
1933
0
  {
1934
0
    if (rangeRecord.len > glyphs->get_population () * hb_bit_storage ((unsigned) rangeRecord.len) / 2)
1935
0
    {
1936
0
      for (auto g : *glyphs)
1937
0
        if (get_class (g))
1938
0
    return true;
1939
0
      return false;
1940
0
    }
1941
0
1942
0
    return hb_any (+ hb_iter (rangeRecord)
1943
0
                   | hb_map ([glyphs] (const RangeRecord<Types> &range) { return range.intersects (*glyphs) && range.value; }));
1944
0
  }
1945
  bool intersects_class (const hb_set_t *glyphs, uint16_t klass) const
1946
0
  {
1947
0
    if (klass == 0)
1948
0
    {
1949
      /* Match if there's any glyph that is not listed! */
1950
0
      hb_codepoint_t g = HB_SET_VALUE_INVALID;
1951
0
      hb_codepoint_t last = HB_SET_VALUE_INVALID;
1952
0
      auto it = hb_iter (rangeRecord);
1953
0
      for (auto &range : it)
1954
0
      {
1955
0
        if (it->first == last + 1)
1956
0
  {
1957
0
    it++;
1958
0
    continue;
1959
0
  }
1960
1961
0
  if (!glyphs->next (&g))
1962
0
    break;
1963
0
  if (g < range.first)
1964
0
    return true;
1965
0
  g = range.last;
1966
0
  last = g;
1967
0
      }
1968
0
      if (g != HB_SET_VALUE_INVALID && glyphs->next (&g))
1969
0
  return true;
1970
      /* Fall through. */
1971
0
    }
1972
0
    for (const auto &range : rangeRecord)
1973
0
      if (range.value == klass && range.intersects (*glyphs))
1974
0
  return true;
1975
0
    return false;
1976
0
  }
1977
1978
  void intersected_class_glyphs (const hb_set_t *glyphs, unsigned klass, hb_set_t *intersect_glyphs) const
1979
0
  {
1980
0
    if (klass == 0)
1981
0
    {
1982
0
      hb_codepoint_t g = HB_SET_VALUE_INVALID;
1983
0
      for (auto &range : rangeRecord)
1984
0
      {
1985
0
  if (!glyphs->next (&g))
1986
0
    goto done;
1987
0
  while (g < range.first)
1988
0
  {
1989
0
    intersect_glyphs->add (g);
1990
0
    if (!glyphs->next (&g))
1991
0
      goto done;
1992
0
        }
1993
0
        g = range.last;
1994
0
      }
1995
0
      while (glyphs->next (&g))
1996
0
  intersect_glyphs->add (g);
1997
0
      done:
1998
1999
0
      return;
2000
0
    }
2001
2002
0
    unsigned count = rangeRecord.len;
2003
0
    if (count > glyphs->get_population () * hb_bit_storage (count) * 8)
2004
0
    {
2005
0
      for (auto g : *glyphs)
2006
0
      {
2007
0
        unsigned i;
2008
0
        if (rangeRecord.as_array ().bfind (g, &i) &&
2009
0
      rangeRecord.arrayZ[i].value == klass)
2010
0
    intersect_glyphs->add (g);
2011
0
      }
2012
0
      return;
2013
0
    }
2014
2015
0
    for (auto &range : rangeRecord)
2016
0
    {
2017
0
      if (range.value != klass) continue;
2018
2019
0
      unsigned end = range.last + 1;
2020
0
      for (hb_codepoint_t g = range.first - 1;
2021
0
     glyphs->next (&g) && g < end;)
2022
0
  intersect_glyphs->add (g);
2023
0
    }
2024
0
  }
2025
2026
  void intersected_classes (const hb_set_t *glyphs, hb_set_t *intersect_classes) const
2027
0
  {
2028
0
    if (glyphs->is_empty ()) return;
2029
0
2030
0
    hb_codepoint_t g = HB_SET_VALUE_INVALID;
2031
0
    for (auto &range : rangeRecord)
2032
0
    {
2033
0
      if (!glyphs->next (&g))
2034
0
        break;
2035
0
      if (g < range.first)
2036
0
      {
2037
0
        intersect_classes->add (0);
2038
0
        break;
2039
0
      }
2040
0
      g = range.last;
2041
0
    }
2042
0
    if (g != HB_SET_VALUE_INVALID && glyphs->next (&g))
2043
0
      intersect_classes->add (0);
2044
0
2045
0
    for (const auto& range : rangeRecord)
2046
0
      if (range.intersects (*glyphs))
2047
0
        intersect_classes->add (range.value);
2048
0
  }
2049
2050
  protected:
2051
  HBUINT16  classFormat;  /* Format identifier--format = 2 */
2052
  typename Types::template SortedArrayOf<RangeRecord<Types>>
2053
    rangeRecord;  /* Array of glyph ranges--ordered by
2054
         * Start GlyphID */
2055
  public:
2056
  DEFINE_SIZE_ARRAY (2 + Types::size, rangeRecord);
2057
};
2058
2059
struct ClassDef
2060
{
2061
  /* Has interface. */
2062
0
  unsigned operator [] (hb_codepoint_t k) const { return get (k); }
2063
0
  bool has (hb_codepoint_t k) const { return (*this)[k]; }
2064
  /* Projection. */
2065
0
  hb_codepoint_t operator () (hb_codepoint_t k) const { return get (k); }
2066
2067
0
  unsigned int get (hb_codepoint_t k) const { return get_class (k); }
2068
  unsigned int get_class (hb_codepoint_t glyph_id) const
2069
0
  {
2070
0
    switch (u.format) {
2071
0
    case 1: return u.format1.get_class (glyph_id);
2072
0
    case 2: return u.format2.get_class (glyph_id);
2073
#ifndef HB_NO_BEYOND_64K
2074
    case 3: return u.format3.get_class (glyph_id);
2075
    case 4: return u.format4.get_class (glyph_id);
2076
#endif
2077
0
    default:return 0;
2078
0
    }
2079
0
  }
2080
2081
  unsigned get_population () const
2082
0
  {
2083
0
    switch (u.format) {
2084
0
    case 1: return u.format1.get_population ();
2085
0
    case 2: return u.format2.get_population ();
2086
0
#ifndef HB_NO_BEYOND_64K
2087
0
    case 3: return u.format3.get_population ();
2088
0
    case 4: return u.format4.get_population ();
2089
0
#endif
2090
0
    default:return NOT_COVERED;
2091
0
    }
2092
0
  }
2093
2094
  template<typename Iterator,
2095
     hb_requires (hb_is_sorted_source_of (Iterator, hb_codepoint_t))>
2096
  bool serialize (hb_serialize_context_t *c, Iterator it_with_class_zero)
2097
0
  {
2098
0
    TRACE_SERIALIZE (this);
2099
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
2100
0
2101
0
    auto it = + it_with_class_zero | hb_filter (hb_second);
2102
0
2103
0
    unsigned format = 2;
2104
0
    hb_codepoint_t glyph_max = 0;
2105
0
    if (likely (it))
2106
0
    {
2107
0
      hb_codepoint_t glyph_min = (*it).first;
2108
0
      glyph_max = glyph_min;
2109
0
2110
0
      unsigned num_glyphs = 0;
2111
0
      unsigned num_ranges = 1;
2112
0
      hb_codepoint_t prev_gid = glyph_min;
2113
0
      unsigned prev_klass = (*it).second;
2114
0
2115
0
      for (const auto gid_klass_pair : it)
2116
0
      {
2117
0
  hb_codepoint_t cur_gid = gid_klass_pair.first;
2118
0
  unsigned cur_klass = gid_klass_pair.second;
2119
0
        num_glyphs++;
2120
0
  if (cur_gid == glyph_min) continue;
2121
0
        if (cur_gid > glyph_max) glyph_max = cur_gid;
2122
0
  if (cur_gid != prev_gid + 1 ||
2123
0
      cur_klass != prev_klass)
2124
0
    num_ranges++;
2125
0
2126
0
  prev_gid = cur_gid;
2127
0
  prev_klass = cur_klass;
2128
0
      }
2129
0
2130
0
      if (num_glyphs && 1 + (glyph_max - glyph_min + 1) <= num_ranges * 3)
2131
0
  format = 1;
2132
0
    }
2133
0
2134
0
#ifndef HB_NO_BEYOND_64K
2135
0
    if (glyph_max > 0xFFFFu)
2136
0
      u.format += 2;
2137
0
    if (unlikely (glyph_max > 0xFFFFFFu))
2138
0
#else
2139
0
    if (unlikely (glyph_max > 0xFFFFu))
2140
0
#endif
2141
0
    {
2142
0
      c->check_success (false, HB_SERIALIZE_ERROR_INT_OVERFLOW);
2143
0
      return_trace (false);
2144
0
    }
2145
0
2146
0
    u.format = format;
2147
0
2148
0
    switch (u.format)
2149
0
    {
2150
0
    case 1: return_trace (u.format1.serialize (c, it));
2151
0
    case 2: return_trace (u.format2.serialize (c, it));
2152
0
#ifndef HB_NO_BEYOND_64K
2153
0
    case 3: return_trace (u.format3.serialize (c, it));
2154
0
    case 4: return_trace (u.format4.serialize (c, it));
2155
0
#endif
2156
0
    default:return_trace (false);
2157
0
    }
2158
0
  }
2159
2160
  bool subset (hb_subset_context_t *c,
2161
         hb_map_t *klass_map = nullptr /*OUT*/,
2162
               bool keep_empty_table = true,
2163
               bool use_class_zero = true,
2164
               const Coverage* glyph_filter = nullptr) const
2165
0
  {
2166
0
    TRACE_SUBSET (this);
2167
0
    switch (u.format) {
2168
0
    case 1: return_trace (u.format1.subset (c, klass_map, keep_empty_table, use_class_zero, glyph_filter));
2169
0
    case 2: return_trace (u.format2.subset (c, klass_map, keep_empty_table, use_class_zero, glyph_filter));
2170
0
#ifndef HB_NO_BEYOND_64K
2171
0
    case 3: return_trace (u.format3.subset (c, klass_map, keep_empty_table, use_class_zero, glyph_filter));
2172
0
    case 4: return_trace (u.format4.subset (c, klass_map, keep_empty_table, use_class_zero, glyph_filter));
2173
0
#endif
2174
0
    default:return_trace (false);
2175
0
    }
2176
0
  }
2177
2178
  bool sanitize (hb_sanitize_context_t *c) const
2179
0
  {
2180
0
    TRACE_SANITIZE (this);
2181
0
    if (!u.format.sanitize (c)) return_trace (false);
2182
0
    hb_barrier ();
2183
0
    switch (u.format) {
2184
0
    case 1: return_trace (u.format1.sanitize (c));
2185
0
    case 2: return_trace (u.format2.sanitize (c));
2186
#ifndef HB_NO_BEYOND_64K
2187
    case 3: return_trace (u.format3.sanitize (c));
2188
    case 4: return_trace (u.format4.sanitize (c));
2189
#endif
2190
0
    default:return_trace (true);
2191
0
    }
2192
0
  }
2193
2194
  unsigned cost () const
2195
0
  {
2196
0
    switch (u.format) {
2197
0
    case 1: return u.format1.cost ();
2198
0
    case 2: return u.format2.cost ();
2199
#ifndef HB_NO_BEYOND_64K
2200
    case 3: return u.format3.cost ();
2201
    case 4: return u.format4.cost ();
2202
#endif
2203
0
    default:return 0u;
2204
0
    }
2205
0
  }
2206
2207
  /* Might return false if array looks unsorted.
2208
   * Used for faster rejection of corrupt data. */
2209
  template <typename set_t>
2210
  bool collect_coverage (set_t *glyphs) const
2211
0
  {
2212
0
    switch (u.format) {
2213
0
    case 1: return u.format1.collect_coverage (glyphs);
2214
0
    case 2: return u.format2.collect_coverage (glyphs);
2215
#ifndef HB_NO_BEYOND_64K
2216
    case 3: return u.format3.collect_coverage (glyphs);
2217
    case 4: return u.format4.collect_coverage (glyphs);
2218
#endif
2219
0
    default:return false;
2220
0
    }
2221
0
  }
2222
2223
  /* Might return false if array looks unsorted.
2224
   * Used for faster rejection of corrupt data. */
2225
  template <typename set_t>
2226
  bool collect_class (set_t *glyphs, unsigned int klass) const
2227
0
  {
2228
0
    switch (u.format) {
2229
0
    case 1: return u.format1.collect_class (glyphs, klass);
2230
0
    case 2: return u.format2.collect_class (glyphs, klass);
2231
#ifndef HB_NO_BEYOND_64K
2232
    case 3: return u.format3.collect_class (glyphs, klass);
2233
    case 4: return u.format4.collect_class (glyphs, klass);
2234
#endif
2235
0
    default:return false;
2236
0
    }
2237
0
  }
2238
2239
  bool intersects (const hb_set_t *glyphs) const
2240
0
  {
2241
0
    switch (u.format) {
2242
0
    case 1: return u.format1.intersects (glyphs);
2243
0
    case 2: return u.format2.intersects (glyphs);
2244
0
#ifndef HB_NO_BEYOND_64K
2245
0
    case 3: return u.format3.intersects (glyphs);
2246
0
    case 4: return u.format4.intersects (glyphs);
2247
0
#endif
2248
0
    default:return false;
2249
0
    }
2250
0
  }
2251
  bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const
2252
0
  {
2253
0
    switch (u.format) {
2254
0
    case 1: return u.format1.intersects_class (glyphs, klass);
2255
0
    case 2: return u.format2.intersects_class (glyphs, klass);
2256
#ifndef HB_NO_BEYOND_64K
2257
    case 3: return u.format3.intersects_class (glyphs, klass);
2258
    case 4: return u.format4.intersects_class (glyphs, klass);
2259
#endif
2260
0
    default:return false;
2261
0
    }
2262
0
  }
2263
2264
  void intersected_class_glyphs (const hb_set_t *glyphs, unsigned klass, hb_set_t *intersect_glyphs) const
2265
0
  {
2266
0
    switch (u.format) {
2267
0
    case 1: return u.format1.intersected_class_glyphs (glyphs, klass, intersect_glyphs);
2268
0
    case 2: return u.format2.intersected_class_glyphs (glyphs, klass, intersect_glyphs);
2269
#ifndef HB_NO_BEYOND_64K
2270
    case 3: return u.format3.intersected_class_glyphs (glyphs, klass, intersect_glyphs);
2271
    case 4: return u.format4.intersected_class_glyphs (glyphs, klass, intersect_glyphs);
2272
#endif
2273
0
    default:return;
2274
0
    }
2275
0
  }
2276
2277
  void intersected_classes (const hb_set_t *glyphs, hb_set_t *intersect_classes) const
2278
0
  {
2279
0
    switch (u.format) {
2280
0
    case 1: return u.format1.intersected_classes (glyphs, intersect_classes);
2281
0
    case 2: return u.format2.intersected_classes (glyphs, intersect_classes);
2282
0
#ifndef HB_NO_BEYOND_64K
2283
0
    case 3: return u.format3.intersected_classes (glyphs, intersect_classes);
2284
0
    case 4: return u.format4.intersected_classes (glyphs, intersect_classes);
2285
0
#endif
2286
0
    default:return;
2287
0
    }
2288
0
  }
2289
2290
2291
  protected:
2292
  union {
2293
  HBUINT16      format;   /* Format identifier */
2294
  ClassDefFormat1_3<SmallTypes> format1;
2295
  ClassDefFormat2_4<SmallTypes> format2;
2296
#ifndef HB_NO_BEYOND_64K
2297
  ClassDefFormat1_3<MediumTypes>format3;
2298
  ClassDefFormat2_4<MediumTypes>format4;
2299
#endif
2300
  } u;
2301
  public:
2302
  DEFINE_SIZE_UNION (2, format);
2303
};
2304
2305
template<typename Iterator>
2306
static inline bool ClassDef_serialize (hb_serialize_context_t *c,
2307
               Iterator it)
2308
0
{ return (c->start_embed<ClassDef> ()->serialize (c, it)); }
Unexecuted instantiation: hb-face.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-font.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-face.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-font.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-layout.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-metrics.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-var.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-static.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-aat-layout.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-cff1-table.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-cff2-table.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-color.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-shaper-arabic.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
Unexecuted instantiation: hb-ot-shape-fallback.cc:bool OT::ClassDef_serialize<hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const> >(hb_serialize_context_t*, hb_sorted_array_t<hb_pair_t<unsigned int, unsigned int> const>)
2309
2310
2311
/*
2312
 * Item Variation Store
2313
 */
2314
2315
/* ported from fonttools (class _Encoding) */
2316
struct delta_row_encoding_t
2317
{
2318
  /* each byte represents a region, value is one of 0/1/2/4, which means bytes
2319
   * needed for this region */
2320
  hb_vector_t<uint8_t> chars;
2321
  unsigned width = 0;
2322
  hb_vector_t<uint8_t> columns;
2323
  unsigned overhead = 0;
2324
  hb_vector_t<const hb_vector_t<int>*> items;
2325
2326
  delta_row_encoding_t () = default;
2327
  delta_row_encoding_t (hb_vector_t<uint8_t>&& chars_,
2328
                        const hb_vector_t<int>* row = nullptr) :
2329
                        delta_row_encoding_t ()
2330
2331
0
  {
2332
0
    chars = std::move (chars_);
2333
0
    width = get_width ();
2334
0
    columns = get_columns ();
2335
0
    overhead = get_chars_overhead (columns);
2336
0
    if (row) items.push (row);
2337
0
  }
2338
2339
  bool is_empty () const
2340
0
  { return !items; }
2341
2342
  static hb_vector_t<uint8_t> get_row_chars (const hb_vector_t<int>& row)
2343
0
  {
2344
0
    hb_vector_t<uint8_t> ret;
2345
0
    if (!ret.alloc (row.length)) return ret;
2346
0
2347
0
    bool long_words = false;
2348
0
2349
0
    /* 0/1/2 byte encoding */
2350
0
    for (int i = row.length - 1; i >= 0; i--)
2351
0
    {
2352
0
      int v =  row.arrayZ[i];
2353
0
      if (v == 0)
2354
0
        ret.push (0);
2355
0
      else if (v > 32767 || v < -32768)
2356
0
      {
2357
0
        long_words = true;
2358
0
        break;
2359
0
      }
2360
0
      else if (v > 127 || v < -128)
2361
0
        ret.push (2);
2362
0
      else
2363
0
        ret.push (1);
2364
0
    }
2365
0
2366
0
    if (!long_words)
2367
0
      return ret;
2368
0
2369
0
    /* redo, 0/2/4 bytes encoding */
2370
0
    ret.reset ();
2371
0
    for (int i = row.length - 1; i >= 0; i--)
2372
0
    {
2373
0
      int v =  row.arrayZ[i];
2374
0
      if (v == 0)
2375
0
        ret.push (0);
2376
0
      else if (v > 32767 || v < -32768)
2377
0
        ret.push (4);
2378
0
      else
2379
0
        ret.push (2);
2380
0
    }
2381
0
    return ret;
2382
0
  }
2383
2384
  inline unsigned get_width ()
2385
0
  {
2386
0
    unsigned ret = + hb_iter (chars)
2387
0
                   | hb_reduce (hb_add, 0u)
2388
0
                   ;
2389
0
    return ret;
2390
0
  }
2391
2392
  hb_vector_t<uint8_t> get_columns ()
2393
0
  {
2394
0
    hb_vector_t<uint8_t> cols;
2395
0
    cols.alloc (chars.length);
2396
0
    for (auto v : chars)
2397
0
    {
2398
0
      uint8_t flag = v ? 1 : 0;
2399
0
      cols.push (flag);
2400
0
    }
2401
0
    return cols;
2402
0
  }
2403
2404
  static inline unsigned get_chars_overhead (const hb_vector_t<uint8_t>& cols)
2405
0
  {
2406
0
    unsigned c = 4 + 6; // 4 bytes for LOffset, 6 bytes for VarData header
2407
0
    unsigned cols_bit_count = 0;
2408
0
    for (auto v : cols)
2409
0
      if (v) cols_bit_count++;
2410
0
    return c + cols_bit_count * 2;
2411
0
  }
2412
2413
  unsigned get_gain () const
2414
0
  {
2415
0
    int count = items.length;
2416
0
    return hb_max (0, (int) overhead - count);
2417
0
  }
2418
2419
  int gain_from_merging (const delta_row_encoding_t& other_encoding) const
2420
0
  {
2421
0
    int combined_width = 0;
2422
0
    for (unsigned i = 0; i < chars.length; i++)
2423
0
      combined_width += hb_max (chars.arrayZ[i], other_encoding.chars.arrayZ[i]);
2424
0
   
2425
0
    hb_vector_t<uint8_t> combined_columns;
2426
0
    combined_columns.alloc (columns.length);
2427
0
    for (unsigned i = 0; i < columns.length; i++)
2428
0
      combined_columns.push (columns.arrayZ[i] | other_encoding.columns.arrayZ[i]);
2429
0
    
2430
0
    int combined_overhead = get_chars_overhead (combined_columns);
2431
0
    int combined_gain = (int) overhead + (int) other_encoding.overhead - combined_overhead
2432
0
                        - (combined_width - (int) width) * items.length
2433
0
                        - (combined_width - (int) other_encoding.width) * other_encoding.items.length;
2434
0
2435
0
    return combined_gain;
2436
0
  }
2437
2438
  static int cmp (const void *pa, const void *pb)
2439
0
  {
2440
0
    const delta_row_encoding_t *a = (const delta_row_encoding_t *)pa;
2441
0
    const delta_row_encoding_t *b = (const delta_row_encoding_t *)pb;
2442
0
2443
0
    int gain_a = a->get_gain ();
2444
0
    int gain_b = b->get_gain ();
2445
0
2446
0
    if (gain_a != gain_b)
2447
0
      return gain_a - gain_b;
2448
0
2449
0
    return (b->chars).as_array ().cmp ((a->chars).as_array ());
2450
0
  }
2451
2452
  static int cmp_width (const void *pa, const void *pb)
2453
0
  {
2454
0
    const delta_row_encoding_t *a = (const delta_row_encoding_t *)pa;
2455
0
    const delta_row_encoding_t *b = (const delta_row_encoding_t *)pb;
2456
0
2457
0
    if (a->width != b->width)
2458
0
      return (int) a->width - (int) b->width;
2459
0
2460
0
    return (b->chars).as_array ().cmp ((a->chars).as_array ());
2461
0
  }
2462
2463
  bool add_row (const hb_vector_t<int>* row)
2464
0
  { return items.push (row); }
2465
};
2466
2467
struct VarRegionAxis
2468
{
2469
  float evaluate (int coord) const
2470
0
  {
2471
0
    int peak = peakCoord.to_int ();
2472
0
    if (peak == 0 || coord == peak)
2473
0
      return 1.f;
2474
2475
0
    int start = startCoord.to_int (), end = endCoord.to_int ();
2476
2477
    /* TODO Move these to sanitize(). */
2478
0
    if (unlikely (start > peak || peak > end))
2479
0
      return 1.f;
2480
0
    if (unlikely (start < 0 && end > 0 && peak != 0))
2481
0
      return 1.f;
2482
2483
0
    if (coord <= start || end <= coord)
2484
0
      return 0.f;
2485
2486
    /* Interpolate */
2487
0
    if (coord < peak)
2488
0
      return float (coord - start) / (peak - start);
2489
0
    else
2490
0
      return float (end - coord) / (end - peak);
2491
0
  }
2492
2493
  bool sanitize (hb_sanitize_context_t *c) const
2494
0
  {
2495
0
    TRACE_SANITIZE (this);
2496
0
    return_trace (c->check_struct (this));
2497
0
    /* TODO Handle invalid start/peak/end configs, so we don't
2498
0
     * have to do that at runtime. */
2499
0
  }
2500
2501
  bool serialize (hb_serialize_context_t *c) const
2502
0
  {
2503
0
    TRACE_SERIALIZE (this);
2504
0
    return_trace (c->embed (this));
2505
0
  }
2506
2507
  public:
2508
  F2DOT14 startCoord;
2509
  F2DOT14 peakCoord;
2510
  F2DOT14 endCoord;
2511
  public:
2512
  DEFINE_SIZE_STATIC (6);
2513
};
2514
2515
0
#define REGION_CACHE_ITEM_CACHE_INVALID 2.f
2516
2517
struct VarRegionList
2518
{
2519
  using cache_t = float;
2520
2521
  float evaluate (unsigned int region_index,
2522
      const int *coords, unsigned int coord_len,
2523
      cache_t *cache = nullptr) const
2524
0
  {
2525
0
    if (unlikely (region_index >= regionCount))
2526
0
      return 0.;
2527
2528
0
    float *cached_value = nullptr;
2529
0
    if (cache)
2530
0
    {
2531
0
      cached_value = &(cache[region_index]);
2532
0
      if (likely (*cached_value != REGION_CACHE_ITEM_CACHE_INVALID))
2533
0
  return *cached_value;
2534
0
    }
2535
2536
0
    const VarRegionAxis *axes = axesZ.arrayZ + (region_index * axisCount);
2537
2538
0
    float v = 1.;
2539
0
    unsigned int count = axisCount;
2540
0
    for (unsigned int i = 0; i < count; i++)
2541
0
    {
2542
0
      int coord = i < coord_len ? coords[i] : 0;
2543
0
      float factor = axes[i].evaluate (coord);
2544
0
      if (factor == 0.f)
2545
0
      {
2546
0
        if (cache)
2547
0
    *cached_value = 0.;
2548
0
  return 0.;
2549
0
      }
2550
0
      v *= factor;
2551
0
    }
2552
2553
0
    if (cache)
2554
0
      *cached_value = v;
2555
0
    return v;
2556
0
  }
2557
2558
  bool sanitize (hb_sanitize_context_t *c) const
2559
0
  {
2560
0
    TRACE_SANITIZE (this);
2561
0
    return_trace (c->check_struct (this) &&
2562
0
      hb_barrier () &&
2563
0
      axesZ.sanitize (c, axisCount * regionCount));
2564
0
  }
2565
2566
  bool serialize (hb_serialize_context_t *c,
2567
                  const hb_vector_t<hb_tag_t>& axis_tags,
2568
                  const hb_vector_t<const hb_hashmap_t<hb_tag_t, Triple>*>& regions)
2569
0
  {
2570
0
    TRACE_SERIALIZE (this);
2571
0
    unsigned axis_count = axis_tags.length;
2572
0
    unsigned region_count = regions.length;
2573
0
    if (!axis_count || !region_count) return_trace (false);
2574
0
    if (unlikely (hb_unsigned_mul_overflows (axis_count * region_count,
2575
0
                                             VarRegionAxis::static_size))) return_trace (false);
2576
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
2577
0
    axisCount = axis_count;
2578
0
    regionCount = region_count;
2579
0
2580
0
    for (unsigned r = 0; r < region_count; r++)
2581
0
    {
2582
0
      const auto& region = regions[r];
2583
0
      for (unsigned i = 0; i < axis_count; i++)
2584
0
      {
2585
0
        hb_tag_t tag = axis_tags.arrayZ[i];
2586
0
        VarRegionAxis var_region_rec;
2587
0
        Triple *coords;
2588
0
        if (region->has (tag, &coords))
2589
0
        {
2590
0
          var_region_rec.startCoord.set_float (coords->minimum);
2591
0
          var_region_rec.peakCoord.set_float (coords->middle);
2592
0
          var_region_rec.endCoord.set_float (coords->maximum);
2593
0
        }
2594
0
        else
2595
0
        {
2596
0
          var_region_rec.startCoord.set_int (0);
2597
0
          var_region_rec.peakCoord.set_int (0);
2598
0
          var_region_rec.endCoord.set_int (0);
2599
0
        }
2600
0
        if (!var_region_rec.serialize (c))
2601
0
          return_trace (false);
2602
0
      }
2603
0
    }
2604
0
    return_trace (true);
2605
0
  }
2606
2607
  bool serialize (hb_serialize_context_t *c, const VarRegionList *src, const hb_inc_bimap_t &region_map)
2608
0
  {
2609
0
    TRACE_SERIALIZE (this);
2610
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
2611
0
    axisCount = src->axisCount;
2612
0
    regionCount = region_map.get_population ();
2613
0
    if (unlikely (hb_unsigned_mul_overflows (axisCount * regionCount,
2614
0
               VarRegionAxis::static_size))) return_trace (false);
2615
0
    if (unlikely (!c->extend (this))) return_trace (false);
2616
0
    unsigned int region_count = src->regionCount;
2617
0
    for (unsigned int r = 0; r < regionCount; r++)
2618
0
    {
2619
0
      unsigned int backward = region_map.backward (r);
2620
0
      if (backward >= region_count) return_trace (false);
2621
0
      hb_memcpy (&axesZ[axisCount * r], &src->axesZ[axisCount * backward], VarRegionAxis::static_size * axisCount);
2622
0
    }
2623
0
2624
0
    return_trace (true);
2625
0
  }
2626
2627
  bool get_var_region (unsigned region_index,
2628
                       const hb_map_t& axes_old_index_tag_map,
2629
                       hb_hashmap_t<hb_tag_t, Triple>& axis_tuples /* OUT */) const
2630
0
  {
2631
0
    if (region_index >= regionCount) return false;
2632
0
    const VarRegionAxis* axis_region = axesZ.arrayZ + (region_index * axisCount);
2633
0
    for (unsigned i = 0; i < axisCount; i++)
2634
0
    {
2635
0
      hb_tag_t *axis_tag;
2636
0
      if (!axes_old_index_tag_map.has (i, &axis_tag))
2637
0
        return false;
2638
0
2639
0
      float min_val = axis_region->startCoord.to_float ();
2640
0
      float def_val = axis_region->peakCoord.to_float ();
2641
0
      float max_val = axis_region->endCoord.to_float ();
2642
0
2643
0
      if (def_val != 0.f)
2644
0
        axis_tuples.set (*axis_tag, Triple (min_val, def_val, max_val));
2645
0
      axis_region++;
2646
0
    }
2647
0
    return !axis_tuples.in_error ();
2648
0
  }
2649
2650
  bool get_var_regions (const hb_map_t& axes_old_index_tag_map,
2651
                        hb_vector_t<hb_hashmap_t<hb_tag_t, Triple>>& regions /* OUT */) const
2652
0
  {
2653
0
    if (!regions.alloc (regionCount))
2654
0
      return false;
2655
0
2656
0
    for (unsigned i = 0; i < regionCount; i++)
2657
0
    {
2658
0
      hb_hashmap_t<hb_tag_t, Triple> axis_tuples;
2659
0
      if (!get_var_region (i, axes_old_index_tag_map, axis_tuples))
2660
0
        return false;
2661
0
      regions.push (std::move (axis_tuples));
2662
0
    }
2663
0
    return !regions.in_error ();
2664
0
  }
2665
2666
0
  unsigned int get_size () const { return min_size + VarRegionAxis::static_size * axisCount * regionCount; }
2667
2668
  public:
2669
  HBUINT16  axisCount;
2670
  HBUINT15  regionCount;
2671
  protected:
2672
  UnsizedArrayOf<VarRegionAxis>
2673
    axesZ;
2674
  public:
2675
  DEFINE_SIZE_ARRAY (4, axesZ);
2676
};
2677
2678
struct VarData
2679
{
2680
  unsigned int get_item_count () const
2681
0
  { return itemCount; }
2682
2683
  unsigned int get_region_index_count () const
2684
0
  { return regionIndices.len; }
2685
  
2686
  unsigned get_region_index (unsigned i) const
2687
0
  { return i >= regionIndices.len ? -1 : regionIndices[i]; }
2688
2689
  unsigned int get_row_size () const
2690
0
  { return (wordCount () + regionIndices.len) * (longWords () ? 2 : 1); }
2691
2692
  unsigned int get_size () const
2693
0
  { return min_size
2694
0
   - regionIndices.min_size + regionIndices.get_size ()
2695
0
   + itemCount * get_row_size ();
2696
0
  }
2697
2698
  float get_delta (unsigned int inner,
2699
       const int *coords, unsigned int coord_count,
2700
       const VarRegionList &regions,
2701
       VarRegionList::cache_t *cache = nullptr) const
2702
0
  {
2703
0
    if (unlikely (inner >= itemCount))
2704
0
      return 0.;
2705
2706
0
   unsigned int count = regionIndices.len;
2707
0
   bool is_long = longWords ();
2708
0
   unsigned word_count = wordCount ();
2709
0
   unsigned int scount = is_long ? count : word_count;
2710
0
   unsigned int lcount = is_long ? word_count : 0;
2711
2712
0
   const HBUINT8 *bytes = get_delta_bytes ();
2713
0
   const HBUINT8 *row = bytes + inner * get_row_size ();
2714
2715
0
   float delta = 0.;
2716
0
   unsigned int i = 0;
2717
2718
0
   const HBINT32 *lcursor = reinterpret_cast<const HBINT32 *> (row);
2719
0
   for (; i < lcount; i++)
2720
0
   {
2721
0
     float scalar = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count, cache);
2722
0
     delta += scalar * *lcursor++;
2723
0
   }
2724
0
   const HBINT16 *scursor = reinterpret_cast<const HBINT16 *> (lcursor);
2725
0
   for (; i < scount; i++)
2726
0
   {
2727
0
     float scalar = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count, cache);
2728
0
     delta += scalar * *scursor++;
2729
0
   }
2730
0
   const HBINT8 *bcursor = reinterpret_cast<const HBINT8 *> (scursor);
2731
0
   for (; i < count; i++)
2732
0
   {
2733
0
     float scalar = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count, cache);
2734
0
     delta += scalar * *bcursor++;
2735
0
   }
2736
2737
0
   return delta;
2738
0
  }
2739
2740
  void get_region_scalars (const int *coords, unsigned int coord_count,
2741
         const VarRegionList &regions,
2742
         float *scalars /*OUT */,
2743
         unsigned int num_scalars) const
2744
0
  {
2745
0
    unsigned count = hb_min (num_scalars, regionIndices.len);
2746
0
    for (unsigned int i = 0; i < count; i++)
2747
0
      scalars[i] = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count);
2748
0
    for (unsigned int i = count; i < num_scalars; i++)
2749
0
      scalars[i] = 0.f;
2750
0
  }
2751
2752
  bool sanitize (hb_sanitize_context_t *c) const
2753
0
  {
2754
0
    TRACE_SANITIZE (this);
2755
0
    return_trace (c->check_struct (this) &&
2756
0
      regionIndices.sanitize (c) &&
2757
0
      hb_barrier () &&
2758
0
      wordCount () <= regionIndices.len &&
2759
0
      c->check_range (get_delta_bytes (),
2760
0
          itemCount,
2761
0
          get_row_size ()));
2762
0
  }
2763
2764
  bool serialize (hb_serialize_context_t *c,
2765
                  bool has_long,
2766
                  const hb_vector_t<const hb_vector_t<int>*>& rows)
2767
0
  {
2768
0
    TRACE_SERIALIZE (this);
2769
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
2770
0
    unsigned row_count = rows.length;
2771
0
    itemCount = row_count;
2772
0
2773
0
    int min_threshold = has_long ? -65536 : -128;
2774
0
    int max_threshold = has_long ? +65535 : +127;
2775
0
    enum delta_size_t { kZero=0, kNonWord, kWord };
2776
0
    hb_vector_t<delta_size_t> delta_sz;
2777
0
    unsigned num_regions = rows[0]->length;
2778
0
    if (!delta_sz.resize (num_regions))
2779
0
      return_trace (false);
2780
0
2781
0
    unsigned word_count = 0;
2782
0
    for (unsigned r = 0; r < num_regions; r++)
2783
0
    {
2784
0
      for (unsigned i = 0; i < row_count; i++)
2785
0
      {
2786
0
        int delta = rows[i]->arrayZ[r];
2787
0
        if (delta < min_threshold || delta > max_threshold)
2788
0
        {
2789
0
          delta_sz[r] = kWord;
2790
0
          word_count++;
2791
0
          break;
2792
0
        }
2793
0
        else if (delta != 0)
2794
0
        {
2795
0
          delta_sz[r] = kNonWord;
2796
0
        }
2797
0
      }
2798
0
    }
2799
0
2800
0
    /* reorder regions: words and then non-words*/
2801
0
    unsigned word_index = 0;
2802
0
    unsigned non_word_index = word_count;
2803
0
    hb_map_t ri_map;
2804
0
    for (unsigned r = 0; r < num_regions; r++)
2805
0
    {
2806
0
      if (!delta_sz[r]) continue;
2807
0
      unsigned new_r = (delta_sz[r] == kWord)? word_index++ : non_word_index++;
2808
0
      if (!ri_map.set (new_r, r))
2809
0
        return_trace (false);
2810
0
    }
2811
0
2812
0
    wordSizeCount = word_count | (has_long ? 0x8000u /* LONG_WORDS */ : 0);
2813
0
2814
0
    unsigned ri_count = ri_map.get_population ();
2815
0
    regionIndices.len = ri_count;
2816
0
    if (unlikely (!c->extend (this))) return_trace (false);
2817
0
2818
0
    for (unsigned r = 0; r < ri_count; r++)
2819
0
    {
2820
0
      hb_codepoint_t *idx;
2821
0
      if (!ri_map.has (r, &idx))
2822
0
        return_trace (false);
2823
0
      regionIndices[r] = *idx;
2824
0
    }
2825
0
2826
0
    HBUINT8 *delta_bytes = get_delta_bytes ();
2827
0
    unsigned row_size = get_row_size ();
2828
0
    for (unsigned int i = 0; i < row_count; i++)
2829
0
    {
2830
0
      for (unsigned int r = 0; r < ri_count; r++)
2831
0
      {
2832
0
        int delta = rows[i]->arrayZ[ri_map[r]];
2833
0
        set_item_delta_fast (i, r, delta, delta_bytes, row_size);
2834
0
      }
2835
0
    }
2836
0
    return_trace (true);
2837
0
  }
2838
2839
  bool serialize (hb_serialize_context_t *c,
2840
      const VarData *src,
2841
      const hb_inc_bimap_t &inner_map,
2842
      const hb_inc_bimap_t &region_map)
2843
0
  {
2844
0
    TRACE_SERIALIZE (this);
2845
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
2846
0
    itemCount = inner_map.get_next_value ();
2847
0
2848
0
    /* Optimize word count */
2849
0
    unsigned ri_count = src->regionIndices.len;
2850
0
    enum delta_size_t { kZero=0, kNonWord, kWord };
2851
0
    hb_vector_t<delta_size_t> delta_sz;
2852
0
    hb_vector_t<unsigned int> ri_map; /* maps new index to old index */
2853
0
    delta_sz.resize (ri_count);
2854
0
    ri_map.resize (ri_count);
2855
0
    unsigned int new_word_count = 0;
2856
0
    unsigned int r;
2857
0
2858
0
    const HBUINT8 *src_delta_bytes = src->get_delta_bytes ();
2859
0
    unsigned src_row_size = src->get_row_size ();
2860
0
    unsigned src_word_count = src->wordCount ();
2861
0
    bool     src_long_words = src->longWords ();
2862
0
2863
0
    bool has_long = false;
2864
0
    if (src_long_words)
2865
0
    {
2866
0
      for (r = 0; r < src_word_count; r++)
2867
0
      {
2868
0
        for (unsigned old_gid : inner_map.keys())
2869
0
  {
2870
0
    int32_t delta = src->get_item_delta_fast (old_gid, r, src_delta_bytes, src_row_size);
2871
0
    if (delta < -65536 || 65535 < delta)
2872
0
    {
2873
0
      has_long = true;
2874
0
      break;
2875
0
    }
2876
0
        }
2877
0
      }
2878
0
    }
2879
0
2880
0
    signed min_threshold = has_long ? -65536 : -128;
2881
0
    signed max_threshold = has_long ? +65535 : +127;
2882
0
    for (r = 0; r < ri_count; r++)
2883
0
    {
2884
0
      bool short_circuit = src_long_words == has_long && src_word_count <= r;
2885
0
2886
0
      delta_sz[r] = kZero;
2887
0
      for (unsigned old_gid : inner_map.keys())
2888
0
      {
2889
0
  int32_t delta = src->get_item_delta_fast (old_gid, r, src_delta_bytes, src_row_size);
2890
0
  if (delta < min_threshold || max_threshold < delta)
2891
0
  {
2892
0
    delta_sz[r] = kWord;
2893
0
    new_word_count++;
2894
0
    break;
2895
0
  }
2896
0
  else if (delta != 0)
2897
0
  {
2898
0
    delta_sz[r] = kNonWord;
2899
0
    if (short_circuit)
2900
0
      break;
2901
0
  }
2902
0
      }
2903
0
    }
2904
0
2905
0
    unsigned int word_index = 0;
2906
0
    unsigned int non_word_index = new_word_count;
2907
0
    unsigned int new_ri_count = 0;
2908
0
    for (r = 0; r < ri_count; r++)
2909
0
      if (delta_sz[r])
2910
0
      {
2911
0
  unsigned new_r = (delta_sz[r] == kWord)? word_index++ : non_word_index++;
2912
0
  ri_map[new_r] = r;
2913
0
  new_ri_count++;
2914
0
      }
2915
0
2916
0
    wordSizeCount = new_word_count | (has_long ? 0x8000u /* LONG_WORDS */ : 0);
2917
0
2918
0
    regionIndices.len = new_ri_count;
2919
0
2920
0
    if (unlikely (!c->extend (this))) return_trace (false);
2921
0
2922
0
    for (r = 0; r < new_ri_count; r++)
2923
0
      regionIndices[r] = region_map[src->regionIndices[ri_map[r]]];
2924
0
2925
0
    HBUINT8 *delta_bytes = get_delta_bytes ();
2926
0
    unsigned row_size = get_row_size ();
2927
0
    unsigned count = itemCount;
2928
0
    for (unsigned int i = 0; i < count; i++)
2929
0
    {
2930
0
      unsigned int old = inner_map.backward (i);
2931
0
      for (unsigned int r = 0; r < new_ri_count; r++)
2932
0
  set_item_delta_fast (i, r,
2933
0
           src->get_item_delta_fast (old, ri_map[r],
2934
0
                   src_delta_bytes, src_row_size),
2935
0
           delta_bytes, row_size);
2936
0
    }
2937
0
2938
0
    return_trace (true);
2939
0
  }
2940
2941
  void collect_region_refs (hb_set_t &region_indices, const hb_inc_bimap_t &inner_map) const
2942
0
  {
2943
0
    const HBUINT8 *delta_bytes = get_delta_bytes ();
2944
0
    unsigned row_size = get_row_size ();
2945
0
2946
0
    for (unsigned int r = 0; r < regionIndices.len; r++)
2947
0
    {
2948
0
      unsigned int region = regionIndices.arrayZ[r];
2949
0
      if (region_indices.has (region)) continue;
2950
0
      for (hb_codepoint_t old_gid : inner_map.keys())
2951
0
  if (get_item_delta_fast (old_gid, r, delta_bytes, row_size) != 0)
2952
0
  {
2953
0
    region_indices.add (region);
2954
0
    break;
2955
0
  }
2956
0
    }
2957
0
  }
2958
2959
  public:
2960
  const HBUINT8 *get_delta_bytes () const
2961
0
  { return &StructAfter<HBUINT8> (regionIndices); }
2962
2963
  protected:
2964
  HBUINT8 *get_delta_bytes ()
2965
0
  { return &StructAfter<HBUINT8> (regionIndices); }
2966
2967
  public:
2968
  int32_t get_item_delta_fast (unsigned int item, unsigned int region,
2969
             const HBUINT8 *delta_bytes, unsigned row_size) const
2970
0
  {
2971
0
    if (unlikely (item >= itemCount || region >= regionIndices.len)) return 0;
2972
0
2973
0
    const HBINT8 *p = (const HBINT8 *) delta_bytes + item * row_size;
2974
0
    unsigned word_count = wordCount ();
2975
0
    bool is_long = longWords ();
2976
0
    if (is_long)
2977
0
    {
2978
0
      if (region < word_count)
2979
0
  return ((const HBINT32 *) p)[region];
2980
0
      else
2981
0
  return ((const HBINT16 *)(p + HBINT32::static_size * word_count))[region - word_count];
2982
0
    }
2983
0
    else
2984
0
    {
2985
0
      if (region < word_count)
2986
0
  return ((const HBINT16 *) p)[region];
2987
0
      else
2988
0
  return (p + HBINT16::static_size * word_count)[region - word_count];
2989
0
    }
2990
0
  }
2991
  int32_t get_item_delta (unsigned int item, unsigned int region) const
2992
0
  {
2993
0
     return get_item_delta_fast (item, region,
2994
0
         get_delta_bytes (),
2995
0
         get_row_size ());
2996
0
  }
2997
2998
  protected:
2999
  void set_item_delta_fast (unsigned int item, unsigned int region, int32_t delta,
3000
          HBUINT8 *delta_bytes, unsigned row_size)
3001
0
  {
3002
0
    HBINT8 *p = (HBINT8 *) delta_bytes + item * row_size;
3003
0
    unsigned word_count = wordCount ();
3004
0
    bool is_long = longWords ();
3005
0
    if (is_long)
3006
0
    {
3007
0
      if (region < word_count)
3008
0
  ((HBINT32 *) p)[region] = delta;
3009
0
      else
3010
0
  ((HBINT16 *)(p + HBINT32::static_size * word_count))[region - word_count] = delta;
3011
0
    }
3012
0
    else
3013
0
    {
3014
0
      if (region < word_count)
3015
0
  ((HBINT16 *) p)[region] = delta;
3016
0
      else
3017
0
  (p + HBINT16::static_size * word_count)[region - word_count] = delta;
3018
0
    }
3019
0
  }
3020
  void set_item_delta (unsigned int item, unsigned int region, int32_t delta)
3021
0
  {
3022
0
    set_item_delta_fast (item, region, delta,
3023
0
       get_delta_bytes (),
3024
0
       get_row_size ());
3025
0
  }
3026
3027
0
  bool longWords () const { return wordSizeCount & 0x8000u /* LONG_WORDS */; }
3028
0
  unsigned wordCount () const { return wordSizeCount & 0x7FFFu /* WORD_DELTA_COUNT_MASK */; }
3029
3030
  protected:
3031
  HBUINT16    itemCount;
3032
  HBUINT16    wordSizeCount;
3033
  Array16Of<HBUINT16> regionIndices;
3034
/*UnsizedArrayOf<HBUINT8>bytesX;*/
3035
  public:
3036
  DEFINE_SIZE_ARRAY (6, regionIndices);
3037
};
3038
3039
struct ItemVariationStore
3040
{
3041
  friend struct item_variations_t;
3042
  using cache_t = VarRegionList::cache_t;
3043
3044
  cache_t *create_cache () const
3045
0
  {
3046
#ifdef HB_NO_VAR
3047
    return nullptr;
3048
#endif
3049
0
    auto &r = this+regions;
3050
0
    unsigned count = r.regionCount;
3051
3052
0
    float *cache = (float *) hb_malloc (sizeof (float) * count);
3053
0
    if (unlikely (!cache)) return nullptr;
3054
3055
0
    for (unsigned i = 0; i < count; i++)
3056
0
      cache[i] = REGION_CACHE_ITEM_CACHE_INVALID;
3057
3058
0
    return cache;
3059
0
  }
3060
3061
0
  static void destroy_cache (cache_t *cache) { hb_free (cache); }
3062
3063
  private:
3064
  float get_delta (unsigned int outer, unsigned int inner,
3065
       const int *coords, unsigned int coord_count,
3066
       VarRegionList::cache_t *cache = nullptr) const
3067
0
  {
3068
#ifdef HB_NO_VAR
3069
    return 0.f;
3070
#endif
3071
3072
0
    if (unlikely (outer >= dataSets.len))
3073
0
      return 0.f;
3074
3075
0
    return (this+dataSets[outer]).get_delta (inner,
3076
0
               coords, coord_count,
3077
0
               this+regions,
3078
0
               cache);
3079
0
  }
3080
3081
  public:
3082
  float get_delta (unsigned int index,
3083
       const int *coords, unsigned int coord_count,
3084
       VarRegionList::cache_t *cache = nullptr) const
3085
0
  {
3086
0
    unsigned int outer = index >> 16;
3087
0
    unsigned int inner = index & 0xFFFF;
3088
0
    return get_delta (outer, inner, coords, coord_count, cache);
3089
0
  }
3090
  float get_delta (unsigned int index,
3091
       hb_array_t<int> coords,
3092
       VarRegionList::cache_t *cache = nullptr) const
3093
0
  {
3094
0
    return get_delta (index,
3095
0
          coords.arrayZ, coords.length,
3096
0
          cache);
3097
0
  }
3098
3099
  bool sanitize (hb_sanitize_context_t *c) const
3100
0
  {
3101
#ifdef HB_NO_VAR
3102
    return true;
3103
#endif
3104
3105
0
    TRACE_SANITIZE (this);
3106
0
    return_trace (c->check_struct (this) &&
3107
0
      hb_barrier () &&
3108
0
      format == 1 &&
3109
0
      regions.sanitize (c, this) &&
3110
0
      dataSets.sanitize (c, this));
3111
0
  }
3112
3113
  bool serialize (hb_serialize_context_t *c,
3114
                  bool has_long,
3115
                  const hb_vector_t<hb_tag_t>& axis_tags,
3116
                  const hb_vector_t<const hb_hashmap_t<hb_tag_t, Triple>*>& region_list,
3117
                  const hb_vector_t<delta_row_encoding_t>& vardata_encodings)
3118
0
  {
3119
0
    TRACE_SERIALIZE (this);
3120
0
#ifdef HB_NO_VAR
3121
0
    return_trace (false);
3122
0
#endif
3123
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
3124
0
    
3125
0
    format = 1;
3126
0
    if (!regions.serialize_serialize (c, axis_tags, region_list))
3127
0
      return_trace (false);
3128
0
3129
0
    unsigned num_var_data = vardata_encodings.length;
3130
0
    if (!num_var_data) return_trace (false);
3131
0
    if (unlikely (!c->check_assign (dataSets.len, num_var_data,
3132
0
                                    HB_SERIALIZE_ERROR_INT_OVERFLOW)))
3133
0
      return_trace (false);
3134
0
3135
0
    if (unlikely (!c->extend (dataSets))) return_trace (false);
3136
0
    for (unsigned i = 0; i < num_var_data; i++)
3137
0
      if (!dataSets[i].serialize_serialize (c, has_long, vardata_encodings[i].items))
3138
0
        return_trace (false);
3139
0
    
3140
0
    return_trace (true);
3141
0
  }
3142
3143
  bool serialize (hb_serialize_context_t *c,
3144
      const ItemVariationStore *src,
3145
      const hb_array_t <const hb_inc_bimap_t> &inner_maps)
3146
0
  {
3147
0
    TRACE_SERIALIZE (this);
3148
0
#ifdef HB_NO_VAR
3149
0
    return_trace (false);
3150
0
#endif
3151
0
3152
0
    if (unlikely (!c->extend_min (this))) return_trace (false);
3153
0
3154
0
    unsigned int set_count = 0;
3155
0
    for (unsigned int i = 0; i < inner_maps.length; i++)
3156
0
      if (inner_maps[i].get_population ())
3157
0
  set_count++;
3158
0
3159
0
    format = 1;
3160
0
3161
0
    const auto &src_regions = src+src->regions;
3162
0
3163
0
    hb_set_t region_indices;
3164
0
    for (unsigned int i = 0; i < inner_maps.length; i++)
3165
0
      (src+src->dataSets[i]).collect_region_refs (region_indices, inner_maps[i]);
3166
0
3167
0
    if (region_indices.in_error ())
3168
0
      return_trace (false);
3169
0
3170
0
    region_indices.del_range ((src_regions).regionCount, hb_set_t::INVALID);
3171
0
3172
0
    /* TODO use constructor when our data-structures support that. */
3173
0
    hb_inc_bimap_t region_map;
3174
0
    + hb_iter (region_indices)
3175
0
    | hb_apply ([&region_map] (unsigned _) { region_map.add(_); })
3176
0
    ;
3177
0
    if (region_map.in_error())
3178
0
      return_trace (false);
3179
0
3180
0
    if (unlikely (!regions.serialize_serialize (c, &src_regions, region_map)))
3181
0
      return_trace (false);
3182
0
3183
0
    dataSets.len = set_count;
3184
0
    if (unlikely (!c->extend (dataSets))) return_trace (false);
3185
0
3186
0
    /* TODO: The following code could be simplified when
3187
0
     * List16OfOffset16To::subset () can take a custom param to be passed to VarData::serialize () */
3188
0
    unsigned int set_index = 0;
3189
0
    for (unsigned int i = 0; i < inner_maps.length; i++)
3190
0
    {
3191
0
      if (!inner_maps[i].get_population ()) continue;
3192
0
      if (unlikely (!dataSets[set_index++]
3193
0
         .serialize_serialize (c, &(src+src->dataSets[i]), inner_maps[i], region_map)))
3194
0
  return_trace (false);
3195
0
    }
3196
0
3197
0
    return_trace (true);
3198
0
  }
3199
3200
  ItemVariationStore *copy (hb_serialize_context_t *c) const
3201
0
  {
3202
0
    TRACE_SERIALIZE (this);
3203
0
    auto *out = c->start_embed (this);
3204
0
    if (unlikely (!out)) return_trace (nullptr);
3205
0
3206
0
    hb_vector_t <hb_inc_bimap_t> inner_maps;
3207
0
    unsigned count = dataSets.len;
3208
0
    for (unsigned i = 0; i < count; i++)
3209
0
    {
3210
0
      hb_inc_bimap_t *map = inner_maps.push ();
3211
0
      auto &data = this+dataSets[i];
3212
0
3213
0
      unsigned itemCount = data.get_item_count ();
3214
0
      for (unsigned j = 0; j < itemCount; j++)
3215
0
  map->add (j);
3216
0
    }
3217
0
3218
0
    if (unlikely (!out->serialize (c, this, inner_maps))) return_trace (nullptr);
3219
0
3220
0
    return_trace (out);
3221
0
  }
3222
3223
  bool subset (hb_subset_context_t *c, const hb_array_t<const hb_inc_bimap_t> &inner_maps) const
3224
0
  {
3225
0
    TRACE_SUBSET (this);
3226
0
#ifdef HB_NO_VAR
3227
0
    return_trace (false);
3228
0
#endif
3229
0
3230
0
    ItemVariationStore *varstore_prime = c->serializer->start_embed<ItemVariationStore> ();
3231
0
    if (unlikely (!varstore_prime)) return_trace (false);
3232
0
3233
0
    varstore_prime->serialize (c->serializer, this, inner_maps);
3234
0
3235
0
    return_trace (
3236
0
        !c->serializer->in_error()
3237
0
        && varstore_prime->dataSets);
3238
0
  }
3239
3240
  unsigned int get_region_index_count (unsigned int major) const
3241
0
  {
3242
#ifdef HB_NO_VAR
3243
    return 0;
3244
#endif
3245
0
    return (this+dataSets[major]).get_region_index_count ();
3246
0
  }
3247
3248
  void get_region_scalars (unsigned int major,
3249
         const int *coords, unsigned int coord_count,
3250
         float *scalars /*OUT*/,
3251
         unsigned int num_scalars) const
3252
0
  {
3253
#ifdef HB_NO_VAR
3254
    for (unsigned i = 0; i < num_scalars; i++)
3255
      scalars[i] = 0.f;
3256
    return;
3257
#endif
3258
3259
0
    (this+dataSets[major]).get_region_scalars (coords, coord_count,
3260
0
                 this+regions,
3261
0
                 &scalars[0], num_scalars);
3262
0
  }
3263
3264
  unsigned int get_sub_table_count () const
3265
0
   {
3266
0
#ifdef HB_NO_VAR
3267
0
     return 0;
3268
0
#endif
3269
0
     return dataSets.len;
3270
0
   }
3271
3272
  const VarData& get_sub_table (unsigned i) const
3273
0
  {
3274
0
#ifdef HB_NO_VAR
3275
0
     return Null (VarData);
3276
0
#endif
3277
0
     return this+dataSets[i];
3278
0
  }
3279
3280
  const VarRegionList& get_region_list () const
3281
0
  {
3282
0
#ifdef HB_NO_VAR
3283
0
     return Null (VarRegionList);
3284
0
#endif
3285
0
     return this+regions;
3286
0
  }
3287
3288
  protected:
3289
  HBUINT16        format;
3290
  Offset32To<VarRegionList>   regions;
3291
  Array16OfOffset32To<VarData>    dataSets;
3292
  public:
3293
  DEFINE_SIZE_ARRAY_SIZED (8, dataSets);
3294
};
3295
3296
#undef REGION_CACHE_ITEM_CACHE_INVALID
3297
3298
/*
3299
 * Feature Variations
3300
 */
3301
enum Cond_with_Var_flag_t
3302
{
3303
  KEEP_COND_WITH_VAR = 0,
3304
  KEEP_RECORD_WITH_VAR = 1,
3305
  DROP_COND_WITH_VAR = 2,
3306
  DROP_RECORD_WITH_VAR = 3,
3307
};
3308
3309
struct ConditionFormat1
3310
{
3311
  friend struct Condition;
3312
3313
  bool subset (hb_subset_context_t *c) const
3314
0
  {
3315
0
    TRACE_SUBSET (this);
3316
0
    auto *out = c->serializer->embed (this);
3317
0
    if (unlikely (!out)) return_trace (false);
3318
0
3319
0
    const hb_map_t *index_map = &c->plan->axes_index_map;
3320
0
    if (index_map->is_empty ()) return_trace (true);
3321
0
3322
0
    const hb_map_t& axes_old_index_tag_map = c->plan->axes_old_index_tag_map;
3323
0
    hb_codepoint_t *axis_tag;
3324
0
    if (!axes_old_index_tag_map.has (axisIndex, &axis_tag) ||
3325
0
        !index_map->has (axisIndex))
3326
0
      return_trace (false);
3327
0
3328
0
    const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location = c->plan->axes_location;
3329
0
    Triple axis_limit{-1.f, 0.f, 1.f};
3330
0
    Triple *normalized_limit;
3331
0
    if (normalized_axes_location.has (*axis_tag, &normalized_limit))
3332
0
      axis_limit = *normalized_limit;
3333
0
3334
0
    const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances = c->plan->axes_triple_distances;
3335
0
    TripleDistances axis_triple_distances{1.f, 1.f};
3336
0
    TripleDistances *triple_dists;
3337
0
    if (axes_triple_distances.has (*axis_tag, &triple_dists))
3338
0
      axis_triple_distances = *triple_dists;
3339
0
3340
0
    float normalized_min = renormalizeValue (filterRangeMinValue.to_float (), axis_limit, axis_triple_distances, false);
3341
0
    float normalized_max = renormalizeValue (filterRangeMaxValue.to_float (), axis_limit, axis_triple_distances, false);
3342
0
    out->filterRangeMinValue.set_float (normalized_min);
3343
0
    out->filterRangeMaxValue.set_float (normalized_max);
3344
0
3345
0
    return_trace (c->serializer->check_assign (out->axisIndex, index_map->get (axisIndex),
3346
0
                                               HB_SERIALIZE_ERROR_INT_OVERFLOW));
3347
0
  }
3348
3349
  private:
3350
  Cond_with_Var_flag_t keep_with_variations (hb_collect_feature_substitutes_with_var_context_t *c,
3351
                                             hb_map_t *condition_map /* OUT */) const
3352
0
  {
3353
0
    //invalid axis index, drop the entire record
3354
0
    if (!c->axes_index_tag_map->has (axisIndex))
3355
0
      return DROP_RECORD_WITH_VAR;
3356
0
3357
0
    hb_tag_t axis_tag = c->axes_index_tag_map->get (axisIndex);
3358
0
3359
0
    Triple axis_range (-1.f, 0.f, 1.f);
3360
0
    Triple *axis_limit;
3361
0
    bool axis_set_by_user = false;
3362
0
    if (c->axes_location->has (axis_tag, &axis_limit))
3363
0
    {
3364
0
      axis_range = *axis_limit;
3365
0
      axis_set_by_user = true;
3366
0
    }
3367
0
3368
0
    float axis_min_val = axis_range.minimum;
3369
0
    float axis_default_val = axis_range.middle;
3370
0
    float axis_max_val = axis_range.maximum;
3371
0
3372
0
    float filter_min_val = filterRangeMinValue.to_float ();
3373
0
    float filter_max_val = filterRangeMaxValue.to_float ();
3374
0
3375
0
    if (axis_default_val < filter_min_val ||
3376
0
        axis_default_val > filter_max_val)
3377
0
      c->apply = false;
3378
0
3379
0
    //condition not met, drop the entire record
3380
0
    if (axis_min_val > filter_max_val || axis_max_val < filter_min_val ||
3381
0
        filter_min_val > filter_max_val)
3382
0
      return DROP_RECORD_WITH_VAR;
3383
0
3384
0
    //condition met and axis pinned, drop the condition
3385
0
    if (axis_set_by_user && axis_range.is_point ())
3386
0
      return DROP_COND_WITH_VAR;
3387
0
3388
0
    if (filter_max_val != axis_max_val || filter_min_val != axis_min_val)
3389
0
    {
3390
0
      // add axisIndex->value into the hashmap so we can check if the record is
3391
0
      // unique with variations
3392
0
      int16_t int_filter_max_val = filterRangeMaxValue.to_int ();
3393
0
      int16_t int_filter_min_val = filterRangeMinValue.to_int ();
3394
0
      hb_codepoint_t val = (int_filter_max_val << 16) + int_filter_min_val;
3395
0
3396
0
      condition_map->set (axisIndex, val);
3397
0
      return KEEP_COND_WITH_VAR;
3398
0
    }
3399
0
    return KEEP_RECORD_WITH_VAR;
3400
0
  }
3401
3402
  bool evaluate (const int *coords, unsigned int coord_len) const
3403
0
  {
3404
0
    int coord = axisIndex < coord_len ? coords[axisIndex] : 0;
3405
0
    return filterRangeMinValue.to_int () <= coord && coord <= filterRangeMaxValue.to_int ();
3406
0
  }
3407
3408
  bool sanitize (hb_sanitize_context_t *c) const
3409
0
  {
3410
0
    TRACE_SANITIZE (this);
3411
0
    return_trace (c->check_struct (this));
3412
0
  }
3413
3414
  protected:
3415
  HBUINT16  format;   /* Format identifier--format = 1 */
3416
  HBUINT16  axisIndex;
3417
  F2DOT14 filterRangeMinValue;
3418
  F2DOT14 filterRangeMaxValue;
3419
  public:
3420
  DEFINE_SIZE_STATIC (8);
3421
};
3422
3423
struct Condition
3424
{
3425
  bool evaluate (const int *coords, unsigned int coord_len) const
3426
0
  {
3427
0
    switch (u.format) {
3428
0
    case 1: return u.format1.evaluate (coords, coord_len);
3429
0
    default:return false;
3430
0
    }
3431
0
  }
3432
3433
  Cond_with_Var_flag_t keep_with_variations (hb_collect_feature_substitutes_with_var_context_t *c,
3434
                                             hb_map_t *condition_map /* OUT */) const
3435
0
  {
3436
0
    switch (u.format) {
3437
0
    case 1: return u.format1.keep_with_variations (c, condition_map);
3438
0
    default: c->apply = false; return KEEP_COND_WITH_VAR;
3439
0
    }
3440
0
  }
3441
3442
  template <typename context_t, typename ...Ts>
3443
  typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
3444
0
  {
3445
0
    if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value ();
3446
0
    TRACE_DISPATCH (this, u.format);
3447
0
    switch (u.format) {
3448
0
    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
3449
0
    default:return_trace (c->default_return_value ());
3450
0
    }
3451
0
  }
3452
3453
  bool sanitize (hb_sanitize_context_t *c) const
3454
0
  {
3455
0
    TRACE_SANITIZE (this);
3456
0
    if (!u.format.sanitize (c)) return_trace (false);
3457
0
    hb_barrier ();
3458
0
    switch (u.format) {
3459
0
    case 1: return_trace (u.format1.sanitize (c));
3460
0
    default:return_trace (true);
3461
0
    }
3462
0
  }
3463
3464
  protected:
3465
  union {
3466
  HBUINT16    format;   /* Format identifier */
3467
  ConditionFormat1  format1;
3468
  } u;
3469
  public:
3470
  DEFINE_SIZE_UNION (2, format);
3471
};
3472
3473
struct ConditionSet
3474
{
3475
  bool evaluate (const int *coords, unsigned int coord_len) const
3476
0
  {
3477
0
    unsigned int count = conditions.len;
3478
0
    for (unsigned int i = 0; i < count; i++)
3479
0
      if (!(this+conditions.arrayZ[i]).evaluate (coords, coord_len))
3480
0
  return false;
3481
0
    return true;
3482
0
  }
3483
3484
  void keep_with_variations (hb_collect_feature_substitutes_with_var_context_t *c) const
3485
0
  {
3486
0
    hb_map_t *condition_map = hb_map_create ();
3487
0
    if (unlikely (!condition_map)) return;
3488
0
    hb::shared_ptr<hb_map_t> p {condition_map};
3489
0
3490
0
    hb_set_t *cond_set = hb_set_create ();
3491
0
    if (unlikely (!cond_set)) return;
3492
0
    hb::shared_ptr<hb_set_t> s {cond_set};
3493
0
3494
0
    c->apply = true;
3495
0
    bool should_keep = false;
3496
0
    unsigned num_kept_cond = 0, cond_idx = 0;
3497
0
    for (const auto& offset : conditions)
3498
0
    {
3499
0
      Cond_with_Var_flag_t ret = (this+offset).keep_with_variations (c, condition_map);
3500
0
      // condition is not met or condition out of range, drop the entire record
3501
0
      if (ret == DROP_RECORD_WITH_VAR)
3502
0
        return;
3503
0
3504
0
      if (ret == KEEP_COND_WITH_VAR)
3505
0
      {
3506
0
        should_keep = true;
3507
0
        cond_set->add (cond_idx);
3508
0
        num_kept_cond++;
3509
0
      }
3510
0
3511
0
      if (ret == KEEP_RECORD_WITH_VAR)
3512
0
        should_keep = true;
3513
0
3514
0
      cond_idx++;
3515
0
    }
3516
0
3517
0
    if (!should_keep) return;
3518
0
3519
0
    //check if condition_set is unique with variations
3520
0
    if (c->conditionset_map->has (p))
3521
0
      //duplicate found, drop the entire record
3522
0
      return;
3523
0
3524
0
    c->conditionset_map->set (p, 1);
3525
0
    c->record_cond_idx_map->set (c->cur_record_idx, s);
3526
0
    if (should_keep && num_kept_cond == 0)
3527
0
      c->universal = true;
3528
0
  }
3529
3530
  bool subset (hb_subset_context_t *c,
3531
               hb_subset_layout_context_t *l,
3532
               bool insert_catch_all) const
3533
0
  {
3534
0
    TRACE_SUBSET (this);
3535
0
    auto *out = c->serializer->start_embed (this);
3536
0
    if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
3537
0
3538
0
    if (insert_catch_all) return_trace (true);
3539
0
3540
0
    hb_set_t *retained_cond_set = nullptr;
3541
0
    if (l->feature_record_cond_idx_map != nullptr)
3542
0
      retained_cond_set = l->feature_record_cond_idx_map->get (l->cur_feature_var_record_idx);
3543
0
3544
0
    unsigned int count = conditions.len;
3545
0
    for (unsigned int i = 0; i < count; i++)
3546
0
    {
3547
0
      if (retained_cond_set != nullptr && !retained_cond_set->has (i))
3548
0
        continue;
3549
0
      subset_offset_array (c, out->conditions, this) (conditions[i]);
3550
0
    }
3551
0
3552
0
    return_trace (bool (out->conditions));
3553
0
  }
3554
3555
  bool sanitize (hb_sanitize_context_t *c) const
3556
0
  {
3557
0
    TRACE_SANITIZE (this);
3558
0
    return_trace (conditions.sanitize (c, this));
3559
0
  }
3560
3561
  protected:
3562
  Array16OfOffset32To<Condition>  conditions;
3563
  public:
3564
  DEFINE_SIZE_ARRAY (2, conditions);
3565
};
3566
3567
struct FeatureTableSubstitutionRecord
3568
{
3569
  friend struct FeatureTableSubstitution;
3570
3571
  void collect_lookups (const void *base, hb_set_t *lookup_indexes /* OUT */) const
3572
0
  {
3573
0
    return (base+feature).add_lookup_indexes_to (lookup_indexes);
3574
0
  }
3575
3576
  void closure_features (const void *base,
3577
       const hb_map_t *lookup_indexes,
3578
       hb_set_t       *feature_indexes /* OUT */) const
3579
0
  {
3580
0
    if ((base+feature).intersects_lookup_indexes (lookup_indexes))
3581
0
      feature_indexes->add (featureIndex);
3582
0
  }
3583
3584
  void collect_feature_substitutes_with_variations (hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map,
3585
                                                    hb_set_t& catch_all_record_feature_idxes,
3586
                                                    const hb_set_t *feature_indices,
3587
                                                    const void *base) const
3588
0
  {
3589
0
    if (feature_indices->has (featureIndex))
3590
0
    {
3591
0
      feature_substitutes_map->set (featureIndex, &(base+feature));
3592
0
      catch_all_record_feature_idxes.add (featureIndex);
3593
0
    }
3594
0
  }
3595
3596
  bool serialize (hb_subset_layout_context_t *c,
3597
                  unsigned feature_index,
3598
                  const Feature *f, const Tag *tag)
3599
0
  {
3600
0
    TRACE_SERIALIZE (this);
3601
0
    hb_serialize_context_t *s = c->subset_context->serializer;
3602
0
    if (unlikely (!s->extend_min (this))) return_trace (false);
3603
0
3604
0
    uint32_t *new_feature_idx;
3605
0
    if (!c->feature_index_map->has (feature_index, &new_feature_idx))
3606
0
      return_trace (false);
3607
0
3608
0
    if (!s->check_assign (featureIndex, *new_feature_idx, HB_SERIALIZE_ERROR_INT_OVERFLOW))
3609
0
      return_trace (false);
3610
0
3611
0
    s->push ();
3612
0
    bool ret = f->subset (c->subset_context, c, tag);
3613
0
    if (ret) s->add_link (feature, s->pop_pack ());
3614
0
    else s->pop_discard ();
3615
0
3616
0
    return_trace (ret);
3617
0
  }
3618
3619
  bool subset (hb_subset_layout_context_t *c, const void *base) const
3620
0
  {
3621
0
    TRACE_SUBSET (this);
3622
0
    uint32_t *new_feature_index;
3623
0
    if (!c->feature_index_map->has (featureIndex, &new_feature_index))
3624
0
      return_trace (false);
3625
0
3626
0
    auto *out = c->subset_context->serializer->embed (this);
3627
0
    if (unlikely (!out)) return_trace (false);
3628
0
3629
0
    out->featureIndex = *new_feature_index;
3630
0
    return_trace (out->feature.serialize_subset (c->subset_context, feature, base, c));
3631
0
  }
3632
3633
  bool sanitize (hb_sanitize_context_t *c, const void *base) const
3634
0
  {
3635
0
    TRACE_SANITIZE (this);
3636
0
    return_trace (c->check_struct (this) && feature.sanitize (c, base));
3637
0
  }
3638
3639
  protected:
3640
  HBUINT16    featureIndex;
3641
  Offset32To<Feature> feature;
3642
  public:
3643
  DEFINE_SIZE_STATIC (6);
3644
};
3645
3646
struct FeatureTableSubstitution
3647
{
3648
  const Feature *find_substitute (unsigned int feature_index) const
3649
0
  {
3650
0
    unsigned int count = substitutions.len;
3651
0
    for (unsigned int i = 0; i < count; i++)
3652
0
    {
3653
0
      const FeatureTableSubstitutionRecord &record = substitutions.arrayZ[i];
3654
0
      if (record.featureIndex == feature_index)
3655
0
  return &(this+record.feature);
3656
0
    }
3657
0
    return nullptr;
3658
0
  }
3659
3660
  void collect_lookups (const hb_set_t *feature_indexes,
3661
      hb_set_t       *lookup_indexes /* OUT */) const
3662
0
  {
3663
0
    + hb_iter (substitutions)
3664
0
    | hb_filter (feature_indexes, &FeatureTableSubstitutionRecord::featureIndex)
3665
0
    | hb_apply ([this, lookup_indexes] (const FeatureTableSubstitutionRecord& r)
3666
0
    { r.collect_lookups (this, lookup_indexes); })
3667
0
    ;
3668
0
  }
3669
3670
  void closure_features (const hb_map_t *lookup_indexes,
3671
       hb_set_t       *feature_indexes /* OUT */) const
3672
0
  {
3673
0
    for (const FeatureTableSubstitutionRecord& record : substitutions)
3674
0
      record.closure_features (this, lookup_indexes, feature_indexes);
3675
0
  }
3676
3677
  bool intersects_features (const hb_map_t *feature_index_map) const
3678
0
  {
3679
0
    for (const FeatureTableSubstitutionRecord& record : substitutions)
3680
0
    {
3681
0
      if (feature_index_map->has (record.featureIndex)) return true;
3682
0
    }
3683
0
    return false;
3684
0
  }
3685
3686
  void collect_feature_substitutes_with_variations (hb_collect_feature_substitutes_with_var_context_t *c) const
3687
0
  {
3688
0
    for (const FeatureTableSubstitutionRecord& record : substitutions)
3689
0
      record.collect_feature_substitutes_with_variations (c->feature_substitutes_map,
3690
0
                                                          c->catch_all_record_feature_idxes,
3691
0
                                                          c->feature_indices, this);
3692
0
  }
3693
3694
  bool subset (hb_subset_context_t        *c,
3695
         hb_subset_layout_context_t *l,
3696
               bool insert_catch_all) const
3697
0
  {
3698
0
    TRACE_SUBSET (this);
3699
0
    auto *out = c->serializer->start_embed (*this);
3700
0
    if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
3701
0
3702
0
    out->version.major = version.major;
3703
0
    out->version.minor = version.minor;
3704
0
3705
0
    if (insert_catch_all)
3706
0
    {
3707
0
      for (unsigned feature_index : *(l->catch_all_record_feature_idxes))
3708
0
      {
3709
0
        hb_pair_t<const void*, const void*> *p;
3710
0
        if (!l->feature_idx_tag_map->has (feature_index, &p))
3711
0
          return_trace (false);
3712
0
        auto *o = out->substitutions.serialize_append (c->serializer);
3713
0
        if (!o->serialize (l, feature_index,
3714
0
                           reinterpret_cast<const Feature*> (p->first),
3715
0
                           reinterpret_cast<const Tag*> (p->second)))
3716
0
          return_trace (false);
3717
0
      }
3718
0
      return_trace (true);
3719
0
    }
3720
0
3721
0
    + substitutions.iter ()
3722
0
    | hb_apply (subset_record_array (l, &(out->substitutions), this))
3723
0
    ;
3724
0
3725
0
    return_trace (bool (out->substitutions));
3726
0
  }
3727
3728
  bool sanitize (hb_sanitize_context_t *c) const
3729
0
  {
3730
0
    TRACE_SANITIZE (this);
3731
0
    return_trace (version.sanitize (c) &&
3732
0
      hb_barrier () &&
3733
0
      likely (version.major == 1) &&
3734
0
      substitutions.sanitize (c, this));
3735
0
  }
3736
3737
  protected:
3738
  FixedVersion<>  version;  /* Version--0x00010000u */
3739
  Array16Of<FeatureTableSubstitutionRecord>
3740
      substitutions;
3741
  public:
3742
  DEFINE_SIZE_ARRAY (6, substitutions);
3743
};
3744
3745
struct FeatureVariationRecord
3746
{
3747
  friend struct FeatureVariations;
3748
3749
  void collect_lookups (const void     *base,
3750
      const hb_set_t *feature_indexes,
3751
      hb_set_t       *lookup_indexes /* OUT */) const
3752
0
  {
3753
0
    return (base+substitutions).collect_lookups (feature_indexes, lookup_indexes);
3754
0
  }
3755
3756
  void closure_features (const void     *base,
3757
       const hb_map_t *lookup_indexes,
3758
       hb_set_t       *feature_indexes /* OUT */) const
3759
0
  {
3760
0
    (base+substitutions).closure_features (lookup_indexes, feature_indexes);
3761
0
  }
3762
3763
  bool intersects_features (const void *base, const hb_map_t *feature_index_map) const
3764
0
  {
3765
0
    return (base+substitutions).intersects_features (feature_index_map);
3766
0
  }
3767
3768
  void collect_feature_substitutes_with_variations (hb_collect_feature_substitutes_with_var_context_t *c,
3769
                                                    const void *base) const
3770
0
  {
3771
0
    (base+conditions).keep_with_variations (c);
3772
0
    if (c->apply && !c->variation_applied)
3773
0
    {
3774
0
      (base+substitutions).collect_feature_substitutes_with_variations (c);
3775
0
      c->variation_applied = true; // set variations only once
3776
0
    }
3777
0
  }
3778
3779
  bool subset (hb_subset_layout_context_t *c, const void *base,
3780
               bool insert_catch_all = false) const
3781
0
  {
3782
0
    TRACE_SUBSET (this);
3783
0
    auto *out = c->subset_context->serializer->embed (this);
3784
0
    if (unlikely (!out)) return_trace (false);
3785
0
3786
0
    out->conditions.serialize_subset (c->subset_context, conditions, base, c, insert_catch_all);
3787
0
    out->substitutions.serialize_subset (c->subset_context, substitutions, base, c, insert_catch_all);
3788
0
3789
0
    return_trace (true);
3790
0
  }
3791
3792
  bool sanitize (hb_sanitize_context_t *c, const void *base) const
3793
0
  {
3794
0
    TRACE_SANITIZE (this);
3795
0
    return_trace (conditions.sanitize (c, base) &&
3796
0
      substitutions.sanitize (c, base));
3797
0
  }
3798
3799
  protected:
3800
  Offset32To<ConditionSet>
3801
      conditions;
3802
  Offset32To<FeatureTableSubstitution>
3803
      substitutions;
3804
  public:
3805
  DEFINE_SIZE_STATIC (8);
3806
};
3807
3808
struct FeatureVariations
3809
{
3810
  static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFFFFFu;
3811
3812
  bool find_index (const int *coords, unsigned int coord_len,
3813
       unsigned int *index) const
3814
0
  {
3815
0
    unsigned int count = varRecords.len;
3816
0
    for (unsigned int i = 0; i < count; i++)
3817
0
    {
3818
0
      const FeatureVariationRecord &record = varRecords.arrayZ[i];
3819
0
      if ((this+record.conditions).evaluate (coords, coord_len))
3820
0
      {
3821
0
  *index = i;
3822
0
  return true;
3823
0
      }
3824
0
    }
3825
0
    *index = NOT_FOUND_INDEX;
3826
0
    return false;
3827
0
  }
3828
3829
  const Feature *find_substitute (unsigned int variations_index,
3830
          unsigned int feature_index) const
3831
0
  {
3832
0
    const FeatureVariationRecord &record = varRecords[variations_index];
3833
0
    return (this+record.substitutions).find_substitute (feature_index);
3834
0
  }
3835
3836
  void collect_feature_substitutes_with_variations (hb_collect_feature_substitutes_with_var_context_t *c) const
3837
0
  {
3838
0
    unsigned int count = varRecords.len;
3839
0
    for (unsigned int i = 0; i < count; i++)
3840
0
    {
3841
0
      c->cur_record_idx = i;
3842
0
      varRecords[i].collect_feature_substitutes_with_variations (c, this);
3843
0
      if (c->universal)
3844
0
        break;
3845
0
    }
3846
0
    if (c->universal || c->record_cond_idx_map->is_empty ())
3847
0
      c->catch_all_record_feature_idxes.reset ();
3848
0
  }
3849
3850
  FeatureVariations* copy (hb_serialize_context_t *c) const
3851
0
  {
3852
0
    TRACE_SERIALIZE (this);
3853
0
    return_trace (c->embed (*this));
3854
0
  }
3855
3856
  void collect_lookups (const hb_set_t *feature_indexes,
3857
      const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map,
3858
      hb_set_t       *lookup_indexes /* OUT */) const
3859
0
  {
3860
0
    unsigned count = varRecords.len;
3861
0
    for (unsigned int i = 0; i < count; i++)
3862
0
    {
3863
0
      if (feature_record_cond_idx_map &&
3864
0
          !feature_record_cond_idx_map->has (i))
3865
0
        continue;
3866
0
      varRecords[i].collect_lookups (this, feature_indexes, lookup_indexes);
3867
0
    }
3868
0
  }
3869
3870
  void closure_features (const hb_map_t *lookup_indexes,
3871
       const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map,
3872
       hb_set_t       *feature_indexes /* OUT */) const
3873
0
  {
3874
0
    unsigned int count = varRecords.len;
3875
0
    for (unsigned int i = 0; i < count; i++)
3876
0
    {
3877
0
      if (feature_record_cond_idx_map != nullptr &&
3878
0
          !feature_record_cond_idx_map->has (i))
3879
0
        continue;
3880
0
      varRecords[i].closure_features (this, lookup_indexes, feature_indexes);
3881
0
    }
3882
0
  }
3883
3884
  bool subset (hb_subset_context_t *c,
3885
         hb_subset_layout_context_t *l) const
3886
0
  {
3887
0
    TRACE_SUBSET (this);
3888
0
    auto *out = c->serializer->start_embed (*this);
3889
0
    if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false);
3890
0
3891
0
    out->version.major = version.major;
3892
0
    out->version.minor = version.minor;
3893
0
3894
0
    int keep_up_to = -1;
3895
0
    for (int i = varRecords.len - 1; i >= 0; i--) {
3896
0
      if (varRecords[i].intersects_features (this, l->feature_index_map)) {
3897
0
        keep_up_to = i;
3898
0
        break;
3899
0
      }
3900
0
    }
3901
0
3902
0
    unsigned count = (unsigned) (keep_up_to + 1);
3903
0
    for (unsigned i = 0; i < count; i++)
3904
0
    {
3905
0
      if (l->feature_record_cond_idx_map != nullptr &&
3906
0
          !l->feature_record_cond_idx_map->has (i))
3907
0
        continue;
3908
0
3909
0
      l->cur_feature_var_record_idx = i;
3910
0
      subset_record_array (l, &(out->varRecords), this) (varRecords[i]);
3911
0
    }
3912
0
3913
0
    if (out->varRecords.len && !l->catch_all_record_feature_idxes->is_empty ())
3914
0
    {
3915
0
      bool insert_catch_all_record = true;
3916
0
      subset_record_array (l, &(out->varRecords), this, insert_catch_all_record) (varRecords[0]);
3917
0
    }
3918
0
3919
0
    return_trace (bool (out->varRecords));
3920
0
  }
3921
3922
  bool sanitize (hb_sanitize_context_t *c) const
3923
0
  {
3924
0
    TRACE_SANITIZE (this);
3925
0
    return_trace (version.sanitize (c) &&
3926
0
      hb_barrier () &&
3927
0
      likely (version.major == 1) &&
3928
0
      varRecords.sanitize (c, this));
3929
0
  }
3930
3931
  protected:
3932
  FixedVersion<>  version;  /* Version--0x00010000u */
3933
  Array32Of<FeatureVariationRecord>
3934
      varRecords;
3935
  public:
3936
  DEFINE_SIZE_ARRAY_SIZED (8, varRecords);
3937
};
3938
3939
3940
/*
3941
 * Device Tables
3942
 */
3943
3944
struct HintingDevice
3945
{
3946
  friend struct Device;
3947
3948
  private:
3949
3950
  hb_position_t get_x_delta (hb_font_t *font) const
3951
0
  { return get_delta (font->x_ppem, font->x_scale); }
3952
3953
  hb_position_t get_y_delta (hb_font_t *font) const
3954
0
  { return get_delta (font->y_ppem, font->y_scale); }
3955
3956
  public:
3957
3958
  unsigned int get_size () const
3959
0
  {
3960
0
    unsigned int f = deltaFormat;
3961
0
    if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * HBUINT16::static_size;
3962
0
    return HBUINT16::static_size * (4 + ((endSize - startSize) >> (4 - f)));
3963
0
  }
3964
3965
  bool sanitize (hb_sanitize_context_t *c) const
3966
0
  {
3967
0
    TRACE_SANITIZE (this);
3968
0
    return_trace (c->check_struct (this) && c->check_range (this, this->get_size ()));
3969
0
  }
3970
3971
  HintingDevice* copy (hb_serialize_context_t *c) const
3972
0
  {
3973
0
    TRACE_SERIALIZE (this);
3974
0
    return_trace (c->embed<HintingDevice> (this));
3975
0
  }
3976
3977
  private:
3978
3979
  int get_delta (unsigned int ppem, int scale) const
3980
0
  {
3981
0
    if (!ppem) return 0;
3982
3983
0
    int pixels = get_delta_pixels (ppem);
3984
3985
0
    if (!pixels) return 0;
3986
3987
0
    return (int) (pixels * (int64_t) scale / ppem);
3988
0
  }
3989
  int get_delta_pixels (unsigned int ppem_size) const
3990
0
  {
3991
0
    unsigned int f = deltaFormat;
3992
0
    if (unlikely (f < 1 || f > 3))
3993
0
      return 0;
3994
3995
0
    if (ppem_size < startSize || ppem_size > endSize)
3996
0
      return 0;
3997
3998
0
    unsigned int s = ppem_size - startSize;
3999
4000
0
    unsigned int byte = deltaValueZ[s >> (4 - f)];
4001
0
    unsigned int bits = (byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f)));
4002
0
    unsigned int mask = (0xFFFFu >> (16 - (1 << f)));
4003
4004
0
    int delta = bits & mask;
4005
4006
0
    if ((unsigned int) delta >= ((mask + 1) >> 1))
4007
0
      delta -= mask + 1;
4008
4009
0
    return delta;
4010
0
  }
4011
4012
  protected:
4013
  HBUINT16  startSize;    /* Smallest size to correct--in ppem */
4014
  HBUINT16  endSize;    /* Largest size to correct--in ppem */
4015
  HBUINT16  deltaFormat;    /* Format of DeltaValue array data: 1, 2, or 3
4016
           * 1  Signed 2-bit value, 8 values per uint16
4017
           * 2  Signed 4-bit value, 4 values per uint16
4018
           * 3  Signed 8-bit value, 2 values per uint16
4019
           */
4020
  UnsizedArrayOf<HBUINT16>
4021
    deltaValueZ;    /* Array of compressed data */
4022
  public:
4023
  DEFINE_SIZE_ARRAY (6, deltaValueZ);
4024
};
4025
4026
struct VariationDevice
4027
{
4028
  friend struct Device;
4029
4030
  private:
4031
4032
  hb_position_t get_x_delta (hb_font_t *font,
4033
           const ItemVariationStore &store,
4034
           ItemVariationStore::cache_t *store_cache = nullptr) const
4035
0
  { return font->em_scalef_x (get_delta (font, store, store_cache)); }
4036
4037
  hb_position_t get_y_delta (hb_font_t *font,
4038
           const ItemVariationStore &store,
4039
           ItemVariationStore::cache_t *store_cache = nullptr) const
4040
0
  { return font->em_scalef_y (get_delta (font, store, store_cache)); }
4041
4042
  VariationDevice* copy (hb_serialize_context_t *c,
4043
                         const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map) const
4044
0
  {
4045
0
    TRACE_SERIALIZE (this);
4046
0
    if (!layout_variation_idx_delta_map) return_trace (nullptr);
4047
0
4048
0
    hb_pair_t<unsigned, int> *v;
4049
0
    if (!layout_variation_idx_delta_map->has (varIdx, &v))
4050
0
      return_trace (nullptr);
4051
0
4052
0
    c->start_zerocopy (this->static_size);
4053
0
    auto *out = c->embed (this);
4054
0
    if (unlikely (!out)) return_trace (nullptr);
4055
0
4056
0
    if (!c->check_assign (out->varIdx, hb_first (*v), HB_SERIALIZE_ERROR_INT_OVERFLOW))
4057
0
      return_trace (nullptr);
4058
0
    return_trace (out);
4059
0
  }
4060
4061
  void collect_variation_index (hb_collect_variation_indices_context_t *c) const
4062
0
  { c->layout_variation_indices->add (varIdx); }
4063
4064
  bool sanitize (hb_sanitize_context_t *c) const
4065
0
  {
4066
0
    TRACE_SANITIZE (this);
4067
0
    return_trace (c->check_struct (this));
4068
0
  }
4069
4070
  private:
4071
4072
  float get_delta (hb_font_t *font,
4073
       const ItemVariationStore &store,
4074
       ItemVariationStore::cache_t *store_cache = nullptr) const
4075
0
  {
4076
0
    return store.get_delta (varIdx, font->coords, font->num_coords, (ItemVariationStore::cache_t *) store_cache);
4077
0
  }
4078
4079
  protected:
4080
  VarIdx  varIdx;
4081
  HBUINT16  deltaFormat;  /* Format identifier for this table: 0x0x8000 */
4082
  public:
4083
  DEFINE_SIZE_STATIC (6);
4084
};
4085
4086
struct DeviceHeader
4087
{
4088
  protected:
4089
  HBUINT16    reserved1;
4090
  HBUINT16    reserved2;
4091
  public:
4092
  HBUINT16    format;   /* Format identifier */
4093
  public:
4094
  DEFINE_SIZE_STATIC (6);
4095
};
4096
4097
struct Device
4098
{
4099
  hb_position_t get_x_delta (hb_font_t *font,
4100
           const ItemVariationStore &store=Null (ItemVariationStore),
4101
           ItemVariationStore::cache_t *store_cache = nullptr) const
4102
0
  {
4103
0
    switch (u.b.format)
4104
0
    {
4105
0
#ifndef HB_NO_HINTING
4106
0
    case 1: case 2: case 3:
4107
0
      return u.hinting.get_x_delta (font);
4108
0
#endif
4109
0
#ifndef HB_NO_VAR
4110
0
    case 0x8000:
4111
0
      return u.variation.get_x_delta (font, store, store_cache);
4112
0
#endif
4113
0
    default:
4114
0
      return 0;
4115
0
    }
4116
0
  }
4117
  hb_position_t get_y_delta (hb_font_t *font,
4118
           const ItemVariationStore &store=Null (ItemVariationStore),
4119
           ItemVariationStore::cache_t *store_cache = nullptr) const
4120
0
  {
4121
0
    switch (u.b.format)
4122
0
    {
4123
0
    case 1: case 2: case 3:
4124
0
#ifndef HB_NO_HINTING
4125
0
      return u.hinting.get_y_delta (font);
4126
0
#endif
4127
0
#ifndef HB_NO_VAR
4128
0
    case 0x8000:
4129
0
      return u.variation.get_y_delta (font, store, store_cache);
4130
0
#endif
4131
0
    default:
4132
0
      return 0;
4133
0
    }
4134
0
  }
4135
4136
  bool sanitize (hb_sanitize_context_t *c) const
4137
0
  {
4138
0
    TRACE_SANITIZE (this);
4139
0
    if (!u.b.format.sanitize (c)) return_trace (false);
4140
0
    switch (u.b.format) {
4141
0
#ifndef HB_NO_HINTING
4142
0
    case 1: case 2: case 3:
4143
0
      return_trace (u.hinting.sanitize (c));
4144
0
#endif
4145
0
#ifndef HB_NO_VAR
4146
0
    case 0x8000:
4147
0
      return_trace (u.variation.sanitize (c));
4148
0
#endif
4149
0
    default:
4150
0
      return_trace (true);
4151
0
    }
4152
0
  }
4153
4154
  Device* copy (hb_serialize_context_t *c,
4155
                const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map=nullptr) const
4156
0
  {
4157
0
    TRACE_SERIALIZE (this);
4158
0
    switch (u.b.format) {
4159
0
#ifndef HB_NO_HINTING
4160
0
    case 1:
4161
0
    case 2:
4162
0
    case 3:
4163
0
      return_trace (reinterpret_cast<Device *> (u.hinting.copy (c)));
4164
0
#endif
4165
0
#ifndef HB_NO_VAR
4166
0
    case 0x8000:
4167
0
      return_trace (reinterpret_cast<Device *> (u.variation.copy (c, layout_variation_idx_delta_map)));
4168
0
#endif
4169
0
    default:
4170
0
      return_trace (nullptr);
4171
0
    }
4172
0
  }
4173
4174
  void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
4175
0
  {
4176
0
    switch (u.b.format) {
4177
0
#ifndef HB_NO_HINTING
4178
0
    case 1:
4179
0
    case 2:
4180
0
    case 3:
4181
0
      return;
4182
0
#endif
4183
0
#ifndef HB_NO_VAR
4184
0
    case 0x8000:
4185
0
      u.variation.collect_variation_index (c);
4186
0
      return;
4187
0
#endif
4188
0
    default:
4189
0
      return;
4190
0
    }
4191
0
  }
4192
4193
  unsigned get_variation_index () const
4194
0
  {
4195
0
    switch (u.b.format) {
4196
0
#ifndef HB_NO_VAR
4197
0
    case 0x8000:
4198
0
      return u.variation.varIdx;
4199
0
#endif
4200
0
    default:
4201
0
      return HB_OT_LAYOUT_NO_VARIATIONS_INDEX;
4202
0
    }
4203
0
  }
4204
4205
  protected:
4206
  union {
4207
  DeviceHeader    b;
4208
  HintingDevice   hinting;
4209
#ifndef HB_NO_VAR
4210
  VariationDevice variation;
4211
#endif
4212
  } u;
4213
  public:
4214
  DEFINE_SIZE_UNION (6, b);
4215
};
4216
4217
4218
} /* namespace OT */
4219
4220
4221
#endif /* HB_OT_LAYOUT_COMMON_HH */