2 * Copyright © 2018 Adobe Inc.
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
24 * Adobe Author(s): Michiharu Ariza
26 #ifndef HB_CFF1_INTERP_CS_HH
27 #define HB_CFF1_INTERP_CS_HH
30 #include "hb-cff-interp-cs-common.hh"
36 typedef biased_subrs_t<CFF1Subrs> cff1_biased_subrs_t;
38 struct cff1_cs_interp_env_t : cs_interp_env_t<number_t, CFF1Subrs>
40 template <typename ACC>
41 void init (const byte_str_t &str, ACC &acc, unsigned int fd)
43 SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
44 processed_width = false;
50 void fini () { SUPER::fini (); }
52 void set_width (bool has_width_)
54 if (likely (!processed_width && (SUPER::argStack.get_count () > 0)))
58 width = SUPER::argStack[0];
63 processed_width = true;
72 void set_in_seac (bool _in_seac) { in_seac = _in_seac; }
76 unsigned int arg_start;
81 typedef cs_interp_env_t<number_t, CFF1Subrs> SUPER;
84 template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM> >
85 struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
87 /* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
88 /* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */
90 static void process_op (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
93 case OpCode_dotsection:
94 SUPER::flush_args_and_op (op, env, param);
98 OPSET::check_width (op, env, param);
99 if (env.argStack.get_count () >= 4)
101 OPSET::process_seac (env, param);
103 OPSET::flush_args_and_op (op, env, param);
104 env.set_endchar (true);
108 SUPER::process_op (op, env, param);
112 static void check_width (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
114 if (!env.processed_width)
116 bool has_width = false;
124 case OpCode_hintmask:
125 case OpCode_cntrmask:
126 has_width = ((env.argStack.get_count () & 1) != 0);
130 has_width = (env.argStack.get_count () > 1);
133 has_width = (env.argStack.get_count () > 2);
138 env.set_width (has_width);
142 static void process_seac (cff1_cs_interp_env_t &env, PARAM& param)
146 static void flush_args (cff1_cs_interp_env_t &env, PARAM& param)
148 SUPER::flush_args (env, param);
149 env.clear_args (); /* pop off width */
153 typedef cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH> SUPER;
156 template <typename OPSET, typename PARAM>
157 struct cff1_cs_interpreter_t : cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM> {};
159 } /* namespace CFF */
161 #endif /* HB_CFF1_INTERP_CS_HH */