Coverage Report

Created: 2025-10-10 06:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/harfbuzz/src/OT/Layout/GSUB/MultipleSubstFormat1.hh
Line
Count
Source
1
#ifndef OT_LAYOUT_GSUB_MULTIPLESUBSTFORMAT1_HH
2
#define OT_LAYOUT_GSUB_MULTIPLESUBSTFORMAT1_HH
3
4
#include "Common.hh"
5
#include "Sequence.hh"
6
7
namespace OT {
8
namespace Layout {
9
namespace GSUB_impl {
10
11
template <typename Types>
12
struct MultipleSubstFormat1_2
13
{
14
  protected:
15
  HBUINT16      format;                 /* Format identifier--format = 1 */
16
  typename Types::template OffsetTo<Coverage>
17
                coverage;               /* Offset to Coverage table--from
18
                                         * beginning of Substitution table */
19
  Array16Of<typename Types::template OffsetTo<Sequence<Types>>>
20
                sequence;               /* Array of Sequence tables
21
                                         * ordered by Coverage Index */
22
  public:
23
  DEFINE_SIZE_ARRAY (4 + Types::size, sequence);
24
25
  bool sanitize (hb_sanitize_context_t *c) const
26
0
  {
27
0
    TRACE_SANITIZE (this);
28
0
    return_trace (coverage.sanitize (c, this) && sequence.sanitize (c, this));
29
0
  }
30
31
  bool intersects (const hb_set_t *glyphs) const
32
0
  { return (this+coverage).intersects (glyphs); }
33
34
  bool may_have_non_1to1 () const
35
0
  { return true; }
36
37
  void closure (hb_closure_context_t *c) const
38
0
  {
39
0
    + hb_zip (this+coverage, sequence)
40
0
    | hb_filter (c->parent_active_glyphs (), hb_first)
41
0
    | hb_map (hb_second)
42
0
    | hb_map (hb_add (this))
43
0
    | hb_apply ([c] (const Sequence<Types> &_) { _.closure (c); })
44
0
    ;
45
0
  }
46
47
0
  void closure_lookups (hb_closure_lookups_context_t *c) const {}
48
49
  void collect_glyphs (hb_collect_glyphs_context_t *c) const
50
0
  {
51
0
    if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
52
0
    + hb_zip (this+coverage, sequence)
53
0
    | hb_map (hb_second)
54
0
    | hb_map (hb_add (this))
55
0
    | hb_apply ([c] (const Sequence<Types> &_) { _.collect_glyphs (c); })
56
0
    ;
57
0
  }
58
59
0
  const Coverage &get_coverage () const { return this+coverage; }
60
61
  bool would_apply (hb_would_apply_context_t *c) const
62
0
  { return c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED; }
63
64
  bool apply (hb_ot_apply_context_t *c) const
65
0
  {
66
0
    TRACE_APPLY (this);
67
68
0
    unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
69
0
    if (index == NOT_COVERED) return_trace (false);
70
71
0
    return_trace ((this+sequence[index]).apply (c));
72
0
  }
73
74
  template<typename Iterator,
75
           hb_requires (hb_is_sorted_iterator (Iterator))>
76
  bool serialize (hb_serialize_context_t *c,
77
      Iterator it)
78
  {
79
    TRACE_SERIALIZE (this);
80
    auto sequences =
81
      + it
82
      | hb_map (hb_second)
83
      ;
84
    auto glyphs =
85
      + it
86
      | hb_map_retains_sorting (hb_first)
87
      ;
88
    if (unlikely (!c->extend_min (this))) return_trace (false);
89
90
    if (unlikely (!sequence.serialize (c, sequences.length))) return_trace (false);
91
92
    for (auto& pair : hb_zip (sequences, sequence))
93
    {
94
      if (unlikely (!pair.second
95
        .serialize_serialize (c, pair.first)))
96
        return_trace (false);
97
    }
98
99
    return_trace (coverage.serialize_serialize (c, glyphs));
100
  }
101
102
  bool subset (hb_subset_context_t *c) const
103
0
  {
104
0
    TRACE_SUBSET (this);
105
0
    const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
106
0
    const hb_map_t &glyph_map = *c->plan->glyph_map;
107
0
108
0
    auto *out = c->serializer->start_embed (*this);
109
0
    if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
110
0
    out->format = format;
111
0
112
0
    hb_sorted_vector_t<hb_codepoint_t> new_coverage;
113
0
    + hb_zip (this+coverage, sequence)
114
0
    | hb_filter (glyphset, hb_first)
115
0
    | hb_filter (subset_offset_array (c, out->sequence, this), hb_second)
116
0
    | hb_map (hb_first)
117
0
    | hb_map (glyph_map)
118
0
    | hb_sink (new_coverage)
119
0
    ;
120
0
    out->coverage.serialize_serialize (c->serializer, new_coverage.iter ());
121
0
    return_trace (bool (new_coverage));
122
0
  }
123
};
124
125
}
126
}
127
}
128
129
130
#endif /* OT_LAYOUT_GSUB_MULTIPLESUBSTFORMAT1_HH */