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-16 09:13:09 +02:00
|
|
|
#ifndef HB_CFF1_INTERP_CS_HH
|
|
|
|
#define HB_CFF1_INTERP_CS_HH
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-08-29 22:26:17 +02:00
|
|
|
#include "hb.hh"
|
|
|
|
#include "hb-cff-interp-cs-common.hh"
|
2018-08-15 21:00:19 +02:00
|
|
|
|
|
|
|
namespace CFF {
|
|
|
|
|
|
|
|
using namespace OT;
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
typedef biased_subrs_t<CFF1Subrs> cff1_biased_subrs_t;
|
2018-11-01 06:30:34 +01:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
struct cff1_cs_interp_env_t : cs_interp_env_t<number_t, CFF1Subrs>
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-09-04 19:25:21 +02:00
|
|
|
template <typename ACC>
|
2018-12-22 16:47:04 +01:00
|
|
|
void init (const byte_str_t &str, ACC &acc, unsigned int fd)
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-09-04 19:25:21 +02:00
|
|
|
SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
|
2018-08-29 21:14:30 +02:00
|
|
|
processed_width = false;
|
|
|
|
has_width = false;
|
2018-11-01 06:30:34 +01:00
|
|
|
arg_start = 0;
|
2018-11-15 21:10:23 +01:00
|
|
|
in_seac = false;
|
2018-08-15 21:00:19 +02:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
void fini () { SUPER::fini (); }
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void set_width (bool has_width_)
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-11-01 06:30:34 +01:00
|
|
|
if (likely (!processed_width && (SUPER::argStack.get_count () > 0)))
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-11-01 16:46:21 +01:00
|
|
|
if (has_width_)
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
width = SUPER::argStack[0];
|
|
|
|
has_width = true;
|
|
|
|
arg_start = 1;
|
2018-11-01 16:46:21 +01:00
|
|
|
}
|
2018-08-15 21:00:19 +02:00
|
|
|
}
|
2018-11-01 16:46:21 +01:00
|
|
|
processed_width = true;
|
2018-11-01 06:30:34 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
void clear_args ()
|
2018-11-01 06:30:34 +01:00
|
|
|
{
|
|
|
|
arg_start = 0;
|
|
|
|
SUPER::clear_args ();
|
2018-08-15 21:00:19 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void set_in_seac (bool _in_seac) { in_seac = _in_seac; }
|
2018-11-15 21:10:23 +01:00
|
|
|
|
2018-12-01 05:04:59 +01:00
|
|
|
bool processed_width;
|
|
|
|
bool has_width;
|
2018-11-01 06:30:34 +01:00
|
|
|
unsigned int arg_start;
|
2018-12-22 16:47:04 +01:00
|
|
|
number_t width;
|
2018-12-01 05:04:59 +01:00
|
|
|
bool in_seac;
|
2018-08-15 21:00:19 +02:00
|
|
|
|
2018-09-01 01:28:47 +02:00
|
|
|
private:
|
2018-12-22 16:47:04 +01:00
|
|
|
typedef cs_interp_env_t<number_t, CFF1Subrs> SUPER;
|
2018-08-15 21:00:19 +02:00
|
|
|
};
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM> >
|
|
|
|
struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
|
2018-08-15 21:00:19 +02:00
|
|
|
{
|
2018-10-25 22:40:40 +02:00
|
|
|
/* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
|
2018-11-14 22:38:03 +01:00
|
|
|
/* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_op (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
|
2018-11-14 22:38:03 +01:00
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case OpCode_dotsection:
|
2018-12-01 05:04:59 +01:00
|
|
|
SUPER::flush_args_and_op (op, env, param);
|
|
|
|
break;
|
2018-11-14 22:38:03 +01:00
|
|
|
|
|
|
|
case OpCode_endchar:
|
2018-12-01 05:04:59 +01:00
|
|
|
OPSET::check_width (op, env, param);
|
|
|
|
if (env.argStack.get_count () >= 4)
|
|
|
|
{
|
|
|
|
OPSET::process_seac (env, param);
|
|
|
|
}
|
|
|
|
OPSET::flush_args_and_op (op, env, param);
|
|
|
|
env.set_endchar (true);
|
|
|
|
break;
|
2018-11-14 22:38:03 +01:00
|
|
|
|
|
|
|
default:
|
2018-12-01 05:04:59 +01:00
|
|
|
SUPER::process_op (op, env, param);
|
2018-11-14 22:38:03 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-29 21:14:30 +02:00
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void check_width (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
|
2018-11-01 06:30:34 +01:00
|
|
|
{
|
|
|
|
if (!env.processed_width)
|
|
|
|
{
|
|
|
|
bool has_width = false;
|
|
|
|
switch (op)
|
|
|
|
{
|
2018-12-01 05:04:59 +01:00
|
|
|
case OpCode_endchar:
|
|
|
|
case OpCode_hstem:
|
|
|
|
case OpCode_hstemhm:
|
|
|
|
case OpCode_vstem:
|
|
|
|
case OpCode_vstemhm:
|
|
|
|
case OpCode_hintmask:
|
|
|
|
case OpCode_cntrmask:
|
|
|
|
has_width = ((env.argStack.get_count () & 1) != 0);
|
|
|
|
break;
|
|
|
|
case OpCode_hmoveto:
|
|
|
|
case OpCode_vmoveto:
|
|
|
|
has_width = (env.argStack.get_count () > 1);
|
|
|
|
break;
|
|
|
|
case OpCode_rmoveto:
|
|
|
|
has_width = (env.argStack.get_count () > 2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2018-11-01 06:30:34 +01:00
|
|
|
}
|
2018-11-01 16:46:21 +01:00
|
|
|
env.set_width (has_width);
|
2018-11-01 06:30:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void process_seac (cff1_cs_interp_env_t &env, PARAM& param)
|
2018-11-14 22:38:03 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-12-22 16:47:04 +01:00
|
|
|
static void flush_args (cff1_cs_interp_env_t &env, PARAM& param)
|
2018-08-29 21:14:30 +02:00
|
|
|
{
|
2018-11-01 06:30:34 +01:00
|
|
|
SUPER::flush_args (env, param);
|
2018-10-18 22:04:21 +02:00
|
|
|
env.clear_args (); /* pop off width */
|
2018-08-29 21:14:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-12-22 16:47:04 +01:00
|
|
|
typedef cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH> SUPER;
|
2018-08-15 21:00:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename OPSET, typename PARAM>
|
2018-12-22 16:47:04 +01:00
|
|
|
struct cff1_cs_interpreter_t : cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM> {};
|
2018-08-15 21:00:19 +02:00
|
|
|
|
|
|
|
} /* namespace CFF */
|
|
|
|
|
2018-08-16 09:13:09 +02:00
|
|
|
#endif /* HB_CFF1_INTERP_CS_HH */
|