1 #ifndef OT_LAYOUT_GPOS_SINGLEPOS_HH
2 #define OT_LAYOUT_GPOS_SINGLEPOS_HH
4 #include "SinglePosFormat1.hh"
5 #include "SinglePosFormat2.hh"
15 HBUINT16 format; /* Format identifier */
16 SinglePosFormat1 format1;
17 SinglePosFormat2 format2;
21 template<typename Iterator,
22 hb_requires (hb_is_iterator (Iterator))>
23 unsigned get_format (Iterator glyph_val_iter_pairs)
25 hb_array_t<const Value> first_val_iter = hb_second (*glyph_val_iter_pairs);
27 for (const auto iter : glyph_val_iter_pairs)
28 for (const auto _ : hb_zip (iter.second, first_val_iter))
29 if (_.first != _.second)
35 template<typename Iterator,
37 hb_requires (hb_is_iterator (Iterator))>
38 void serialize (hb_serialize_context_t *c,
40 Iterator glyph_val_iter_pairs,
41 const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map,
44 if (unlikely (!c->extend_min (u.format))) return;
46 ValueFormat new_format = src->get_value_format ();
49 new_format = new_format.drop_device_table_flags ();
51 if (glyph_val_iter_pairs)
52 format = get_format (glyph_val_iter_pairs);
56 case 1: u.format1.serialize (c,
60 layout_variation_idx_delta_map);
62 case 2: u.format2.serialize (c,
66 layout_variation_idx_delta_map);
72 template <typename context_t, typename ...Ts>
73 typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
75 if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value ();
76 TRACE_DISPATCH (this, u.format);
78 case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
79 case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
80 default:return_trace (c->default_return_value ());
86 template<typename Iterator, typename SrcLookup>
88 SinglePos_serialize (hb_serialize_context_t *c,
91 const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map,
93 { c->start_embed<SinglePos> ()->serialize (c, src, it, layout_variation_idx_delta_map, all_axes_pinned); }
100 #endif /* OT_LAYOUT_GPOS_SINGLEPOS_HH */