Imported Upstream version 8.2.2
[platform/upstream/harfbuzz.git] / src / OT / Layout / GPOS / LigatureArray.hh
1 #ifndef OT_LAYOUT_GPOS_LIGATUREARRAY_HH
2 #define OT_LAYOUT_GPOS_LIGATUREARRAY_HH
3
4 namespace OT {
5 namespace Layout {
6 namespace GPOS_impl {
7
8
9 typedef AnchorMatrix LigatureAttach;    /* component-major--
10                                          * in order of writing direction--,
11                                          * mark-minor--
12                                          * ordered by class--zero-based. */
13
14 /* Array of LigatureAttach tables ordered by LigatureCoverage Index */
15 struct LigatureArray : List16OfOffset16To<LigatureAttach>
16 {
17   template <typename Iterator,
18             hb_requires (hb_is_iterator (Iterator))>
19   bool subset (hb_subset_context_t *c,
20                Iterator             coverage,
21                unsigned             class_count,
22                const hb_map_t      *klass_mapping) const
23   {
24     TRACE_SUBSET (this);
25     const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
26
27     auto *out = c->serializer->start_embed (this);
28     if (unlikely (!c->serializer->extend_min (out)))  return_trace (false);
29
30     bool ret = false;
31     for (const auto _ : + hb_zip (coverage, *this)
32                   | hb_filter (glyphset, hb_first))
33     {
34       auto *matrix = out->serialize_append (c->serializer);
35       if (unlikely (!matrix)) return_trace (false);
36
37       const LigatureAttach& src = (this + _.second);
38       auto indexes =
39           + hb_range (src.rows * class_count)
40           | hb_filter ([=] (unsigned index) { return klass_mapping->has (index % class_count); })
41           ;
42       ret |= matrix->serialize_subset (c,
43                                        _.second,
44                                        this,
45                                        src.rows,
46                                        indexes);
47     }
48     return_trace (ret);
49   }
50 };
51
52
53 }
54 }
55 }
56
57 #endif /* OT_LAYOUT_GPOS_LIGATUREARRAY_HH */