Coverage Report

Created: 2024-07-05 06:13

/src/mupdf/thirdparty/harfbuzz/src/hb-cff1-interp-cs.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_CFF1_INTERP_CS_HH
27
#define HB_CFF1_INTERP_CS_HH
28
29
#include "hb.hh"
30
#include "hb-cff-interp-cs-common.hh"
31
32
namespace CFF {
33
34
using namespace OT;
35
36
typedef biased_subrs_t<CFF1Subrs>   cff1_biased_subrs_t;
37
38
struct cff1_cs_interp_env_t : cs_interp_env_t<number_t, CFF1Subrs>
39
{
40
  template <typename ACC>
41
  cff1_cs_interp_env_t (const hb_ubytes_t &str, ACC &acc, unsigned int fd)
42
    : SUPER (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs)
43
0
  {
44
0
    processed_width = false;
45
0
    has_width = false;
46
0
    arg_start = 0;
47
0
    in_seac = false;
48
0
  }
49
50
  void set_width (bool has_width_)
51
0
  {
52
0
    if (likely (!processed_width && (SUPER::argStack.get_count () > 0)))
53
0
    {
54
0
      if (has_width_)
55
0
      {
56
0
  width = SUPER::argStack[0];
57
0
  has_width = true;
58
0
  arg_start = 1;
59
0
      }
60
0
    }
61
0
    processed_width = true;
62
0
  }
63
64
  void clear_args ()
65
0
  {
66
0
    arg_start = 0;
67
0
    SUPER::clear_args ();
68
0
  }
69
70
0
  void set_in_seac (bool _in_seac) { in_seac = _in_seac; }
71
72
  bool    processed_width;
73
  bool    has_width;
74
  unsigned int  arg_start;
75
  number_t  width;
76
  bool    in_seac;
77
78
  private:
79
  typedef cs_interp_env_t<number_t, CFF1Subrs> SUPER;
80
};
81
82
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM>>
83
struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
84
{
85
  /* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
86
  /* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */
87
88
  static void process_op (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
89
0
  {
90
0
    switch (op) {
91
0
      case OpCode_dotsection:
92
0
  SUPER::flush_args_and_op (op, env, param);
93
0
  break;
94
95
0
      case OpCode_endchar:
96
0
  OPSET::check_width (op, env, param);
97
0
  if (env.argStack.get_count () >= 4)
98
0
  {
99
0
    OPSET::process_seac (env, param);
100
0
  }
101
0
  OPSET::flush_args_and_op (op, env, param);
102
0
  env.set_endchar (true);
103
0
  break;
104
105
0
      default:
106
0
  SUPER::process_op (op, env, param);
107
0
    }
108
0
  }
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_extents_t, cff1_extents_param_t, cff1_path_procs_extents_t>::process_op(unsigned int, CFF::cff1_cs_interp_env_t&, cff1_extents_param_t&)
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_path_t, cff1_path_param_t, cff1_path_procs_path_t>::process_op(unsigned int, CFF::cff1_cs_interp_env_t&, cff1_path_param_t&)
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_seac_t, get_seac_param_t, CFF::path_procs_null_t<CFF::cff1_cs_interp_env_t, get_seac_param_t> >::process_op(unsigned int, CFF::cff1_cs_interp_env_t&, get_seac_param_t&)
109
110
  static void check_width (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
111
0
  {
112
0
    if (!env.processed_width)
113
0
    {
114
0
      bool  has_width = false;
115
0
      switch (op)
116
0
      {
117
0
  case OpCode_endchar:
118
0
  case OpCode_hstem:
119
0
  case OpCode_hstemhm:
120
0
  case OpCode_vstem:
121
0
  case OpCode_vstemhm:
122
0
  case OpCode_hintmask:
123
0
  case OpCode_cntrmask:
124
0
    has_width = ((env.argStack.get_count () & 1) != 0);
125
0
    break;
126
0
  case OpCode_hmoveto:
127
0
  case OpCode_vmoveto:
128
0
    has_width = (env.argStack.get_count () > 1);
129
0
    break;
130
0
  case OpCode_rmoveto:
131
0
    has_width = (env.argStack.get_count () > 2);
132
0
    break;
133
0
  default:
134
0
    return;
135
0
      }
136
0
      env.set_width (has_width);
137
0
    }
138
0
  }
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_extents_t, cff1_extents_param_t, cff1_path_procs_extents_t>::check_width(unsigned int, CFF::cff1_cs_interp_env_t&, cff1_extents_param_t&)
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_path_t, cff1_path_param_t, cff1_path_procs_path_t>::check_width(unsigned int, CFF::cff1_cs_interp_env_t&, cff1_path_param_t&)
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_seac_t, get_seac_param_t, CFF::path_procs_null_t<CFF::cff1_cs_interp_env_t, get_seac_param_t> >::check_width(unsigned int, CFF::cff1_cs_interp_env_t&, get_seac_param_t&)
139
140
  static void process_seac (cff1_cs_interp_env_t &env, PARAM& param)
141
  {
142
  }
143
144
  static void flush_args (cff1_cs_interp_env_t &env, PARAM& param)
145
0
  {
146
0
    SUPER::flush_args (env, param);
147
0
    env.clear_args ();  /* pop off width */
148
0
  }
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_extents_t, cff1_extents_param_t, cff1_path_procs_extents_t>::flush_args(CFF::cff1_cs_interp_env_t&, cff1_extents_param_t&)
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_path_t, cff1_path_param_t, cff1_path_procs_path_t>::flush_args(CFF::cff1_cs_interp_env_t&, cff1_path_param_t&)
Unexecuted instantiation: CFF::cff1_cs_opset_t<cff1_cs_opset_seac_t, get_seac_param_t, CFF::path_procs_null_t<CFF::cff1_cs_interp_env_t, get_seac_param_t> >::flush_args(CFF::cff1_cs_interp_env_t&, get_seac_param_t&)
149
150
  private:
151
  typedef cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>  SUPER;
152
};
153
154
template <typename OPSET, typename PARAM>
155
using cff1_cs_interpreter_t = cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM>;
156
157
} /* namespace CFF */
158
159
#endif /* HB_CFF1_INTERP_CS_HH */