1#ifndef OT_LAYOUT_GPOS_PAIRVALUERECORD_HH
2#define OT_LAYOUT_GPOS_PAIRVALUERECORD_HH
3
4#include "ValueFormat.hh"
5
6namespace OT {
7namespace Layout {
8namespace GPOS_impl {
9
10
11template <typename Types>
12struct PairValueRecord
13{
14 template <typename Types2>
15 friend struct PairSet;
16
17 protected:
18 typename Types::HBGlyphID
19 secondGlyph; /* GlyphID of second glyph in the
20 * pair--first glyph is listed in the
21 * Coverage table */
22 ValueRecord values; /* Positioning data for the first glyph
23 * followed by for second glyph */
24 public:
25 DEFINE_SIZE_ARRAY (Types::HBGlyphID::static_size, values);
26
27 int cmp (hb_codepoint_t k) const
28 { return secondGlyph.cmp (k); }
29
30 struct context_t
31 {
32 const void *base;
33 const ValueFormat *valueFormats;
34 const ValueFormat *newFormats;
35 unsigned len1; /* valueFormats[0].get_len() */
36 const hb_map_t *glyph_map;
37 const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map;
38 };
39
40 bool subset (hb_subset_context_t *c,
41 context_t *closure) const
42 {
43 TRACE_SERIALIZE (this);
44 auto *s = c->serializer;
45 auto *out = s->start_embed (*this);
46 if (unlikely (!s->extend_min (out))) return_trace (false);
47
48 out->secondGlyph = (*closure->glyph_map)[secondGlyph];
49
50 closure->valueFormats[0].copy_values (s,
51 closure->newFormats[0],
52 closure->base, &values[0],
53 closure->layout_variation_idx_delta_map);
54 closure->valueFormats[1].copy_values (s,
55 closure->newFormats[1],
56 closure->base,
57 &values[closure->len1],
58 closure->layout_variation_idx_delta_map);
59
60 return_trace (true);
61 }
62
63 void collect_variation_indices (hb_collect_variation_indices_context_t *c,
64 const ValueFormat *valueFormats,
65 const void *base) const
66 {
67 unsigned record1_len = valueFormats[0].get_len ();
68 unsigned record2_len = valueFormats[1].get_len ();
69 const hb_array_t<const Value> values_array = values.as_array (record1_len + record2_len);
70
71 if (valueFormats[0].has_device ())
72 valueFormats[0].collect_variation_indices (c, base, values_array.sub_array (0, record1_len));
73
74 if (valueFormats[1].has_device ())
75 valueFormats[1].collect_variation_indices (c, base, values_array.sub_array (record1_len, record2_len));
76 }
77
78 bool intersects (const hb_set_t& glyphset) const
79 {
80 return glyphset.has(secondGlyph);
81 }
82
83 const Value* get_values_1 () const
84 {
85 return &values[0];
86 }
87
88 const Value* get_values_2 (ValueFormat format1) const
89 {
90 return &values[format1.get_len ()];
91 }
92};
93
94
95}
96}
97}
98
99#endif // OT_LAYOUT_GPOS_PAIRVALUERECORD_HH
100