2018-08-15 21:00:19 +02:00
|
|
|
/*
|
2018-11-12 17:47:07 +01:00
|
|
|
* Copyright © 2018 Adobe Inc.
|
2018-08-15 21:00:19 +02:00
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Adobe Author(s): Michiharu Ariza
|
|
|
|
*/
|
2018-08-29 22:36:39 +02:00
|
|
|
#ifndef HB_CFF_INTERP_CS_COMMON_HH
|
|
|
|
#define HB_CFF_INTERP_CS_COMMON_HH
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-08-29 22:26:17 +02:00
|
|
|
#include "hb.hh"
|
|
|
|
#include "hb-cff-interp-common.hh"
|
2018-08-15 21:00:19 +02:00
|
|
|
|
|
|
|
namespace CFF {
|
|
|
|
|
|
|
|
using namespace OT;
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
enum cs_type_t {
|
2018-11-01 06:30:34 +01:00
|
|
|
CSType_CharString,
|
|
|
|
CSType_GlobalSubr,
|
|
|
|
CSType_LocalSubr
|
|
|
|
};
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
struct call_context_t
|
2018-11-01 06:30:34 +01:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
void init (const byte_str_ref_t substr_=byte_str_ref_t (), cs_type_t type_=CSType_CharString, unsigned int subr_num_=0)
|
2018-11-01 06:30:34 +01:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
str_ref = substr_;
|
2018-11-01 06:30:34 +01:00
|
|
|
type = type_;
|
|
|
|
subr_num = subr_num_;
|
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
void fini () {}
|
2018-11-01 06:30:34 +01:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
byte_str_ref_t str_ref;
|
|
|
|
cs_type_t type;
|
2018-11-01 06:30:34 +01:00
|
|
|
unsigned int subr_num;
|
|
|
|
};
|
|
|
|
|
2018-08-15 21:00:19 +02:00
|
|
|
/* call stack */
|
2018-11-01 06:30:34 +01:00
|
|
|
const unsigned int kMaxCallLimit = 10;
|
2019-07-05 16:16:41 +02:00
|
|
|
struct call_stack_t : cff_stack_t<call_context_t, kMaxCallLimit> {};
|
2018-08-15 21:00:19 +02:00
|
|
|
|
|
|
|
template <typename SUBRS>
|
2018-12-22 16:47:04 +01:00
|
|
|
struct biased_subrs_t
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2019-06-27 00:58:38 +02:00
|
|
|
void init (const SUBRS *subrs_)
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2019-06-27 00:58:38 +02:00
|
|
|
subrs = subrs_;
|
2018-12-05 06:32:34 +01:00
|
|
|
unsigned int nSubrs = get_count ();
|
2018-08-15 21:00:19 +02:00
|
|
|
if (nSubrs < 1240)
|
|
|
|
bias = 107;
|
|
|
|
else if (nSubrs < 33900)
|
|
|
|
bias = 1131;
|
|
|
|
else
|
|
|
|
bias = 32768;
|
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
void fini () {}
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2020-04-20 21:18:23 +02:00
|
|
|
unsigned int get_count () const { return subrs ? subrs->count : 0; }
|
2019-06-09 09:19:25 +02:00
|
|
|
unsigned int get_bias () const { return bias; }
|
2018-12-05 06:32:34 +01:00
|
|
|
|
2022-05-10 00:09:56 +02:00
|
|
|
hb_ubytes_t operator [] (unsigned int index) const
|
2018-12-05 06:32:34 +01:00
|
|
|
{
|
2020-04-20 21:18:23 +02:00
|
|
|
if (unlikely (!subrs || index >= subrs->count))
|
2022-05-10 23:15:49 +02:00
|
|
|
return hb_ubytes_t ();
|
2018-12-05 06:32:34 +01:00
|
|
|
else
|
|
|
|
return (*subrs)[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-08-15 21:00:19 +02:00
|
|
|
unsigned int bias;
|
2018-12-05 06:32:34 +01:00
|
|
|
const SUBRS *subrs;
|
2018-08-15 21:00:19 +02:00
|
|
|
};
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
struct point_t
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
void set_int (int _x, int _y)
|
2018-11-14 22:38:03 +01:00
|
|
|
{
|
|
|
|
x.set_int (_x);
|
|
|
|
y.set_int (_y);
|
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
void move_x (const number_t &dx) { x += dx; }
|
|
|
|
void move_y (const number_t &dy) { y += dy; }
|
|
|
|
void move (const number_t &dx, const number_t &dy) { move_x (dx); move_y (dy); }
|
|
|
|
void move (const point_t &d) { move_x (d.x); move_y (d.y); }
|
2018-09-17 20:14:56 +02:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
number_t x;
|
|
|
|
number_t y;
|
2018-09-17 20:14:56 +02:00
|
|
|
};
|
|
|
|
|
2018-09-01 01:28:47 +02:00
|
|
|
template <typename ARG, typename SUBRS>
|
2018-12-22 16:47:04 +01:00
|
|
|
struct cs_interp_env_t : interp_env_t<ARG>
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2022-05-11 00:33:37 +02:00
|
|
|
cs_interp_env_t (const hb_ubytes_t &str, const SUBRS *globalSubrs_, const SUBRS *localSubrs_) :
|
|
|
|
interp_env_t<ARG> (str)
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-11-01 06:30:34 +01:00
|
|
|
context.init (str, CSType_CharString);
|
2018-08-17 22:13:18 +02:00
|
|
|
seen_moveto = true;
|
|
|
|
seen_hintmask = false;
|
|
|
|
hstem_count = 0;
|
|
|
|
vstem_count = 0;
|
2019-01-18 18:43:51 +01:00
|
|
|
hintmask_size = 0;
|
2022-01-18 21:14:42 +01:00
|
|
|
pt.set_int (0, 0);
|
2018-08-15 21:00:19 +02:00
|
|
|
globalSubrs.init (globalSubrs_);
|
|
|
|
localSubrs.init (localSubrs_);
|
|
|
|
}
|
2022-05-11 00:33:37 +02:00
|
|
|
~cs_interp_env_t ()
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
|
|
|
globalSubrs.fini ();
|
|
|
|
localSubrs.fini ();
|
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
bool in_error () const
|
2018-10-12 11:16:07 +02:00
|
|
|
{
|
|
|
|
return callStack.in_error () || SUPER::in_error ();
|
|
|
|
}
|
|
|
|
|
2019-05-08 22:44:03 +02:00
|
|
|
bool pop_subr_num (const biased_subrs_t<SUBRS>& biasedSubrs, unsigned int &subr_num)
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2019-05-08 22:44:03 +02:00
|
|
|
subr_num = 0;
|
2018-10-12 11:16:07 +02:00
|
|
|
int n = SUPER::argStack.pop_int ();
|
2018-12-05 06:32:34 +01:00
|
|
|
n += biasedSubrs.get_bias ();
|
|
|
|
if (unlikely ((n < 0) || ((unsigned int)n >= biasedSubrs.get_count ())))
|
2018-08-15 21:00:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
subr_num = (unsigned int)n;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-08 22:44:03 +02:00
|
|
|
void call_subr (const biased_subrs_t<SUBRS>& biasedSubrs, cs_type_t type)
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2019-05-08 21:01:55 +02:00
|
|
|
unsigned int subr_num = 0;
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2019-05-08 22:44:03 +02:00
|
|
|
if (unlikely (!pop_subr_num (biasedSubrs, subr_num)
|
2018-12-01 05:04:59 +01:00
|
|
|
|| callStack.get_count () >= kMaxCallLimit))
|
2018-11-01 06:30:34 +01:00
|
|
|
{
|
|
|
|
SUPER::set_error ();
|
|
|
|
return;
|
|
|
|
}
|
2018-12-22 16:47:04 +01:00
|
|
|
context.str_ref = SUPER::str_ref;
|
2018-11-01 06:30:34 +01:00
|
|
|
callStack.push (context);
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-12-05 06:32:34 +01:00
|
|
|
context.init ( biasedSubrs[subr_num], type, subr_num);
|
2018-12-22 16:47:04 +01:00
|
|
|
SUPER::str_ref = context.str_ref;
|
2018-08-15 21:00:19 +02:00
|
|
|
}
|
|
|
|
|
2019-05-08 22:44:03 +02:00
|
|
|
void return_from_subr ()
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
if (unlikely (SUPER::str_ref.in_error ()))
|
2018-10-12 11:16:07 +02:00
|
|
|
SUPER::set_error ();
|
2018-11-01 06:30:34 +01:00
|
|
|
context = callStack.pop ();
|
2018-12-22 16:47:04 +01:00
|
|
|
SUPER::str_ref = context.str_ref;
|
2018-08-15 21:00:19 +02:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
void determine_hintmask_size ()
|
2018-08-17 22:13:18 +02:00
|
|
|
{
|
|
|
|
if (!seen_hintmask)
|
|
|
|
{
|
2018-09-01 01:28:47 +02:00
|
|
|
vstem_count += SUPER::argStack.get_count() / 2;
|
2018-08-17 22:13:18 +02:00
|
|
|
hintmask_size = (hstem_count + vstem_count + 7) >> 3;
|
|
|
|
seen_hintmask = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; }
|
2018-12-17 19:01:01 +01:00
|
|
|
bool is_endchar () const { return endchar_flag; }
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
const number_t &get_x () const { return pt.x; }
|
|
|
|
const number_t &get_y () const { return pt.y; }
|
|
|
|
const point_t &get_pt () const { return pt; }
|
2018-09-17 20:14:56 +02:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
void moveto (const point_t &pt_ ) { pt = pt_; }
|
2018-09-17 20:14:56 +02:00
|
|
|
|
2018-08-29 21:14:30 +02:00
|
|
|
public:
|
2018-12-22 16:47:04 +01:00
|
|
|
call_context_t context;
|
2018-12-01 05:04:59 +01:00
|
|
|
bool endchar_flag;
|
|
|
|
bool seen_moveto;
|
|
|
|
bool seen_hintmask;
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-08-17 22:13:18 +02:00
|
|
|
unsigned int hstem_count;
|
|
|
|
unsigned int vstem_count;
|
|
|
|
unsigned int hintmask_size;
|
2018-12-22 16:47:04 +01:00
|
|
|
call_stack_t callStack;
|
|
|
|
biased_subrs_t<SUBRS> globalSubrs;
|
|
|
|
biased_subrs_t<SUBRS> localSubrs;
|
2018-09-01 01:28:47 +02:00
|
|
|
|
|
|
|
private:
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt;
|
2018-09-17 20:14:56 +02:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
typedef interp_env_t<ARG> SUPER;
|
2018-08-15 21:00:19 +02:00
|
|
|
};
|
|
|
|
|
2018-09-17 20:14:56 +02:00
|
|
|
template <typename ENV, typename PARAM>
|
2018-12-22 16:47:04 +01:00
|
|
|
struct path_procs_null_t
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
static void rmoveto (ENV &env, PARAM& param) {}
|
|
|
|
static void hmoveto (ENV &env, PARAM& param) {}
|
|
|
|
static void vmoveto (ENV &env, PARAM& param) {}
|
|
|
|
static void rlineto (ENV &env, PARAM& param) {}
|
|
|
|
static void hlineto (ENV &env, PARAM& param) {}
|
|
|
|
static void vlineto (ENV &env, PARAM& param) {}
|
|
|
|
static void rrcurveto (ENV &env, PARAM& param) {}
|
|
|
|
static void rcurveline (ENV &env, PARAM& param) {}
|
|
|
|
static void rlinecurve (ENV &env, PARAM& param) {}
|
|
|
|
static void vvcurveto (ENV &env, PARAM& param) {}
|
|
|
|
static void hhcurveto (ENV &env, PARAM& param) {}
|
|
|
|
static void vhcurveto (ENV &env, PARAM& param) {}
|
|
|
|
static void hvcurveto (ENV &env, PARAM& param) {}
|
2018-12-22 16:47:04 +01:00
|
|
|
static void moveto (ENV &env, PARAM& param, const point_t &pt) {}
|
|
|
|
static void line (ENV &env, PARAM& param, const point_t &pt1) {}
|
|
|
|
static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &pt3) {}
|
2018-12-16 20:08:10 +01:00
|
|
|
static void hflex (ENV &env, PARAM& param) {}
|
|
|
|
static void flex (ENV &env, PARAM& param) {}
|
|
|
|
static void hflex1 (ENV &env, PARAM& param) {}
|
|
|
|
static void flex1 (ENV &env, PARAM& param) {}
|
2018-09-17 20:14:56 +02:00
|
|
|
};
|
|
|
|
|
2019-04-30 22:05:10 +02:00
|
|
|
template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=path_procs_null_t<ENV, PARAM>>
|
2018-12-22 16:47:04 +01:00
|
|
|
struct cs_opset_t : opset_t<ARG>
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_op (op_code_t op, ENV &env, PARAM& param)
|
2018-12-01 04:54:57 +01:00
|
|
|
{
|
2018-08-15 21:00:19 +02:00
|
|
|
switch (op) {
|
|
|
|
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_return:
|
2019-05-08 22:44:03 +02:00
|
|
|
env.return_from_subr ();
|
2018-12-01 05:04:59 +01:00
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_endchar:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
env.set_endchar (true);
|
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
|
2018-08-22 20:36:39 +02:00
|
|
|
case OpCode_fixedcs:
|
2018-12-22 16:47:04 +01:00
|
|
|
env.argStack.push_fixed_from_substr (env.str_ref);
|
2018-12-01 05:04:59 +01:00
|
|
|
break;
|
2018-08-15 21:00:19 +02:00
|
|
|
|
|
|
|
case OpCode_callsubr:
|
2019-05-08 22:44:03 +02:00
|
|
|
env.call_subr (env.localSubrs, CSType_LocalSubr);
|
2018-12-01 05:04:59 +01:00
|
|
|
break;
|
2018-10-12 11:16:07 +02:00
|
|
|
|
2018-08-15 21:00:19 +02:00
|
|
|
case OpCode_callgsubr:
|
2019-05-08 22:44:03 +02:00
|
|
|
env.call_subr (env.globalSubrs, CSType_GlobalSubr);
|
2018-12-01 05:04:59 +01:00
|
|
|
break;
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_hstem:
|
|
|
|
case OpCode_hstemhm:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
OPSET::process_hstem (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_vstem:
|
|
|
|
case OpCode_vstemhm:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
OPSET::process_vstem (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_hintmask:
|
|
|
|
case OpCode_cntrmask:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
OPSET::process_hintmask (op, env, param);
|
|
|
|
break;
|
2018-09-17 20:14:56 +02:00
|
|
|
case OpCode_rmoveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
PATH::rmoveto (env, param);
|
|
|
|
OPSET::process_post_move (op, env, param);
|
|
|
|
break;
|
2018-09-17 20:14:56 +02:00
|
|
|
case OpCode_hmoveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
PATH::hmoveto (env, param);
|
|
|
|
OPSET::process_post_move (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_vmoveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
PATH::vmoveto (env, param);
|
|
|
|
OPSET::process_post_move (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_rlineto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::rlineto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_hlineto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::hlineto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_vlineto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::vlineto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_rrcurveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::rrcurveto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_rcurveline:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::rcurveline (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_rlinecurve:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::rlinecurve (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_vvcurveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::vvcurveto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_hhcurveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::hhcurveto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_vhcurveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::vhcurveto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_hvcurveto:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::hvcurveto (env, param);
|
|
|
|
process_post_path (op, env, param);
|
|
|
|
break;
|
2018-08-31 22:28:16 +02:00
|
|
|
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_hflex:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::hflex (env, param);
|
|
|
|
OPSET::process_post_flex (op, env, param);
|
|
|
|
break;
|
2018-10-18 22:04:21 +02:00
|
|
|
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_flex:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::flex (env, param);
|
|
|
|
OPSET::process_post_flex (op, env, param);
|
|
|
|
break;
|
2018-10-18 22:04:21 +02:00
|
|
|
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_hflex1:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::hflex1 (env, param);
|
|
|
|
OPSET::process_post_flex (op, env, param);
|
|
|
|
break;
|
2018-10-18 22:04:21 +02:00
|
|
|
|
2018-08-17 22:13:18 +02:00
|
|
|
case OpCode_flex1:
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::flex1 (env, param);
|
|
|
|
OPSET::process_post_flex (op, env, param);
|
|
|
|
break;
|
2018-08-17 22:13:18 +02:00
|
|
|
|
2018-08-15 21:00:19 +02:00
|
|
|
default:
|
2018-12-01 05:04:59 +01:00
|
|
|
SUPER::process_op (op, env);
|
|
|
|
break;
|
2018-08-15 21:00:19 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-29 21:14:30 +02:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_hstem (op_code_t op, ENV &env, PARAM& param)
|
2018-08-31 22:28:16 +02:00
|
|
|
{
|
2018-09-17 20:14:56 +02:00
|
|
|
env.hstem_count += env.argStack.get_count () / 2;
|
2018-08-31 22:28:16 +02:00
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_vstem (op_code_t op, ENV &env, PARAM& param)
|
2018-08-31 22:28:16 +02:00
|
|
|
{
|
2018-09-17 20:14:56 +02:00
|
|
|
env.vstem_count += env.argStack.get_count () / 2;
|
2018-08-31 22:28:16 +02:00
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_hintmask (op_code_t op, ENV &env, PARAM& param)
|
2018-08-29 21:14:30 +02:00
|
|
|
{
|
2018-08-31 22:28:16 +02:00
|
|
|
env.determine_hintmask_size ();
|
2018-12-22 16:47:04 +01:00
|
|
|
if (likely (env.str_ref.avail (env.hintmask_size)))
|
2018-08-31 22:28:16 +02:00
|
|
|
{
|
|
|
|
OPSET::flush_hintmask (op, env, param);
|
2018-12-22 16:47:04 +01:00
|
|
|
env.str_ref.inc (env.hintmask_size);
|
2018-08-31 22:28:16 +02:00
|
|
|
}
|
2018-08-29 21:14:30 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_post_flex (op_code_t op, ENV &env, PARAM& param)
|
2018-08-29 21:14:30 +02:00
|
|
|
{
|
2018-08-31 22:28:16 +02:00
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
2018-08-29 21:14:30 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void check_width (op_code_t op, ENV &env, PARAM& param)
|
2018-11-01 06:30:34 +01:00
|
|
|
{}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_post_move (op_code_t op, ENV &env, PARAM& param)
|
2018-08-29 21:14:30 +02:00
|
|
|
{
|
|
|
|
if (!env.seen_moveto)
|
|
|
|
{
|
|
|
|
env.determine_hintmask_size ();
|
|
|
|
env.seen_moveto = true;
|
|
|
|
}
|
2018-08-31 22:28:16 +02:00
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
2018-08-29 21:14:30 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_post_path (op_code_t op, ENV &env, PARAM& param)
|
2018-08-29 21:14:30 +02:00
|
|
|
{
|
2018-08-31 22:28:16 +02:00
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
2018-08-29 21:14:30 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void flush_args_and_op (op_code_t op, ENV &env, PARAM& param)
|
2018-08-29 21:14:30 +02:00
|
|
|
{
|
2018-11-01 06:30:34 +01:00
|
|
|
OPSET::flush_args (env, param);
|
2018-08-31 22:28:16 +02:00
|
|
|
OPSET::flush_op (op, env, param);
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void flush_args (ENV &env, PARAM& param)
|
2018-08-31 22:28:16 +02:00
|
|
|
{
|
2018-11-01 06:30:34 +01:00
|
|
|
env.pop_n_args (env.argStack.get_count ());
|
2018-08-31 22:28:16 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void flush_op (op_code_t op, ENV &env, PARAM& param)
|
2018-08-31 22:28:16 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void flush_hintmask (op_code_t op, ENV &env, PARAM& param)
|
2018-08-31 22:28:16 +02:00
|
|
|
{
|
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
2018-08-31 02:21:56 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static bool is_number_op (op_code_t op)
|
2018-11-01 06:30:34 +01:00
|
|
|
{
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case OpCode_shortint:
|
|
|
|
case OpCode_fixedcs:
|
|
|
|
case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
|
|
|
|
case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
|
|
|
|
case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
|
|
|
|
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
|
2018-12-01 05:04:59 +01:00
|
|
|
return true;
|
2018-11-01 06:30:34 +01:00
|
|
|
|
|
|
|
default:
|
2018-12-01 05:04:59 +01:00
|
|
|
/* 1-byte integer */
|
|
|
|
return (OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast);
|
2018-11-01 06:30:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-17 20:14:56 +02:00
|
|
|
protected:
|
2018-12-22 16:47:04 +01:00
|
|
|
typedef opset_t<ARG> SUPER;
|
2018-08-15 21:00:19 +02:00
|
|
|
};
|
|
|
|
|
2018-09-17 20:14:56 +02:00
|
|
|
template <typename PATH, typename ENV, typename PARAM>
|
2018-12-22 16:47:04 +01:00
|
|
|
struct path_procs_t
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
static void rmoveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
|
|
|
const number_t &dy = env.pop_arg ();
|
|
|
|
const number_t &dx = env.pop_arg ();
|
2018-09-17 20:14:56 +02:00
|
|
|
pt1.move (dx, dy);
|
2018-09-18 00:34:39 +02:00
|
|
|
PATH::moveto (env, param, pt1);
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void hmoveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_x (env.pop_arg ());
|
2018-09-18 00:34:39 +02:00
|
|
|
PATH::moveto (env, param, pt1);
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void vmoveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_y (env.pop_arg ());
|
2018-09-18 00:34:39 +02:00
|
|
|
PATH::moveto (env, param, pt1);
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void rlineto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i + 2 <= env.argStack.get_count (); i += 2)
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
|
|
|
}
|
|
|
|
}
|
2018-12-01 04:54:57 +01:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void hlineto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1;
|
2018-09-17 20:14:56 +02:00
|
|
|
unsigned int i = 0;
|
|
|
|
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
|
|
|
{
|
|
|
|
pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_x (env.eval_arg (i));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_y (env.eval_arg (i+1));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
|
|
|
}
|
|
|
|
if (i < env.argStack.get_count ())
|
|
|
|
{
|
|
|
|
pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_x (env.eval_arg (i));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void vlineto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1;
|
2018-09-17 20:14:56 +02:00
|
|
|
unsigned int i = 0;
|
|
|
|
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
|
|
|
{
|
|
|
|
pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_y (env.eval_arg (i));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_x (env.eval_arg (i+1));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
|
|
|
}
|
|
|
|
if (i < env.argStack.get_count ())
|
|
|
|
{
|
|
|
|
pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_y (env.eval_arg (i));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void rrcurveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i + 6 <= env.argStack.get_count (); i += 6)
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void rcurveline (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2019-11-17 20:32:12 +01:00
|
|
|
unsigned int arg_count = env.argStack.get_count ();
|
|
|
|
if (unlikely (arg_count < 8))
|
|
|
|
return;
|
|
|
|
|
2018-09-17 20:14:56 +02:00
|
|
|
unsigned int i = 0;
|
2019-11-17 20:32:12 +01:00
|
|
|
unsigned int curve_limit = arg_count - 2;
|
|
|
|
for (; i + 6 <= curve_limit; i += 6)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
}
|
2019-11-17 20:32:12 +01:00
|
|
|
|
|
|
|
point_t pt1 = env.get_pt ();
|
|
|
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
|
|
|
PATH::line (env, param, pt1);
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void rlinecurve (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2019-11-17 20:32:12 +01:00
|
|
|
unsigned int arg_count = env.argStack.get_count ();
|
|
|
|
if (unlikely (arg_count < 8))
|
|
|
|
return;
|
|
|
|
|
2018-09-17 20:14:56 +02:00
|
|
|
unsigned int i = 0;
|
2019-11-17 20:32:12 +01:00
|
|
|
unsigned int line_limit = arg_count - 6;
|
2018-09-17 20:14:56 +02:00
|
|
|
for (; i + 2 <= line_limit; i += 2)
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::line (env, param, pt1);
|
|
|
|
}
|
2019-11-17 20:32:12 +01:00
|
|
|
|
|
|
|
point_t pt1 = env.get_pt ();
|
|
|
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
|
|
|
point_t pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
|
|
|
point_t pt3 = pt2;
|
|
|
|
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void vvcurveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
|
|
|
unsigned int i = 0;
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-09-17 20:14:56 +02:00
|
|
|
if ((env.argStack.get_count () & 1) != 0)
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_x (env.eval_arg (i++));
|
2018-09-17 20:14:56 +02:00
|
|
|
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
|
|
|
{
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_y (env.eval_arg (i));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt3.move_y (env.eval_arg (i+3));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
pt1 = env.get_pt ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void hhcurveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
|
|
|
unsigned int i = 0;
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-09-17 20:14:56 +02:00
|
|
|
if ((env.argStack.get_count () & 1) != 0)
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_y (env.eval_arg (i++));
|
2018-09-17 20:14:56 +02:00
|
|
|
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
|
|
|
{
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_x (env.eval_arg (i));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt3.move_x (env.eval_arg (i+3));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
pt1 = env.get_pt ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void vhcurveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1, pt2, pt3;
|
2018-09-17 20:14:56 +02:00
|
|
|
unsigned int i = 0;
|
|
|
|
if ((env.argStack.get_count () % 8) >= 4)
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_y (env.eval_arg (i));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt3.move_x (env.eval_arg (i+3));
|
2018-09-17 20:14:56 +02:00
|
|
|
i += 4;
|
|
|
|
|
|
|
|
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
pt1 = env.get_pt ();
|
|
|
|
pt1.move_x (env.eval_arg (i));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_y (env.eval_arg (i+3));
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
|
|
|
|
pt1 = pt3;
|
|
|
|
pt1.move_y (env.eval_arg (i+4));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_x (env.eval_arg (i+7));
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
if (i < env.argStack.get_count ())
|
2018-12-01 05:04:59 +01:00
|
|
|
pt3.move_y (env.eval_arg (i));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
pt1 = env.get_pt ();
|
|
|
|
pt1.move_y (env.eval_arg (i));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_x (env.eval_arg (i+3));
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
|
|
|
|
pt1 = pt3;
|
|
|
|
pt1.move_x (env.eval_arg (i+4));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_y (env.eval_arg (i+7));
|
|
|
|
if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0))
|
|
|
|
pt3.move_x (env.eval_arg (i+8));
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void hvcurveto (ENV &env, PARAM& param)
|
2018-09-17 20:14:56 +02:00
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1, pt2, pt3;
|
2018-09-17 20:14:56 +02:00
|
|
|
unsigned int i = 0;
|
|
|
|
if ((env.argStack.get_count () % 8) >= 4)
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-09 00:05:36 +02:00
|
|
|
pt1.move_x (env.eval_arg (i));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-09 00:05:36 +02:00
|
|
|
pt3.move_y (env.eval_arg (i+3));
|
2018-09-17 20:14:56 +02:00
|
|
|
i += 4;
|
|
|
|
|
|
|
|
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
pt1 = env.get_pt ();
|
|
|
|
pt1.move_y (env.eval_arg (i));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_x (env.eval_arg (i+3));
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
|
|
|
|
pt1 = pt3;
|
|
|
|
pt1.move_x (env.eval_arg (i+4));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_y (env.eval_arg (i+7));
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
if (i < env.argStack.get_count ())
|
2018-12-01 05:04:59 +01:00
|
|
|
pt3.move_x (env.eval_arg (i));
|
2018-09-17 20:14:56 +02:00
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
pt1 = env.get_pt ();
|
|
|
|
pt1.move_x (env.eval_arg (i));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_y (env.eval_arg (i+3));
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
|
|
|
|
pt1 = pt3;
|
|
|
|
pt1.move_y (env.eval_arg (i+4));
|
|
|
|
pt2 = pt1;
|
|
|
|
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
|
|
|
pt3 = pt2;
|
|
|
|
pt3.move_x (env.eval_arg (i+7));
|
|
|
|
if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0))
|
|
|
|
pt3.move_y (env.eval_arg (i+8));
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
2018-09-17 20:14:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* default actions to be overridden */
|
2018-12-22 16:47:04 +01:00
|
|
|
static void moveto (ENV &env, PARAM& param, const point_t &pt)
|
2018-09-17 20:14:56 +02:00
|
|
|
{ env.moveto (pt); }
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void line (ENV &env, PARAM& param, const point_t &pt1)
|
2018-09-17 20:14:56 +02:00
|
|
|
{ PATH::moveto (env, param, pt1); }
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
|
2018-09-17 20:14:56 +02:00
|
|
|
{ PATH::moveto (env, param, pt3); }
|
2018-10-18 22:04:21 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void hflex (ENV &env, PARAM& param)
|
2018-10-18 22:04:21 +02:00
|
|
|
{
|
|
|
|
if (likely (env.argStack.get_count () == 7))
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-18 22:04:21 +02:00
|
|
|
pt1.move_x (env.eval_arg (0));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt2.move (env.eval_arg (1), env.eval_arg (2));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt3.move_x (env.eval_arg (3));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt4 = pt3;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt4.move_x (env.eval_arg (4));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt5 = pt4;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt5.move_x (env.eval_arg (5));
|
|
|
|
pt5.y = pt1.y;
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt6 = pt5;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt6.move_x (env.eval_arg (6));
|
|
|
|
|
|
|
|
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
env.set_error ();
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void flex (ENV &env, PARAM& param)
|
2018-10-18 22:04:21 +02:00
|
|
|
{
|
|
|
|
if (likely (env.argStack.get_count () == 13))
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-18 22:04:21 +02:00
|
|
|
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt4 = pt3;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt5 = pt4;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt6 = pt5;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt6.move (env.eval_arg (10), env.eval_arg (11));
|
|
|
|
|
|
|
|
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
env.set_error ();
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void hflex1 (ENV &env, PARAM& param)
|
2018-10-18 22:04:21 +02:00
|
|
|
{
|
|
|
|
if (likely (env.argStack.get_count () == 9))
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-18 22:04:21 +02:00
|
|
|
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt3.move_x (env.eval_arg (4));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt4 = pt3;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt4.move_x (env.eval_arg (5));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt5 = pt4;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt5.move (env.eval_arg (6), env.eval_arg (7));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt6 = pt5;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt6.move_x (env.eval_arg (8));
|
|
|
|
pt6.y = env.get_pt ().y;
|
|
|
|
|
|
|
|
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
env.set_error ();
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
static void flex1 (ENV &env, PARAM& param)
|
2018-10-18 22:04:21 +02:00
|
|
|
{
|
|
|
|
if (likely (env.argStack.get_count () == 11))
|
|
|
|
{
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t d;
|
2018-10-18 22:04:21 +02:00
|
|
|
for (unsigned int i = 0; i < 10; i += 2)
|
2018-12-01 05:04:59 +01:00
|
|
|
d.move (env.eval_arg (i), env.eval_arg (i+1));
|
2018-10-18 22:04:21 +02:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt1 = env.get_pt ();
|
2018-10-18 22:04:21 +02:00
|
|
|
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt2 = pt1;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt3 = pt2;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt4 = pt3;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt5 = pt4;
|
2018-10-18 22:04:21 +02:00
|
|
|
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
2018-12-22 16:47:04 +01:00
|
|
|
point_t pt6 = pt5;
|
2018-10-18 22:04:21 +02:00
|
|
|
|
|
|
|
if (fabs (d.x.to_real ()) > fabs (d.y.to_real ()))
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
pt6.move_x (env.eval_arg (10));
|
|
|
|
pt6.y = env.get_pt ().y;
|
2018-10-18 22:04:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
pt6.x = env.get_pt ().x;
|
|
|
|
pt6.move_y (env.eval_arg (10));
|
2018-10-18 22:04:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
env.set_error ();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-12-16 20:08:10 +01:00
|
|
|
static void curve2 (ENV &env, PARAM& param,
|
2018-12-22 16:47:04 +01:00
|
|
|
const point_t &pt1, const point_t &pt2, const point_t &pt3,
|
|
|
|
const point_t &pt4, const point_t &pt5, const point_t &pt6)
|
2018-10-18 22:04:21 +02:00
|
|
|
{
|
|
|
|
PATH::curve (env, param, pt1, pt2, pt3);
|
|
|
|
PATH::curve (env, param, pt4, pt5, pt6);
|
|
|
|
}
|
2018-09-17 20:14:56 +02:00
|
|
|
};
|
|
|
|
|
2018-08-15 21:00:19 +02:00
|
|
|
template <typename ENV, typename OPSET, typename PARAM>
|
2018-12-22 16:47:04 +01:00
|
|
|
struct cs_interpreter_t : interpreter_t<ENV>
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2022-05-11 00:33:37 +02:00
|
|
|
cs_interpreter_t (ENV& env_) : interpreter_t<ENV> (env_) {}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool interpret (PARAM& param)
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-09-01 01:28:47 +02:00
|
|
|
SUPER::env.set_endchar (false);
|
2018-08-15 21:00:19 +02:00
|
|
|
|
|
|
|
for (;;) {
|
2018-10-12 11:16:07 +02:00
|
|
|
OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param);
|
|
|
|
if (unlikely (SUPER::env.in_error ()))
|
2018-12-01 05:04:59 +01:00
|
|
|
return false;
|
2022-05-10 22:52:40 +02:00
|
|
|
if (SUPER::env.is_endchar ())
|
2018-12-01 05:04:59 +01:00
|
|
|
break;
|
2018-08-15 21:00:19 +02:00
|
|
|
}
|
2018-12-01 04:54:57 +01:00
|
|
|
|
2018-08-15 21:00:19 +02:00
|
|
|
return true;
|
|
|
|
}
|
2018-09-01 01:28:47 +02:00
|
|
|
|
|
|
|
private:
|
2018-12-22 16:47:04 +01:00
|
|
|
typedef interpreter_t<ENV> SUPER;
|
2018-08-15 21:00:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace CFF */
|
|
|
|
|
2018-08-29 22:36:39 +02:00
|
|
|
#endif /* HB_CFF_INTERP_CS_COMMON_HH */
|