Coverage Report

Created: 2025-08-03 06:54

/src/harfbuzz/src/hb-cff-interp-common.hh
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright © 2018 Adobe Inc.
3
 *
4
 *  This is part of HarfBuzz, a text shaping library.
5
 *
6
 * Permission is hereby granted, without written agreement and without
7
 * license or royalty fees, to use, copy, modify, and distribute this
8
 * software and its documentation for any purpose, provided that the
9
 * above copyright notice and the following two paragraphs appear in
10
 * all copies of this software.
11
 *
12
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16
 * DAMAGE.
17
 *
18
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23
 *
24
 * Adobe Author(s): Michiharu Ariza
25
 */
26
#ifndef HB_CFF_INTERP_COMMON_HH
27
#define HB_CFF_INTERP_COMMON_HH
28
29
extern HB_INTERNAL const unsigned char *endchar_str;
30
31
namespace CFF {
32
33
using namespace OT;
34
35
typedef unsigned int op_code_t;
36
37
38
/* === Dict operators === */
39
40
/* One byte operators (0-31) */
41
7.63k
#define OpCode_version      0 /* CFF Top */
42
11.7k
#define OpCode_Notice     1 /* CFF Top */
43
14.5k
#define OpCode_FullName     2 /* CFF Top */
44
17.5k
#define OpCode_FamilyName   3 /* CFF Top */
45
20.7k
#define OpCode_Weight     4 /* CFF Top */
46
8.61k
#define OpCode_FontBBox     5 /* CFF Top */
47
17.4k
#define OpCode_BlueValues   6 /* CFF Private, CFF2 Private */
48
22.9k
#define OpCode_OtherBlues   7 /* CFF Private, CFF2 Private */
49
27.7k
#define OpCode_FamilyBlues    8 /* CFF Private, CFF2 Private */
50
30.3k
#define OpCode_FamilyOtherBlues   9 /* CFF Private, CFF2 Private */
51
79.1k
#define OpCode_StdHW     10 /* CFF Private, CFF2 Private */
52
97.4k
#define OpCode_StdVW     11 /* CFF Private, CFF2 Private */
53
6.44M
#define OpCode_escape    12 /* All. Shared with CS */
54
4.05k
#define OpCode_UniqueID    13 /* CFF Top */
55
10.5k
#define OpCode_XUID    14 /* CFF Top */
56
5.13k
#define OpCode_charset     15 /* CFF Top (0) */
57
3.05k
#define OpCode_Encoding    16 /* CFF Top (0) */
58
7.84k
#define OpCode_CharStrings   17 /* CFF Top, CFF2 Top */
59
24.8k
#define OpCode_Private     18 /* CFF Top, CFF2 FD */
60
45.6k
#define OpCode_Subrs     19 /* CFF Private, CFF2 Private */
61
102k
#define OpCode_defaultWidthX   20 /* CFF Private (0) */
62
104k
#define OpCode_nominalWidthX   21 /* CFF Private (0) */
63
0
#define OpCode_vsindexdict   22 /* CFF2 Private/CS */
64
3.01k
#define OpCode_blenddict   23 /* CFF2 Private/CS */
65
1.13k
#define OpCode_vstore    24 /* CFF2 Top */
66
#define OpCode_reserved25  25
67
#define OpCode_reserved26  26
68
#define OpCode_reserved27  27
69
70
/* Numbers */
71
40.4k
#define OpCode_shortint    28 /* 16-bit integer, All */
72
19.0k
#define OpCode_longintdict   29 /* 32-bit integer, All */
73
4.14k
#define OpCode_BCD     30 /* Real number, CFF2 Top/FD */
74
#define OpCode_reserved31  31
75
76
/* 1-byte integers */
77
#define OpCode_OneByteIntFirst   32 /* All. beginning of the range of first byte ints */
78
#define OpCode_OneByteIntLast 246 /* All. ending of the range of first byte int */
79
80
/* 2-byte integers */
81
332k
#define OpCode_TwoBytePosInt0 247 /* All. first byte of two byte positive int (+108 to +1131) */
82
122k
#define OpCode_TwoBytePosInt1 248
83
217k
#define OpCode_TwoBytePosInt2 249
84
262k
#define OpCode_TwoBytePosInt3 250
85
86
175k
#define OpCode_TwoByteNegInt0 251 /* All. first byte of two byte negative int (-1131 to -108) */
87
66.3k
#define OpCode_TwoByteNegInt1 252
88
73.6k
#define OpCode_TwoByteNegInt2 253
89
99.2k
#define OpCode_TwoByteNegInt3 254
90
91
/* Two byte escape operators 12, (0-41) */
92
1.19M
#define OpCode_ESC_Base   256
93
1.06M
#define Make_OpCode_ESC(byte2)  ((op_code_t)(OpCode_ESC_Base + (byte2)))
94
95
3.29k
inline op_code_t Unmake_OpCode_ESC (op_code_t op)  { return (op_code_t)(op - OpCode_ESC_Base); }
96
130k
inline bool Is_OpCode_ESC (op_code_t op) { return op >= OpCode_ESC_Base; }
97
14.8k
inline unsigned int OpCode_Size (op_code_t op) { return Is_OpCode_ESC (op) ? 2: 1; }
98
99
8.60k
#define OpCode_Copyright  Make_OpCode_ESC(0) /* CFF Top */
100
599
#define OpCode_isFixedPitch Make_OpCode_ESC(1) /* CFF Top (false) */
101
964
#define OpCode_ItalicAngle  Make_OpCode_ESC(2) /* CFF Top (0) */
102
2.36k
#define OpCode_UnderlinePosition Make_OpCode_ESC(3) /* CFF Top (-100) */
103
2.60k
#define OpCode_UnderlineThickness Make_OpCode_ESC(4) /* CFF Top (50) */
104
3.52k
#define OpCode_PaintType  Make_OpCode_ESC(5) /* CFF Top (0) */
105
3.18k
#define OpCode_CharstringType Make_OpCode_ESC(6) /* CFF Top (2) */
106
1.41k
#define OpCode_FontMatrix Make_OpCode_ESC(7) /* CFF Top, CFF2 Top (.001 0 0 .001 0 0)*/
107
4.22k
#define OpCode_StrokeWidth  Make_OpCode_ESC(8) /* CFF Top (0) */
108
98.1k
#define OpCode_BlueScale  Make_OpCode_ESC(9) /* CFF Private, CFF2 Private (0.039625) */
109
98.5k
#define OpCode_BlueShift  Make_OpCode_ESC(10) /* CFF Private, CFF2 Private (7) */
110
99.4k
#define OpCode_BlueFuzz   Make_OpCode_ESC(11) /* CFF Private, CFF2 Private (1) */
111
51.9k
#define OpCode_StemSnapH  Make_OpCode_ESC(12) /* CFF Private, CFF2 Private */
112
66.3k
#define OpCode_StemSnapV  Make_OpCode_ESC(13) /* CFF Private, CFF2 Private */
113
89.5k
#define OpCode_ForceBold  Make_OpCode_ESC(14) /* CFF Private (false) */
114
#define OpCode_reservedESC15  Make_OpCode_ESC(15)
115
#define OpCode_reservedESC16  Make_OpCode_ESC(16)
116
103k
#define OpCode_LanguageGroup  Make_OpCode_ESC(17) /* CFF Private, CFF2 Private (0) */
117
103k
#define OpCode_ExpansionFactor  Make_OpCode_ESC(18) /* CFF Private, CFF2 Private (0.06) */
118
86.8k
#define OpCode_initialRandomSeed Make_OpCode_ESC(19) /* CFF Private (0) */
119
4.33k
#define OpCode_SyntheticBase  Make_OpCode_ESC(20) /* CFF Top */
120
17.8k
#define OpCode_PostScript Make_OpCode_ESC(21) /* CFF Top */
121
18.1k
#define OpCode_BaseFontName Make_OpCode_ESC(22) /* CFF Top */
122
10.8k
#define OpCode_BaseFontBlend  Make_OpCode_ESC(23) /* CFF Top */
123
#define OpCode_reservedESC24  Make_OpCode_ESC(24)
124
#define OpCode_reservedESC25  Make_OpCode_ESC(25)
125
#define OpCode_reservedESC26  Make_OpCode_ESC(26)
126
#define OpCode_reservedESC27  Make_OpCode_ESC(27)
127
#define OpCode_reservedESC28  Make_OpCode_ESC(28)
128
#define OpCode_reservedESC29  Make_OpCode_ESC(29)
129
1.38k
#define OpCode_ROS    Make_OpCode_ESC(30) /* CFF Top_CID */
130
5.22k
#define OpCode_CIDFontVersion Make_OpCode_ESC(31) /* CFF Top_CID (0) */
131
5.37k
#define OpCode_CIDFontRevision  Make_OpCode_ESC(32) /* CFF Top_CID (0) */
132
5.41k
#define OpCode_CIDFontType  Make_OpCode_ESC(33) /* CFF Top_CID (0) */
133
869
#define OpCode_CIDCount   Make_OpCode_ESC(34) /* CFF Top_CID (8720) */
134
5.46k
#define OpCode_UIDBase    Make_OpCode_ESC(35) /* CFF Top_CID */
135
3.76k
#define OpCode_FDArray    Make_OpCode_ESC(36) /* CFF Top_CID, CFF2 Top */
136
2.24k
#define OpCode_FDSelect   Make_OpCode_ESC(37) /* CFF Top_CID, CFF2 Top */
137
28.3k
#define OpCode_FontName   Make_OpCode_ESC(38) /* CFF Top_CID */
138
139
140
/* === CharString operators === */
141
142
63.1k
#define OpCode_hstem      1 /* CFF, CFF2 */
143
#define OpCode_Reserved2    2
144
58.9k
#define OpCode_vstem      3 /* CFF, CFF2 */
145
27.5k
#define OpCode_vmoveto      4 /* CFF, CFF2 */
146
15.9k
#define OpCode_rlineto      5 /* CFF, CFF2 */
147
55.4k
#define OpCode_hlineto      6 /* CFF, CFF2 */
148
24.1k
#define OpCode_vlineto      7 /* CFF, CFF2 */
149
20.9k
#define OpCode_rrcurveto    8 /* CFF, CFF2 */
150
#define OpCode_Reserved9    9
151
756k
#define OpCode_callsubr    10 /* CFF, CFF2 */
152
195k
#define OpCode_return    11 /* CFF */
153
//#define OpCode_escape    12 /* CFF, CFF2 */
154
#define OpCode_Reserved13  13
155
13.1k
#define OpCode_endchar     14 /* CFF */
156
11.7k
#define OpCode_vsindexcs   15 /* CFF2 */
157
5.95k
#define OpCode_blendcs     16 /* CFF2 */
158
#define OpCode_Reserved17  17
159
77.0k
#define OpCode_hstemhm     18 /* CFF, CFF2 */
160
63.2k
#define OpCode_hintmask    19 /* CFF, CFF2 */
161
95.2k
#define OpCode_cntrmask    20 /* CFF, CFF2 */
162
41.9k
#define OpCode_rmoveto     21 /* CFF, CFF2 */
163
6.66k
#define OpCode_hmoveto     22 /* CFF, CFF2 */
164
73.0k
#define OpCode_vstemhm     23 /* CFF, CFF2 */
165
4.16k
#define OpCode_rcurveline  24 /* CFF, CFF2 */
166
3.20k
#define OpCode_rlinecurve  25 /* CFF, CFF2 */
167
7.72k
#define OpCode_vvcurveto   26 /* CFF, CFF2 */
168
7.18k
#define OpCode_hhcurveto   27 /* CFF, CFF2 */
169
//#define OpCode_shortint  28 /* CFF, CFF2 */
170
477k
#define OpCode_callgsubr   29 /* CFF, CFF2 */
171
4.97k
#define OpCode_vhcurveto   30 /* CFF, CFF2 */
172
46.6k
#define OpCode_hvcurveto   31 /* CFF, CFF2 */
173
174
90.0k
#define OpCode_fixedcs    255 /* 32-bit fixed */
175
176
/* Two byte escape operators 12, (0-41) */
177
14.7k
#define OpCode_dotsection Make_OpCode_ESC(0) /* CFF (obsoleted) */
178
#define OpCode_ReservedESC1 Make_OpCode_ESC(1)
179
#define OpCode_ReservedESC2 Make_OpCode_ESC(2)
180
#define OpCode_and    Make_OpCode_ESC(3) /* CFF */
181
#define OpCode_or   Make_OpCode_ESC(4) /* CFF */
182
#define OpCode_not    Make_OpCode_ESC(5) /* CFF */
183
#define OpCode_ReservedESC6 Make_OpCode_ESC(6)
184
#define OpCode_ReservedESC7 Make_OpCode_ESC(7)
185
#define OpCode_ReservedESC8 Make_OpCode_ESC(8)
186
#define OpCode_abs    Make_OpCode_ESC(9) /* CFF */
187
#define OpCode_add    Make_OpCode_ESC(10) /* CFF */
188
#define OpCode_sub    Make_OpCode_ESC(11) /* CFF */
189
#define OpCode_div    Make_OpCode_ESC(12) /* CFF */
190
#define OpCode_ReservedESC13  Make_OpCode_ESC(13)
191
#define OpCode_neg    Make_OpCode_ESC(14) /* CFF */
192
#define OpCode_eq   Make_OpCode_ESC(15) /* CFF */
193
#define OpCode_ReservedESC16  Make_OpCode_ESC(16)
194
#define OpCode_ReservedESC17  Make_OpCode_ESC(17)
195
#define OpCode_drop   Make_OpCode_ESC(18) /* CFF */
196
#define OpCode_ReservedESC19  Make_OpCode_ESC(19)
197
#define OpCode_put    Make_OpCode_ESC(20) /* CFF */
198
#define OpCode_get    Make_OpCode_ESC(21) /* CFF */
199
#define OpCode_ifelse   Make_OpCode_ESC(22) /* CFF */
200
#define OpCode_random   Make_OpCode_ESC(23) /* CFF */
201
#define OpCode_mul    Make_OpCode_ESC(24) /* CFF */
202
//#define OpCode_reservedESC25  Make_OpCode_ESC(25)
203
#define OpCode_sqrt   Make_OpCode_ESC(26) /* CFF */
204
#define OpCode_dup    Make_OpCode_ESC(27) /* CFF */
205
#define OpCode_exch   Make_OpCode_ESC(28) /* CFF */
206
#define OpCode_index    Make_OpCode_ESC(29) /* CFF */
207
#define OpCode_roll   Make_OpCode_ESC(30) /* CFF */
208
#define OpCode_reservedESC31  Make_OpCode_ESC(31)
209
#define OpCode_reservedESC32  Make_OpCode_ESC(32)
210
#define OpCode_reservedESC33  Make_OpCode_ESC(33)
211
392
#define OpCode_hflex    Make_OpCode_ESC(34) /* CFF, CFF2 */
212
3.43k
#define OpCode_flex   Make_OpCode_ESC(35) /* CFF, CFF2 */
213
840
#define OpCode_hflex1   Make_OpCode_ESC(36) /* CFF, CFF2 */
214
616
#define OpCode_flex1    Make_OpCode_ESC(37) /* CFF, CFF2 */
215
216
217
624M
#define OpCode_Invalid    0xFFFFu
218
219
220
struct number_t
221
{
222
5.11M
  void set_int (int v)       { value = v; }
223
2.14M
  int to_int () const        { return value; }
224
225
76.1k
  void set_fixed (int32_t v) { value = v / 65536.0; }
226
12.7k
  int32_t to_fixed () const  { return value * 65536.0; }
227
228
4.14k
  void set_real (double v)   { value = v; }
229
0
  double to_real () const    { return value; }
230
231
  bool in_int_range () const
232
975k
  { return ((double) (int16_t) to_int () == value); }
233
234
0
  bool operator >  (const number_t &n) const { return value > n.to_real (); }
235
0
  bool operator <  (const number_t &n) const { return n > *this; }
236
0
  bool operator >= (const number_t &n) const { return !(*this < n); }
237
0
  bool operator <= (const number_t &n) const { return !(*this > n); }
238
239
  const number_t &operator += (const number_t &n)
240
0
  {
241
0
    set_real (to_real () + n.to_real ());
242
243
0
    return *this;
244
0
  }
245
246
  protected:
247
  double value = 0.;
248
};
249
250
/* byte string */
251
struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
252
{
253
  hb_ubytes_t as_ubytes (unsigned l) const
254
25.1k
  { return hb_ubytes_t ((const unsigned char *) this, l); }
255
256
  // encode 2-byte int (Dict/CharString) or 4-byte int (Dict)
257
  template <typename T, typename V>
258
  static bool serialize_int (hb_serialize_context_t *c, op_code_t intOp, V value)
259
10.9k
  {
260
10.9k
    TRACE_SERIALIZE (this);
261
262
10.9k
    HBUINT8 *p = c->allocate_size<HBUINT8> (1);
263
10.9k
    if (unlikely (!p)) return_trace (false);
264
10.9k
    *p = intOp;
265
266
10.9k
    T *ip = c->allocate_size<T> (T::static_size);
267
10.9k
    if (unlikely (!ip)) return_trace (false);
268
10.9k
    return_trace (c->check_assign (*ip, value, HB_SERIALIZE_ERROR_INT_OVERFLOW));
269
10.9k
  }
bool CFF::UnsizedByteStr::serialize_int<OT::NumType<true, int, 4u>, int>(hb_serialize_context_t*, unsigned int, int)
Line
Count
Source
259
5.48k
  {
260
5.48k
    TRACE_SERIALIZE (this);
261
262
5.48k
    HBUINT8 *p = c->allocate_size<HBUINT8> (1);
263
5.48k
    if (unlikely (!p)) return_trace (false);
264
5.48k
    *p = intOp;
265
266
5.48k
    T *ip = c->allocate_size<T> (T::static_size);
267
5.48k
    if (unlikely (!ip)) return_trace (false);
268
5.48k
    return_trace (c->check_assign (*ip, value, HB_SERIALIZE_ERROR_INT_OVERFLOW));
269
5.48k
  }
bool CFF::UnsizedByteStr::serialize_int<OT::NumType<true, short, 2u>, int>(hb_serialize_context_t*, unsigned int, int)
Line
Count
Source
259
358
  {
260
358
    TRACE_SERIALIZE (this);
261
262
358
    HBUINT8 *p = c->allocate_size<HBUINT8> (1);
263
358
    if (unlikely (!p)) return_trace (false);
264
358
    *p = intOp;
265
266
358
    T *ip = c->allocate_size<T> (T::static_size);
267
358
    if (unlikely (!ip)) return_trace (false);
268
358
    return_trace (c->check_assign (*ip, value, HB_SERIALIZE_ERROR_INT_OVERFLOW));
269
358
  }
bool CFF::UnsizedByteStr::serialize_int<OT::NumType<true, short, 2u>, unsigned int>(hb_serialize_context_t*, unsigned int, unsigned int)
Line
Count
Source
259
5.13k
  {
260
5.13k
    TRACE_SERIALIZE (this);
261
262
5.13k
    HBUINT8 *p = c->allocate_size<HBUINT8> (1);
263
5.13k
    if (unlikely (!p)) return_trace (false);
264
5.13k
    *p = intOp;
265
266
5.13k
    T *ip = c->allocate_size<T> (T::static_size);
267
5.13k
    if (unlikely (!ip)) return_trace (false);
268
5.13k
    return_trace (c->check_assign (*ip, value, HB_SERIALIZE_ERROR_INT_OVERFLOW));
269
5.13k
  }
270
271
  template <typename V>
272
  static bool serialize_int4 (hb_serialize_context_t *c, V value)
273
  { return serialize_int<HBINT32> (c, OpCode_longintdict, value); }
274
275
  template <typename V>
276
  static bool serialize_int2 (hb_serialize_context_t *c, V value)
277
2.01k
  { return serialize_int<HBINT16> (c, OpCode_shortint, value); }
278
279
  /* Defining null_size allows a Null object may be created. Should be safe because:
280
   * A descendent struct Dict uses a Null pointer to indicate a missing table,
281
   * checked before access.
282
   */
283
  DEFINE_SIZE_MIN(0);
284
};
285
286
/* A byte string associated with the current offset and an error condition */
287
struct byte_str_ref_t
288
{
289
  byte_str_ref_t ()
290
172k
    : str () {}
291
292
  byte_str_ref_t (const hb_ubytes_t &str_, unsigned int offset_ = 0)
293
109k
    : str (str_) { set_offset (offset_); }
294
295
  void reset (const hb_ubytes_t &str_, unsigned int offset_ = 0)
296
60.9k
  {
297
60.9k
    str = str_;
298
60.9k
    set_offset (offset_);
299
60.9k
  }
300
301
616k
  const unsigned char& operator [] (int i) {
302
616k
    if (unlikely ((unsigned int) (get_offset () + i) >= str.length))
303
219
    {
304
219
      set_error ();
305
219
      return Null (unsigned char);
306
219
    }
307
616k
    return str.arrayZ[get_offset () + i];
308
616k
  }
309
310
6.55M
  unsigned char head_unchecked () const { return str.arrayZ[get_offset ()]; }
311
312
  /* Conversion to hb_ubytes_t */
313
0
  operator hb_ubytes_t () const { return str.sub_array (get_offset ()); }
314
315
  hb_ubytes_t sub_array (unsigned int offset_, unsigned int len_) const
316
78.6M
  { return str.sub_array (offset_, len_); }
317
318
  bool avail (unsigned int count=1) const
319
320M
  { return get_offset () + count <= str.length; }
320
  void inc (unsigned int count=1)
321
7.11M
  {
322
    /* Automatically puts us in error if count is out-of-range. */
323
7.11M
    set_offset (get_offset () + count);
324
7.11M
  }
325
326
  /* We (ab)use ubytes backwards_length as a cursor (called offset),
327
   * as well as to store error condition. */
328
329
493M
  unsigned get_offset () const { return str.backwards_length; }
330
7.28M
  void set_offset (unsigned offset) { str.backwards_length = offset; }
331
332
4.31k
  void set_error ()      { str.backwards_length = str.length + 1; }
333
315M
  bool in_error () const { return str.backwards_length > str.length; }
334
335
12.0k
  unsigned total_size () const { return str.length; }
336
337
  protected:
338
  hb_ubytes_t       str;
339
};
340
341
/* stack */
342
template <typename ELEM, int LIMIT>
343
struct cff_stack_t
344
{
345
  ELEM& operator [] (unsigned int i)
346
989k
  {
347
989k
    if (unlikely (i >= count))
348
0
    {
349
0
      set_error ();
350
0
      return Crap (ELEM);
351
0
    }
352
989k
    return elements[i];
353
989k
  }
CFF::cff_stack_t<CFF::number_t, 513>::operator[](unsigned int)
Line
Count
Source
346
52.3k
  {
347
52.3k
    if (unlikely (i >= count))
348
0
    {
349
0
      set_error ();
350
0
      return Crap (ELEM);
351
0
    }
352
52.3k
    return elements[i];
353
52.3k
  }
CFF::cff_stack_t<CFF::call_context_t, 10>::operator[](unsigned int)
Line
Count
Source
346
405
  {
347
405
    if (unlikely (i >= count))
348
0
    {
349
0
      set_error ();
350
0
      return Crap (ELEM);
351
0
    }
352
405
    return elements[i];
353
405
  }
CFF::cff_stack_t<CFF::blend_arg_t, 513>::operator[](unsigned int)
Line
Count
Source
346
937k
  {
347
937k
    if (unlikely (i >= count))
348
0
    {
349
0
      set_error ();
350
0
      return Crap (ELEM);
351
0
    }
352
937k
    return elements[i];
353
937k
  }
354
355
  void push (const ELEM &v)
356
99.4k
  {
357
99.4k
    if (likely (count < LIMIT))
358
99.4k
      elements[count++] = v;
359
0
    else
360
0
      set_error ();
361
99.4k
  }
362
  ELEM &push ()
363
5.17M
  {
364
5.17M
    if (likely (count < LIMIT))
365
5.17M
      return elements[count++];
366
26
    else
367
26
    {
368
26
      set_error ();
369
26
      return Crap (ELEM);
370
26
    }
371
5.17M
  }
CFF::cff_stack_t<CFF::number_t, 513>::push()
Line
Count
Source
363
1.49M
  {
364
1.49M
    if (likely (count < LIMIT))
365
1.49M
      return elements[count++];
366
24
    else
367
24
    {
368
24
      set_error ();
369
24
      return Crap (ELEM);
370
24
    }
371
1.49M
  }
CFF::cff_stack_t<CFF::blend_arg_t, 513>::push()
Line
Count
Source
363
3.67M
  {
364
3.67M
    if (likely (count < LIMIT))
365
3.67M
      return elements[count++];
366
2
    else
367
2
    {
368
2
      set_error ();
369
2
      return Crap (ELEM);
370
2
    }
371
3.67M
  }
372
373
  ELEM& pop ()
374
303k
  {
375
303k
    if (likely (count > 0))
376
303k
      return elements[--count];
377
867
    else
378
867
    {
379
867
      set_error ();
380
867
      return Crap (ELEM);
381
867
    }
382
303k
  }
CFF::cff_stack_t<CFF::number_t, 513>::pop()
Line
Count
Source
374
114k
  {
375
114k
    if (likely (count > 0))
376
113k
      return elements[--count];
377
668
    else
378
668
    {
379
668
      set_error ();
380
668
      return Crap (ELEM);
381
668
    }
382
114k
  }
CFF::cff_stack_t<CFF::call_context_t, 10>::pop()
Line
Count
Source
374
97.0k
  {
375
97.0k
    if (likely (count > 0))
376
96.8k
      return elements[--count];
377
141
    else
378
141
    {
379
141
      set_error ();
380
141
      return Crap (ELEM);
381
141
    }
382
97.0k
  }
CFF::cff_stack_t<CFF::blend_arg_t, 513>::pop()
Line
Count
Source
374
92.8k
  {
375
92.8k
    if (likely (count > 0))
376
92.7k
      return elements[--count];
377
58
    else
378
58
    {
379
58
      set_error ();
380
58
      return Crap (ELEM);
381
58
    }
382
92.8k
  }
383
  void pop (unsigned int n)
384
310M
  {
385
310M
    if (likely (count >= n))
386
310M
      count -= n;
387
0
    else
388
0
      set_error ();
389
310M
  }
CFF::cff_stack_t<CFF::number_t, 513>::pop(unsigned int)
Line
Count
Source
384
309M
  {
385
309M
    if (likely (count >= n))
386
309M
      count -= n;
387
0
    else
388
0
      set_error ();
389
309M
  }
CFF::cff_stack_t<CFF::blend_arg_t, 513>::pop(unsigned int)
Line
Count
Source
384
314k
  {
385
314k
    if (likely (count >= n))
386
314k
      count -= n;
387
0
    else
388
0
      set_error ();
389
314k
  }
390
391
  const ELEM& peek ()
392
  {
393
    if (unlikely (count == 0))
394
    {
395
      set_error ();
396
      return Null (ELEM);
397
    }
398
    return elements[count - 1];
399
  }
400
401
  void unpop ()
402
  {
403
    if (likely (count < LIMIT))
404
      count++;
405
    else
406
      set_error ();
407
  }
408
409
  void clear () { count = 0; }
410
411
629M
  bool in_error () const { return (error); }
CFF::cff_stack_t<CFF::number_t, 513>::in_error() const
Line
Count
Source
411
311M
  bool in_error () const { return (error); }
CFF::cff_stack_t<CFF::call_context_t, 10>::in_error() const
Line
Count
Source
411
314M
  bool in_error () const { return (error); }
CFF::cff_stack_t<CFF::blend_arg_t, 513>::in_error() const
Line
Count
Source
411
4.16M
  bool in_error () const { return (error); }
412
1.23k
  void set_error ()      { error = true; }
CFF::cff_stack_t<CFF::number_t, 513>::set_error()
Line
Count
Source
412
953
  void set_error ()      { error = true; }
CFF::cff_stack_t<CFF::call_context_t, 10>::set_error()
Line
Count
Source
412
141
  void set_error ()      { error = true; }
CFF::cff_stack_t<CFF::blend_arg_t, 513>::set_error()
Line
Count
Source
412
141
  void set_error ()      { error = true; }
413
414
311M
  unsigned int get_count () const { return count; }
CFF::cff_stack_t<CFF::number_t, 513>::get_count() const
Line
Count
Source
414
309M
  unsigned int get_count () const { return count; }
CFF::cff_stack_t<CFF::call_context_t, 10>::get_count() const
Line
Count
Source
414
102k
  unsigned int get_count () const { return count; }
CFF::cff_stack_t<CFF::blend_arg_t, 513>::get_count() const
Line
Count
Source
414
1.37M
  unsigned int get_count () const { return count; }
415
993k
  bool is_empty () const          { return !count; }
CFF::cff_stack_t<CFF::number_t, 513>::is_empty() const
Line
Count
Source
415
906k
  bool is_empty () const          { return !count; }
CFF::cff_stack_t<CFF::call_context_t, 10>::is_empty() const
Line
Count
Source
415
87.7k
  bool is_empty () const          { return !count; }
416
417
  hb_array_t<const ELEM> sub_array (unsigned start, unsigned length) const
418
14.0k
  { return hb_array_t<const ELEM> (elements).sub_array (start, length); }
Unexecuted instantiation: CFF::cff_stack_t<CFF::number_t, 513>::sub_array(unsigned int, unsigned int) const
CFF::cff_stack_t<CFF::blend_arg_t, 513>::sub_array(unsigned int, unsigned int) const
Line
Count
Source
418
14.0k
  { return hb_array_t<const ELEM> (elements).sub_array (start, length); }
419
420
  private:
421
  bool error = false;
422
  unsigned int count = 0;
423
  ELEM elements[LIMIT];
424
};
425
426
/* argument stack */
427
template <typename ARG=number_t>
428
struct arg_stack_t : cff_stack_t<ARG, 513>
429
{
430
  void push_int (int v)
431
5.09M
  {
432
5.09M
    ARG &n = S::push ();
433
5.09M
    n.set_int (v);
434
5.09M
  }
CFF::arg_stack_t<CFF::number_t>::push_int(int)
Line
Count
Source
431
1.45M
  {
432
1.45M
    ARG &n = S::push ();
433
1.45M
    n.set_int (v);
434
1.45M
  }
CFF::arg_stack_t<CFF::blend_arg_t>::push_int(int)
Line
Count
Source
431
3.63M
  {
432
3.63M
    ARG &n = S::push ();
433
3.63M
    n.set_int (v);
434
3.63M
  }
435
436
  void push_fixed (int32_t v)
437
76.1k
  {
438
76.1k
    ARG &n = S::push ();
439
76.1k
    n.set_fixed (v);
440
76.1k
  }
CFF::arg_stack_t<CFF::number_t>::push_fixed(int)
Line
Count
Source
437
31.5k
  {
438
31.5k
    ARG &n = S::push ();
439
31.5k
    n.set_fixed (v);
440
31.5k
  }
CFF::arg_stack_t<CFF::blend_arg_t>::push_fixed(int)
Line
Count
Source
437
44.6k
  {
438
44.6k
    ARG &n = S::push ();
439
44.6k
    n.set_fixed (v);
440
44.6k
  }
441
442
  void push_real (double v)
443
4.14k
  {
444
4.14k
    ARG &n = S::push ();
445
4.14k
    n.set_real (v);
446
4.14k
  }
447
448
  ARG& pop_num () { return this->pop (); }
449
450
206k
  int pop_int ()  { return this->pop ().to_int (); }
CFF::arg_stack_t<CFF::number_t>::pop_int()
Line
Count
Source
450
114k
  int pop_int ()  { return this->pop ().to_int (); }
CFF::arg_stack_t<CFF::blend_arg_t>::pop_int()
Line
Count
Source
450
92.8k
  int pop_int ()  { return this->pop ().to_int (); }
451
452
  unsigned int pop_uint ()
453
76.7k
  {
454
76.7k
    int i = pop_int ();
455
76.7k
    if (unlikely (i < 0))
456
342
    {
457
342
      i = 0;
458
342
      S::set_error ();
459
342
    }
460
76.7k
    return (unsigned) i;
461
76.7k
  }
CFF::arg_stack_t<CFF::number_t>::pop_uint()
Line
Count
Source
453
71.3k
  {
454
71.3k
    int i = pop_int ();
455
71.3k
    if (unlikely (i < 0))
456
261
    {
457
261
      i = 0;
458
261
      S::set_error ();
459
261
    }
460
71.3k
    return (unsigned) i;
461
71.3k
  }
CFF::arg_stack_t<CFF::blend_arg_t>::pop_uint()
Line
Count
Source
453
5.40k
  {
454
5.40k
    int i = pop_int ();
455
5.40k
    if (unlikely (i < 0))
456
81
    {
457
81
      i = 0;
458
81
      S::set_error ();
459
81
    }
460
5.40k
    return (unsigned) i;
461
5.40k
  }
462
463
  void push_longint_from_substr (byte_str_ref_t& str_ref)
464
19.0k
  {
465
19.0k
    push_int ((str_ref[0] << 24) | (str_ref[1] << 16) | (str_ref[2] << 8) | (str_ref[3]));
466
19.0k
    str_ref.inc (4);
467
19.0k
  }
468
469
  bool push_fixed_from_substr (byte_str_ref_t& str_ref)
470
77.3k
  {
471
77.3k
    if (unlikely (!str_ref.avail (4)))
472
1.13k
      return false;
473
76.1k
    push_fixed ((int32_t)*(const HBUINT32*)&str_ref[0]);
474
76.1k
    str_ref.inc (4);
475
76.1k
    return true;
476
77.3k
  }
CFF::arg_stack_t<CFF::number_t>::push_fixed_from_substr(CFF::byte_str_ref_t&)
Line
Count
Source
470
32.4k
  {
471
32.4k
    if (unlikely (!str_ref.avail (4)))
472
876
      return false;
473
31.5k
    push_fixed ((int32_t)*(const HBUINT32*)&str_ref[0]);
474
31.5k
    str_ref.inc (4);
475
31.5k
    return true;
476
32.4k
  }
CFF::arg_stack_t<CFF::blend_arg_t>::push_fixed_from_substr(CFF::byte_str_ref_t&)
Line
Count
Source
470
44.8k
  {
471
44.8k
    if (unlikely (!str_ref.avail (4)))
472
261
      return false;
473
44.6k
    push_fixed ((int32_t)*(const HBUINT32*)&str_ref[0]);
474
44.6k
    str_ref.inc (4);
475
44.6k
    return true;
476
44.8k
  }
477
478
  private:
479
  typedef cff_stack_t<ARG, 513> S;
480
};
481
482
/* an operator prefixed by its operands in a byte string */
483
struct op_str_t
484
{
485
  /* This used to have a hb_ubytes_t. Using a pointer and length
486
   * in a particular order, saves 8 bytes in this struct and more
487
   * in our parsed_cs_op_t subclass. */
488
489
  const unsigned char *ptr = nullptr;
490
491
  op_code_t  op = OpCode_Invalid;
492
493
  uint8_t length = 0;
494
};
495
496
/* base of OP_SERIALIZER */
497
struct op_serializer_t
498
{
499
  protected:
500
  bool copy_opstr (hb_serialize_context_t *c, const op_str_t& opstr) const
501
41.5k
  {
502
41.5k
    TRACE_SERIALIZE (this);
503
504
41.5k
    unsigned char *d = c->allocate_size<unsigned char> (opstr.length);
505
41.5k
    if (unlikely (!d)) return_trace (false);
506
    /* Faster than hb_memcpy for small strings. */
507
148k
    for (unsigned i = 0; i < opstr.length; i++)
508
107k
      d[i] = opstr.ptr[i];
509
41.5k
    return_trace (true);
510
41.5k
  }
511
};
512
513
template <typename VAL>
514
struct parsed_values_t
515
{
516
  void init ()
517
693k
  {
518
693k
    opStart = 0;
519
693k
    values.init ();
520
693k
  }
CFF::parsed_values_t<CFF::parsed_cs_op_t>::init()
Line
Count
Source
517
519k
  {
518
519k
    opStart = 0;
519
519k
    values.init ();
520
519k
  }
CFF::parsed_values_t<CFF::cff1_top_dict_val_t>::init()
Line
Count
Source
517
53.7k
  {
518
53.7k
    opStart = 0;
519
53.7k
    values.init ();
520
53.7k
  }
CFF::parsed_values_t<CFF::op_str_t>::init()
Line
Count
Source
517
120k
  {
518
120k
    opStart = 0;
519
120k
    values.init ();
520
120k
  }
Unexecuted instantiation: CFF::parsed_values_t<CFF::dict_val_t>::init()
521
94.0k
  void fini () { values.fini (); }
CFF::parsed_values_t<CFF::cff1_top_dict_val_t>::fini()
Line
Count
Source
521
89.3k
  void fini () { values.fini (); }
CFF::parsed_values_t<CFF::op_str_t>::fini()
Line
Count
Source
521
4.76k
  void fini () { values.fini (); }
522
523
  void alloc (unsigned n)
524
16.3k
  {
525
16.3k
    values.alloc_exact (n);
526
16.3k
  }
527
528
  void add_op (op_code_t op, const byte_str_ref_t& str_ref = byte_str_ref_t (), const VAL &v = VAL ())
529
78.6M
  {
530
78.6M
    VAL *val = values.push (v);
531
78.6M
    val->op = op;
532
78.6M
    auto arr = str_ref.sub_array (opStart, str_ref.get_offset () - opStart);
533
78.6M
    val->ptr = arr.arrayZ;
534
78.6M
    val->length = arr.length;
535
78.6M
    opStart = str_ref.get_offset ();
536
78.6M
  }
CFF::parsed_values_t<CFF::parsed_cs_op_t>::add_op(unsigned int, CFF::byte_str_ref_t const&, CFF::parsed_cs_op_t const&)
Line
Count
Source
529
78.1M
  {
530
78.1M
    VAL *val = values.push (v);
531
78.1M
    val->op = op;
532
78.1M
    auto arr = str_ref.sub_array (opStart, str_ref.get_offset () - opStart);
533
78.1M
    val->ptr = arr.arrayZ;
534
78.1M
    val->length = arr.length;
535
78.1M
    opStart = str_ref.get_offset ();
536
78.1M
  }
CFF::parsed_values_t<CFF::cff1_top_dict_val_t>::add_op(unsigned int, CFF::byte_str_ref_t const&, CFF::cff1_top_dict_val_t const&)
Line
Count
Source
529
70.4k
  {
530
70.4k
    VAL *val = values.push (v);
531
70.4k
    val->op = op;
532
70.4k
    auto arr = str_ref.sub_array (opStart, str_ref.get_offset () - opStart);
533
70.4k
    val->ptr = arr.arrayZ;
534
70.4k
    val->length = arr.length;
535
70.4k
    opStart = str_ref.get_offset ();
536
70.4k
  }
CFF::parsed_values_t<CFF::op_str_t>::add_op(unsigned int, CFF::byte_str_ref_t const&, CFF::op_str_t const&)
Line
Count
Source
529
387k
  {
530
387k
    VAL *val = values.push (v);
531
387k
    val->op = op;
532
387k
    auto arr = str_ref.sub_array (opStart, str_ref.get_offset () - opStart);
533
387k
    val->ptr = arr.arrayZ;
534
387k
    val->length = arr.length;
535
387k
    opStart = str_ref.get_offset ();
536
387k
  }
Unexecuted instantiation: CFF::parsed_values_t<CFF::dict_val_t>::add_op(unsigned int, CFF::byte_str_ref_t const&, CFF::dict_val_t const&)
537
538
  bool has_op (op_code_t op) const
539
1.33k
  {
540
1.33k
    for (const auto& v : values)
541
10.4k
      if (v.op == op) return true;
542
179
    return false;
543
1.33k
  }
544
545
79.8k
  unsigned get_count () const { return values.length; }
CFF::parsed_values_t<CFF::op_str_t>::get_count() const
Line
Count
Source
545
52.2k
  unsigned get_count () const { return values.length; }
CFF::parsed_values_t<CFF::cff1_top_dict_val_t>::get_count() const
Line
Count
Source
545
27.5k
  unsigned get_count () const { return values.length; }
546
57.4k
  const VAL &operator [] (unsigned int i) const { return values[i]; }
CFF::parsed_values_t<CFF::op_str_t>::operator[](unsigned int) const
Line
Count
Source
546
49.0k
  const VAL &operator [] (unsigned int i) const { return values[i]; }
CFF::parsed_values_t<CFF::cff1_top_dict_val_t>::operator[](unsigned int) const
Line
Count
Source
546
8.40k
  const VAL &operator [] (unsigned int i) const { return values[i]; }
547
548
  unsigned int       opStart;
549
  hb_vector_t<VAL>   values;
550
};
551
552
template <typename ARG=number_t>
553
struct interp_env_t
554
{
555
  interp_env_t () {}
556
  interp_env_t (const hb_ubytes_t &str_)
557
60.9k
  {
558
60.9k
    str_ref.reset (str_);
559
60.9k
  }
CFF::interp_env_t<CFF::number_t>::interp_env_t(hb_array_t<unsigned char const> const&)
Line
Count
Source
557
59.3k
  {
558
59.3k
    str_ref.reset (str_);
559
59.3k
  }
CFF::interp_env_t<CFF::blend_arg_t>::interp_env_t(hb_array_t<unsigned char const> const&)
Line
Count
Source
557
1.51k
  {
558
1.51k
    str_ref.reset (str_);
559
1.51k
  }
560
  bool in_error () const
561
315M
  { return str_ref.in_error () || argStack.in_error (); }
CFF::interp_env_t<CFF::number_t>::in_error() const
Line
Count
Source
561
311M
  { return str_ref.in_error () || argStack.in_error (); }
CFF::interp_env_t<CFF::blend_arg_t>::in_error() const
Line
Count
Source
561
4.16M
  { return str_ref.in_error () || argStack.in_error (); }
562
563
3.97k
  void set_error () { str_ref.set_error (); }
CFF::interp_env_t<CFF::number_t>::set_error()
Line
Count
Source
563
3.35k
  void set_error () { str_ref.set_error (); }
CFF::interp_env_t<CFF::blend_arg_t>::set_error()
Line
Count
Source
563
616
  void set_error () { str_ref.set_error (); }
564
565
  op_code_t fetch_op ()
566
315M
  {
567
315M
    op_code_t  op = OpCode_Invalid;
568
315M
    if (unlikely (!str_ref.avail ()))
569
308M
      return OpCode_Invalid;
570
6.44M
    op = (op_code_t) str_ref.head_unchecked ();
571
6.44M
    str_ref.inc ();
572
6.44M
    if (op == OpCode_escape) {
573
110k
      if (unlikely (!str_ref.avail ()))
574
851
  return OpCode_Invalid;
575
109k
      op = Make_OpCode_ESC (str_ref.head_unchecked ());
576
109k
      str_ref.inc ();
577
109k
    }
578
6.44M
    return op;
579
6.44M
  }
CFF::interp_env_t<CFF::number_t>::fetch_op()
Line
Count
Source
566
311M
  {
567
311M
    op_code_t  op = OpCode_Invalid;
568
311M
    if (unlikely (!str_ref.avail ()))
569
308M
      return OpCode_Invalid;
570
2.36M
    op = (op_code_t) str_ref.head_unchecked ();
571
2.36M
    str_ref.inc ();
572
2.36M
    if (op == OpCode_escape) {
573
85.8k
      if (unlikely (!str_ref.avail ()))
574
837
  return OpCode_Invalid;
575
85.0k
      op = Make_OpCode_ESC (str_ref.head_unchecked ());
576
85.0k
      str_ref.inc ();
577
85.0k
    }
578
2.36M
    return op;
579
2.36M
  }
CFF::interp_env_t<CFF::blend_arg_t>::fetch_op()
Line
Count
Source
566
4.08M
  {
567
4.08M
    op_code_t  op = OpCode_Invalid;
568
4.08M
    if (unlikely (!str_ref.avail ()))
569
0
      return OpCode_Invalid;
570
4.08M
    op = (op_code_t) str_ref.head_unchecked ();
571
4.08M
    str_ref.inc ();
572
4.08M
    if (op == OpCode_escape) {
573
24.4k
      if (unlikely (!str_ref.avail ()))
574
14
  return OpCode_Invalid;
575
24.3k
      op = Make_OpCode_ESC (str_ref.head_unchecked ());
576
24.3k
      str_ref.inc ();
577
24.3k
    }
578
4.08M
    return op;
579
4.08M
  }
580
581
48.8k
  const ARG& eval_arg (unsigned int i) { return argStack[i]; }
582
583
0
  ARG& pop_arg () { return argStack.pop (); }
584
310M
  void pop_n_args (unsigned int n) { argStack.pop (n); }
CFF::interp_env_t<CFF::number_t>::pop_n_args(unsigned int)
Line
Count
Source
584
309M
  void pop_n_args (unsigned int n) { argStack.pop (n); }
CFF::interp_env_t<CFF::blend_arg_t>::pop_n_args(unsigned int)
Line
Count
Source
584
309k
  void pop_n_args (unsigned int n) { argStack.pop (n); }
585
586
309M
  void clear_args () { pop_n_args (argStack.get_count ()); }
CFF::interp_env_t<CFF::number_t>::clear_args()
Line
Count
Source
586
309M
  void clear_args () { pop_n_args (argStack.get_count ()); }
CFF::interp_env_t<CFF::blend_arg_t>::clear_args()
Line
Count
Source
586
95.6k
  void clear_args () { pop_n_args (argStack.get_count ()); }
587
588
  byte_str_ref_t
589
    str_ref;
590
  arg_stack_t<ARG>
591
    argStack;
592
};
593
594
using num_interp_env_t =  interp_env_t<>;
595
596
template <typename ARG=number_t>
597
struct opset_t
598
{
599
  static void process_op (op_code_t op, interp_env_t<ARG>& env)
600
314M
  {
601
314M
    switch (op) {
602
33.8k
      case OpCode_shortint:
603
33.8k
  env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1]));
604
33.8k
  env.str_ref.inc (2);
605
33.8k
  break;
606
607
122k
      case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
608
262k
      case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
609
262k
  env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108));
610
262k
  env.str_ref.inc ();
611
262k
  break;
612
613
66.3k
      case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
614
99.2k
      case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
615
99.2k
  env.argStack.push_int ((-(int16_t)(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108));
616
99.2k
  env.str_ref.inc ();
617
99.2k
  break;
618
619
313M
      default:
620
  /* 1-byte integer */
621
313M
  if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast)))
622
4.67M
  {
623
4.67M
    env.argStack.push_int ((int)op - 139);
624
309M
  } else {
625
    /* invalid unknown operator */
626
309M
    env.clear_args ();
627
309M
  }
628
313M
  break;
629
314M
    }
630
314M
  }
CFF::opset_t<CFF::number_t>::process_op(unsigned int, CFF::interp_env_t<CFF::number_t>&)
Line
Count
Source
600
310M
  {
601
310M
    switch (op) {
602
33.4k
      case OpCode_shortint:
603
33.4k
  env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1]));
604
33.4k
  env.str_ref.inc (2);
605
33.4k
  break;
606
607
118k
      case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
608
159k
      case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
609
159k
  env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108));
610
159k
  env.str_ref.inc ();
611
159k
  break;
612
613
34.1k
      case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
614
52.2k
      case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
615
52.2k
  env.argStack.push_int ((-(int16_t)(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108));
616
52.2k
  env.str_ref.inc ();
617
52.2k
  break;
618
619
310M
      default:
620
  /* 1-byte integer */
621
310M
  if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast)))
622
1.19M
  {
623
1.19M
    env.argStack.push_int ((int)op - 139);
624
309M
  } else {
625
    /* invalid unknown operator */
626
309M
    env.clear_args ();
627
309M
  }
628
310M
  break;
629
310M
    }
630
310M
  }
CFF::opset_t<CFF::blend_arg_t>::process_op(unsigned int, CFF::interp_env_t<CFF::blend_arg_t>&)
Line
Count
Source
600
3.72M
  {
601
3.72M
    switch (op) {
602
417
      case OpCode_shortint:
603
417
  env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1]));
604
417
  env.str_ref.inc (2);
605
417
  break;
606
607
4.83k
      case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
608
103k
      case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
609
103k
  env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108));
610
103k
  env.str_ref.inc ();
611
103k
  break;
612
613
32.2k
      case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
614
46.9k
      case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
615
46.9k
  env.argStack.push_int ((-(int16_t)(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108));
616
46.9k
  env.str_ref.inc ();
617
46.9k
  break;
618
619
3.57M
      default:
620
  /* 1-byte integer */
621
3.57M
  if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast)))
622
3.48M
  {
623
3.48M
    env.argStack.push_int ((int)op - 139);
624
3.48M
  } else {
625
    /* invalid unknown operator */
626
94.8k
    env.clear_args ();
627
94.8k
  }
628
3.57M
  break;
629
3.72M
    }
630
3.72M
  }
631
};
632
633
template <typename ENV>
634
struct interpreter_t
635
{
636
60.9k
  interpreter_t (ENV& env_) : env (env_) {}
CFF::interpreter_t<CFF::interp_env_t<CFF::number_t> >::interpreter_t(CFF::interp_env_t<CFF::number_t>&)
Line
Count
Source
636
42.4k
  interpreter_t (ENV& env_) : env (env_) {}
CFF::interpreter_t<CFF::cff2_priv_dict_interp_env_t>::interpreter_t(CFF::cff2_priv_dict_interp_env_t&)
Line
Count
Source
636
2.95k
  interpreter_t (ENV& env_) : env (env_) {}
CFF::interpreter_t<CFF::cff1_top_dict_interp_env_t>::interpreter_t(CFF::cff1_top_dict_interp_env_t&)
Line
Count
Source
636
5.38k
  interpreter_t (ENV& env_) : env (env_) {}
CFF::interpreter_t<CFF::cff1_cs_interp_env_t>::interpreter_t(CFF::cff1_cs_interp_env_t&)
Line
Count
Source
636
8.60k
  interpreter_t (ENV& env_) : env (env_) {}
Unexecuted instantiation: CFF::interpreter_t<CFF::cff2_cs_interp_env_t<CFF::number_t> >::interpreter_t(CFF::cff2_cs_interp_env_t<CFF::number_t>&)
CFF::interpreter_t<CFF::cff2_cs_interp_env_t<CFF::blend_arg_t> >::interpreter_t(CFF::cff2_cs_interp_env_t<CFF::blend_arg_t>&)
Line
Count
Source
636
1.51k
  interpreter_t (ENV& env_) : env (env_) {}
637
  ENV& env;
638
};
639
640
} /* namespace CFF */
641
642
#endif /* HB_CFF_INTERP_COMMON_HH */