Coverage Report

Created: 2025-10-10 06:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/harfbuzz/src/hb-subset-table-cff.cc
Line
Count
Source
1
#include "hb-subset-table.hh"
2
3
#include "hb-ot-cff1-table.hh"
4
#include "hb-ot-cff2-table.hh"
5
#include "hb-ot-vorg-table.hh"
6
7
8
#ifndef HB_NO_SUBSET_CFF
9
template<>
10
struct hb_subset_plan_t::source_table_loader<const OT::cff1>
11
{
12
  auto operator () (hb_subset_plan_t *plan)
13
  HB_AUTO_RETURN (plan->accelerator ? plan->accelerator->cff1_accel :
14
      plan->inprogress_accelerator ? plan->inprogress_accelerator->cff1_accel :
15
      plan->cff1_accel)
16
};
17
template<>
18
struct hb_subset_plan_t::source_table_loader<const OT::cff2>
19
{
20
  auto operator () (hb_subset_plan_t *plan)
21
  HB_AUTO_RETURN (plan->accelerator ? plan->accelerator->cff2_accel :
22
      plan->inprogress_accelerator ? plan->inprogress_accelerator->cff2_accel :
23
      plan->cff2_accel)
24
};
25
#endif
26
27
28
bool _hb_subset_table_cff   (hb_subset_plan_t *plan, hb_vector_t<char> &buf, hb_tag_t tag, bool *success)
29
451k
{
30
451k
#ifndef HB_NO_SUBSET_CFF
31
451k
  switch (tag)
32
451k
  {
33
2.82k
  case HB_TAG('C','F','F',' '): *success = _hb_subset_table<const OT::cff1> (plan, buf); return true;
34
1.85k
  case HB_TAG('C','F','F','2'): *success = _hb_subset_table<const OT::cff2> (plan, buf); return true;
35
191
  case HB_TAG('V','O','R','G'): *success = _hb_subset_table<const OT::VORG> (plan, buf); return true;
36
451k
  }
37
446k
#endif
38
446k
  return false;
39
451k
}
40
41
42
#ifdef HB_EXPERIMENTAL_API
43
#ifndef HB_NO_CFF
44
45
template<typename accel_t>
46
0
static hb_blob_t* get_charstrings_data(accel_t& accel, hb_codepoint_t glyph_index) {
47
0
  if (!accel.is_valid()) {
48
0
    return hb_blob_get_empty ();
49
0
  }
50
51
0
  hb_ubytes_t bytes = (*accel.charStrings)[glyph_index];
52
0
  if (!bytes) {
53
0
    return hb_blob_get_empty ();
54
0
  }
55
56
0
  hb_blob_t* cff_blob = accel.get_blob();
57
0
  uint32_t length;
58
0
  const char* cff_data = hb_blob_get_data(cff_blob, &length) ;
59
60
0
  long int offset = (const char*) bytes.arrayZ - cff_data;
61
0
  if (offset < 0 || offset > INT32_MAX) {
62
0
    return hb_blob_get_empty ();
63
0
  }
64
65
0
  return hb_blob_create_sub_blob(cff_blob, (uint32_t) offset, bytes.length);
66
0
}
Unexecuted instantiation: hb-subset-table-cff.cc:hb_blob_t* get_charstrings_data<OT::cff1_accelerator_t const>(OT::cff1_accelerator_t const&, unsigned int)
Unexecuted instantiation: hb-subset-table-cff.cc:hb_blob_t* get_charstrings_data<OT::cff2_accelerator_t const>(OT::cff2_accelerator_t const&, unsigned int)
67
68
template<typename accel_t>
69
0
static hb_blob_t* get_charstrings_index(accel_t& accel) {
70
0
  if (!accel.is_valid()) {
71
0
    return hb_blob_get_empty ();
72
0
  }
73
74
0
  const char* charstrings_start = (const char*) accel.charStrings;
75
0
  unsigned charstrings_length = accel.charStrings->get_size();
76
77
0
  hb_blob_t* cff_blob = accel.get_blob();
78
0
  uint32_t length;
79
0
  const char* cff_data = hb_blob_get_data(cff_blob, &length) ;
80
81
0
  long int offset = charstrings_start - cff_data;
82
0
  if (offset < 0 || offset > INT32_MAX) {
83
0
    return hb_blob_get_empty ();
84
0
  }
85
86
0
  return hb_blob_create_sub_blob(cff_blob, (uint32_t) offset, charstrings_length);
87
0
}
Unexecuted instantiation: hb-subset-table-cff.cc:hb_blob_t* get_charstrings_index<OT::cff1_accelerator_t const>(OT::cff1_accelerator_t const&)
Unexecuted instantiation: hb-subset-table-cff.cc:hb_blob_t* get_charstrings_index<OT::cff2_accelerator_t const>(OT::cff2_accelerator_t const&)
88
89
/**
90
 * hb_subset_cff_get_charstring_data:
91
 * @face: A face object
92
 * @glyph_index: Glyph index to get data for.
93
 *
94
 * Returns the raw outline data from the CFF/CFF2 table associated with the given glyph index.
95
 *
96
 * XSince: EXPERIMENTAL
97
 **/
98
HB_EXTERN hb_blob_t*
99
0
hb_subset_cff_get_charstring_data(hb_face_t* face, hb_codepoint_t glyph_index) {
100
0
  return get_charstrings_data(*face->table.cff1, glyph_index);
101
0
}
102
103
/**
104
 * hb_subset_cff_get_charstrings_index:
105
 * @face: A face object
106
 *
107
 * Returns the raw CFF CharStrings INDEX from the CFF table.
108
 *
109
 * XSince: EXPERIMENTAL
110
 **/
111
HB_EXTERN hb_blob_t*
112
0
hb_subset_cff_get_charstrings_index (hb_face_t* face) {
113
0
  return get_charstrings_index (*face->table.cff1);
114
0
}
115
116
/**
117
 * hb_subset_cff2_get_charstring_data:
118
 * @face: A face object
119
 * @glyph_index: Glyph index to get data for.
120
 *
121
 * Returns the raw outline data from the CFF/CFF2 table associated with the given glyph index.
122
 *
123
 * XSince: EXPERIMENTAL
124
 **/
125
HB_EXTERN hb_blob_t*
126
0
hb_subset_cff2_get_charstring_data(hb_face_t* face, hb_codepoint_t glyph_index) {
127
0
  return get_charstrings_data(*face->table.cff2, glyph_index);
128
0
}
129
130
/**
131
 * hb_subset_cff2_get_charstrings_index:
132
 * @face: A face object
133
 *
134
 * Returns the raw CFF2 CharStrings INDEX from the CFF2 table.
135
 *
136
 * XSince: EXPERIMENTAL
137
 **/
138
HB_EXTERN hb_blob_t*
139
0
hb_subset_cff2_get_charstrings_index (hb_face_t* face) {
140
0
  return get_charstrings_index (*face->table.cff2);
141
0
}
142
#endif
143
#endif