uncamelize non-table struct names
This commit is contained in:
parent
abebca2690
commit
45e4bf0e8f
|
@ -215,7 +215,7 @@ inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op) ? 2: 1;
|
||||||
#define OpCode_Invalid 0xFFFFu
|
#define OpCode_Invalid 0xFFFFu
|
||||||
|
|
||||||
|
|
||||||
struct Number
|
struct number_t
|
||||||
{
|
{
|
||||||
void init () { set_real (0.0); }
|
void init () { set_real (0.0); }
|
||||||
void fini () {}
|
void fini () {}
|
||||||
|
@ -235,19 +235,19 @@ struct Number
|
||||||
bool in_int_range () const
|
bool in_int_range () const
|
||||||
{ return ((double) (int16_t) to_int () == value); }
|
{ return ((double) (int16_t) to_int () == value); }
|
||||||
|
|
||||||
bool operator > (const Number &n) const
|
bool operator > (const number_t &n) const
|
||||||
{ return value > n.to_real (); }
|
{ return value > n.to_real (); }
|
||||||
|
|
||||||
bool operator < (const Number &n) const
|
bool operator < (const number_t &n) const
|
||||||
{ return n > *this; }
|
{ return n > *this; }
|
||||||
|
|
||||||
bool operator >= (const Number &n) const
|
bool operator >= (const number_t &n) const
|
||||||
{ return !(*this < n); }
|
{ return !(*this < n); }
|
||||||
|
|
||||||
bool operator <= (const Number &n) const
|
bool operator <= (const number_t &n) const
|
||||||
{ return !(*this > n); }
|
{ return !(*this > n); }
|
||||||
|
|
||||||
const Number &operator += (const Number &n)
|
const number_t &operator += (const number_t &n)
|
||||||
{
|
{
|
||||||
set_real (to_real () + n.to_real ());
|
set_real (to_real () + n.to_real ());
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ typedef hb_vector_t<byte_str_t> byte_str_array_t;
|
||||||
|
|
||||||
/* stack */
|
/* stack */
|
||||||
template <typename ELEM, int LIMIT>
|
template <typename ELEM, int LIMIT>
|
||||||
struct Stack
|
struct stack_t
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
|
@ -486,8 +486,8 @@ struct Stack
|
||||||
};
|
};
|
||||||
|
|
||||||
/* argument stack */
|
/* argument stack */
|
||||||
template <typename ARG=Number>
|
template <typename ARG=number_t>
|
||||||
struct ArgStack : Stack<ARG, 513>
|
struct arg_stack_t : stack_t<ARG, 513>
|
||||||
{
|
{
|
||||||
void push_int (int v)
|
void push_int (int v)
|
||||||
{
|
{
|
||||||
|
@ -543,11 +543,11 @@ struct ArgStack : Stack<ARG, 513>
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef Stack<ARG, 513> S;
|
typedef stack_t<ARG, 513> S;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* an operator prefixed by its operands in a byte string */
|
/* an operator prefixed by its operands in a byte string */
|
||||||
struct OpStr
|
struct op_str_t
|
||||||
{
|
{
|
||||||
void init () {}
|
void init () {}
|
||||||
void fini () {}
|
void fini () {}
|
||||||
|
@ -557,10 +557,10 @@ struct OpStr
|
||||||
};
|
};
|
||||||
|
|
||||||
/* base of OP_SERIALIZER */
|
/* base of OP_SERIALIZER */
|
||||||
struct OpSerializer
|
struct op_serializer_t
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
bool copy_opstr (hb_serialize_context_t *c, const OpStr& opstr) const
|
bool copy_opstr (hb_serialize_context_t *c, const op_str_t& opstr) const
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ struct OpSerializer
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename VAL>
|
template <typename VAL>
|
||||||
struct ParsedValues
|
struct parsed_values_t
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
|
@ -612,8 +612,8 @@ struct ParsedValues
|
||||||
hb_vector_t<VAL> values;
|
hb_vector_t<VAL> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ARG=Number>
|
template <typename ARG=number_t>
|
||||||
struct InterpEnv
|
struct interp_env_t
|
||||||
{
|
{
|
||||||
void init (const byte_str_t &str_)
|
void init (const byte_str_t &str_)
|
||||||
{
|
{
|
||||||
|
@ -665,17 +665,17 @@ struct InterpEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
byte_str_ref_t str_ref;
|
byte_str_ref_t str_ref;
|
||||||
ArgStack<ARG> argStack;
|
arg_stack_t<ARG> argStack;
|
||||||
protected:
|
protected:
|
||||||
bool error;
|
bool error;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef InterpEnv<> NumInterpEnv;
|
typedef interp_env_t<> num_interp_env_t;
|
||||||
|
|
||||||
template <typename ARG=Number>
|
template <typename ARG=number_t>
|
||||||
struct OpSet
|
struct opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, InterpEnv<ARG>& env)
|
static void process_op (OpCode op, interp_env_t<ARG>& env)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_shortint:
|
case OpCode_shortint:
|
||||||
|
@ -711,9 +711,9 @@ struct OpSet
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ENV>
|
template <typename ENV>
|
||||||
struct Interpreter {
|
struct interpreter_t {
|
||||||
|
|
||||||
~Interpreter() { fini (); }
|
~interpreter_t() { fini (); }
|
||||||
|
|
||||||
void fini () { env.fini (); }
|
void fini () { env.fini (); }
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ enum CSType {
|
||||||
CSType_LocalSubr
|
CSType_LocalSubr
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CallContext
|
struct call_context_t
|
||||||
{
|
{
|
||||||
void init (const byte_str_ref_t substr_=byte_str_ref_t (), CSType type_=CSType_CharString, unsigned int subr_num_=0)
|
void init (const byte_str_ref_t substr_=byte_str_ref_t (), CSType type_=CSType_CharString, unsigned int subr_num_=0)
|
||||||
{
|
{
|
||||||
|
@ -57,10 +57,10 @@ struct CallContext
|
||||||
|
|
||||||
/* call stack */
|
/* call stack */
|
||||||
const unsigned int kMaxCallLimit = 10;
|
const unsigned int kMaxCallLimit = 10;
|
||||||
struct CallStack : Stack<CallContext, kMaxCallLimit> {};
|
struct call_stack_t : stack_t<call_context_t, kMaxCallLimit> {};
|
||||||
|
|
||||||
template <typename SUBRS>
|
template <typename SUBRS>
|
||||||
struct BiasedSubrs
|
struct biased_subrs_t
|
||||||
{
|
{
|
||||||
void init (const SUBRS &subrs_)
|
void init (const SUBRS &subrs_)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,7 @@ struct BiasedSubrs
|
||||||
const SUBRS *subrs;
|
const SUBRS *subrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Point
|
struct point_t
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
|
@ -106,21 +106,21 @@ struct Point
|
||||||
y.set_int (_y);
|
y.set_int (_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_x (const Number &dx) { x += dx; }
|
void move_x (const number_t &dx) { x += dx; }
|
||||||
void move_y (const Number &dy) { y += dy; }
|
void move_y (const number_t &dy) { y += dy; }
|
||||||
void move (const Number &dx, const Number &dy) { move_x (dx); move_y (dy); }
|
void move (const number_t &dx, const number_t &dy) { move_x (dx); move_y (dy); }
|
||||||
void move (const Point &d) { move_x (d.x); move_y (d.y); }
|
void move (const point_t &d) { move_x (d.x); move_y (d.y); }
|
||||||
|
|
||||||
Number x;
|
number_t x;
|
||||||
Number y;
|
number_t y;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ARG, typename SUBRS>
|
template <typename ARG, typename SUBRS>
|
||||||
struct CSInterpEnv : InterpEnv<ARG>
|
struct cs_interp_env_t : interp_env_t<ARG>
|
||||||
{
|
{
|
||||||
void init (const byte_str_t &str, const SUBRS &globalSubrs_, const SUBRS &localSubrs_)
|
void init (const byte_str_t &str, const SUBRS &globalSubrs_, const SUBRS &localSubrs_)
|
||||||
{
|
{
|
||||||
InterpEnv<ARG>::init (str);
|
interp_env_t<ARG>::init (str);
|
||||||
|
|
||||||
context.init (str, CSType_CharString);
|
context.init (str, CSType_CharString);
|
||||||
seen_moveto = true;
|
seen_moveto = true;
|
||||||
|
@ -134,7 +134,7 @@ struct CSInterpEnv : InterpEnv<ARG>
|
||||||
}
|
}
|
||||||
void fini ()
|
void fini ()
|
||||||
{
|
{
|
||||||
InterpEnv<ARG>::fini ();
|
interp_env_t<ARG>::fini ();
|
||||||
|
|
||||||
callStack.fini ();
|
callStack.fini ();
|
||||||
globalSubrs.fini ();
|
globalSubrs.fini ();
|
||||||
|
@ -146,7 +146,7 @@ struct CSInterpEnv : InterpEnv<ARG>
|
||||||
return callStack.in_error () || SUPER::in_error ();
|
return callStack.in_error () || SUPER::in_error ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool popSubrNum (const BiasedSubrs<SUBRS>& biasedSubrs, unsigned int &subr_num)
|
bool popSubrNum (const biased_subrs_t<SUBRS>& biasedSubrs, unsigned int &subr_num)
|
||||||
{
|
{
|
||||||
int n = SUPER::argStack.pop_int ();
|
int n = SUPER::argStack.pop_int ();
|
||||||
n += biasedSubrs.get_bias ();
|
n += biasedSubrs.get_bias ();
|
||||||
|
@ -157,7 +157,7 @@ struct CSInterpEnv : InterpEnv<ARG>
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void callSubr (const BiasedSubrs<SUBRS>& biasedSubrs, CSType type)
|
void callSubr (const biased_subrs_t<SUBRS>& biasedSubrs, CSType type)
|
||||||
{
|
{
|
||||||
unsigned int subr_num;
|
unsigned int subr_num;
|
||||||
|
|
||||||
|
@ -195,14 +195,14 @@ struct CSInterpEnv : InterpEnv<ARG>
|
||||||
void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; }
|
void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; }
|
||||||
bool is_endchar () const { return endchar_flag; }
|
bool is_endchar () const { return endchar_flag; }
|
||||||
|
|
||||||
const Number &get_x () const { return pt.x; }
|
const number_t &get_x () const { return pt.x; }
|
||||||
const Number &get_y () const { return pt.y; }
|
const number_t &get_y () const { return pt.y; }
|
||||||
const Point &get_pt () const { return pt; }
|
const point_t &get_pt () const { return pt; }
|
||||||
|
|
||||||
void moveto (const Point &pt_ ) { pt = pt_; }
|
void moveto (const point_t &pt_ ) { pt = pt_; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CallContext context;
|
call_context_t context;
|
||||||
bool endchar_flag;
|
bool endchar_flag;
|
||||||
bool seen_moveto;
|
bool seen_moveto;
|
||||||
bool seen_hintmask;
|
bool seen_hintmask;
|
||||||
|
@ -210,18 +210,18 @@ struct CSInterpEnv : InterpEnv<ARG>
|
||||||
unsigned int hstem_count;
|
unsigned int hstem_count;
|
||||||
unsigned int vstem_count;
|
unsigned int vstem_count;
|
||||||
unsigned int hintmask_size;
|
unsigned int hintmask_size;
|
||||||
CallStack callStack;
|
call_stack_t callStack;
|
||||||
BiasedSubrs<SUBRS> globalSubrs;
|
biased_subrs_t<SUBRS> globalSubrs;
|
||||||
BiasedSubrs<SUBRS> localSubrs;
|
biased_subrs_t<SUBRS> localSubrs;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Point pt;
|
point_t pt;
|
||||||
|
|
||||||
typedef InterpEnv<ARG> SUPER;
|
typedef interp_env_t<ARG> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ENV, typename PARAM>
|
template <typename ENV, typename PARAM>
|
||||||
struct PathProcsNull
|
struct path_procs_null_t
|
||||||
{
|
{
|
||||||
static void rmoveto (ENV &env, PARAM& param) {}
|
static void rmoveto (ENV &env, PARAM& param) {}
|
||||||
static void hmoveto (ENV &env, PARAM& param) {}
|
static void hmoveto (ENV &env, PARAM& param) {}
|
||||||
|
@ -236,17 +236,17 @@ struct PathProcsNull
|
||||||
static void hhcurveto (ENV &env, PARAM& param) {}
|
static void hhcurveto (ENV &env, PARAM& param) {}
|
||||||
static void vhcurveto (ENV &env, PARAM& param) {}
|
static void vhcurveto (ENV &env, PARAM& param) {}
|
||||||
static void hvcurveto (ENV &env, PARAM& param) {}
|
static void hvcurveto (ENV &env, PARAM& param) {}
|
||||||
static void moveto (ENV &env, PARAM& param, const Point &pt) {}
|
static void moveto (ENV &env, PARAM& param, const point_t &pt) {}
|
||||||
static void line (ENV &env, PARAM& param, const Point &pt1) {}
|
static void line (ENV &env, PARAM& param, const point_t &pt1) {}
|
||||||
static void curve (ENV &env, PARAM& param, const Point &pt1, const Point &pt2, const Point &pt3) {}
|
static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &pt3) {}
|
||||||
static void hflex (ENV &env, PARAM& param) {}
|
static void hflex (ENV &env, PARAM& param) {}
|
||||||
static void flex (ENV &env, PARAM& param) {}
|
static void flex (ENV &env, PARAM& param) {}
|
||||||
static void hflex1 (ENV &env, PARAM& param) {}
|
static void hflex1 (ENV &env, PARAM& param) {}
|
||||||
static void flex1 (ENV &env, PARAM& param) {}
|
static void flex1 (ENV &env, PARAM& param) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=PathProcsNull<ENV, PARAM> >
|
template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=path_procs_null_t<ENV, PARAM> >
|
||||||
struct CSOpSet : OpSet<ARG>
|
struct cs_opset_t : opset_t<ARG>
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, ENV &env, PARAM& param)
|
static void process_op (OpCode op, ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
|
@ -454,31 +454,31 @@ struct CSOpSet : OpSet<ARG>
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef OpSet<ARG> SUPER;
|
typedef opset_t<ARG> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename PATH, typename ENV, typename PARAM>
|
template <typename PATH, typename ENV, typename PARAM>
|
||||||
struct PathProcs
|
struct path_procs_t
|
||||||
{
|
{
|
||||||
static void rmoveto (ENV &env, PARAM& param)
|
static void rmoveto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
const Number &dy = env.pop_arg ();
|
const number_t &dy = env.pop_arg ();
|
||||||
const Number &dx = env.pop_arg ();
|
const number_t &dx = env.pop_arg ();
|
||||||
pt1.move (dx, dy);
|
pt1.move (dx, dy);
|
||||||
PATH::moveto (env, param, pt1);
|
PATH::moveto (env, param, pt1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hmoveto (ENV &env, PARAM& param)
|
static void hmoveto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move_x (env.pop_arg ());
|
pt1.move_x (env.pop_arg ());
|
||||||
PATH::moveto (env, param, pt1);
|
PATH::moveto (env, param, pt1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vmoveto (ENV &env, PARAM& param)
|
static void vmoveto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move_y (env.pop_arg ());
|
pt1.move_y (env.pop_arg ());
|
||||||
PATH::moveto (env, param, pt1);
|
PATH::moveto (env, param, pt1);
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ struct PathProcs
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i + 2 <= env.argStack.get_count (); i += 2)
|
for (unsigned int i = 0; i + 2 <= env.argStack.get_count (); i += 2)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
PATH::line (env, param, pt1);
|
PATH::line (env, param, pt1);
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ struct PathProcs
|
||||||
|
|
||||||
static void hlineto (ENV &env, PARAM& param)
|
static void hlineto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1;
|
point_t pt1;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
||||||
{
|
{
|
||||||
|
@ -515,7 +515,7 @@ struct PathProcs
|
||||||
|
|
||||||
static void vlineto (ENV &env, PARAM& param)
|
static void vlineto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1;
|
point_t pt1;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
||||||
{
|
{
|
||||||
|
@ -537,11 +537,11 @@ struct PathProcs
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i + 6 <= env.argStack.get_count (); i += 6)
|
for (unsigned int i = 0; i + 6 <= env.argStack.get_count (); i += 6)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
||||||
PATH::curve (env, param, pt1, pt2, pt3);
|
PATH::curve (env, param, pt1, pt2, pt3);
|
||||||
}
|
}
|
||||||
|
@ -552,17 +552,17 @@ struct PathProcs
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (; i + 6 <= env.argStack.get_count (); i += 6)
|
for (; i + 6 <= env.argStack.get_count (); i += 6)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
||||||
PATH::curve (env, param, pt1, pt2, pt3);
|
PATH::curve (env, param, pt1, pt2, pt3);
|
||||||
}
|
}
|
||||||
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
PATH::line (env, param, pt1);
|
PATH::line (env, param, pt1);
|
||||||
}
|
}
|
||||||
|
@ -574,17 +574,17 @@ struct PathProcs
|
||||||
unsigned int line_limit = (env.argStack.get_count () % 6);
|
unsigned int line_limit = (env.argStack.get_count () % 6);
|
||||||
for (; i + 2 <= line_limit; i += 2)
|
for (; i + 2 <= line_limit; i += 2)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
PATH::line (env, param, pt1);
|
PATH::line (env, param, pt1);
|
||||||
}
|
}
|
||||||
for (; i + 6 <= env.argStack.get_count (); i += 6)
|
for (; i + 6 <= env.argStack.get_count (); i += 6)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
||||||
PATH::curve (env, param, pt1, pt2, pt3);
|
PATH::curve (env, param, pt1, pt2, pt3);
|
||||||
}
|
}
|
||||||
|
@ -593,15 +593,15 @@ struct PathProcs
|
||||||
static void vvcurveto (ENV &env, PARAM& param)
|
static void vvcurveto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
if ((env.argStack.get_count () & 1) != 0)
|
if ((env.argStack.get_count () & 1) != 0)
|
||||||
pt1.move_x (env.eval_arg (i++));
|
pt1.move_x (env.eval_arg (i++));
|
||||||
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
||||||
{
|
{
|
||||||
pt1.move_y (env.eval_arg (i));
|
pt1.move_y (env.eval_arg (i));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move_y (env.eval_arg (i+3));
|
pt3.move_y (env.eval_arg (i+3));
|
||||||
PATH::curve (env, param, pt1, pt2, pt3);
|
PATH::curve (env, param, pt1, pt2, pt3);
|
||||||
pt1 = env.get_pt ();
|
pt1 = env.get_pt ();
|
||||||
|
@ -611,15 +611,15 @@ struct PathProcs
|
||||||
static void hhcurveto (ENV &env, PARAM& param)
|
static void hhcurveto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
if ((env.argStack.get_count () & 1) != 0)
|
if ((env.argStack.get_count () & 1) != 0)
|
||||||
pt1.move_y (env.eval_arg (i++));
|
pt1.move_y (env.eval_arg (i++));
|
||||||
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
||||||
{
|
{
|
||||||
pt1.move_x (env.eval_arg (i));
|
pt1.move_x (env.eval_arg (i));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move_x (env.eval_arg (i+3));
|
pt3.move_x (env.eval_arg (i+3));
|
||||||
PATH::curve (env, param, pt1, pt2, pt3);
|
PATH::curve (env, param, pt1, pt2, pt3);
|
||||||
pt1 = env.get_pt ();
|
pt1 = env.get_pt ();
|
||||||
|
@ -628,15 +628,15 @@ struct PathProcs
|
||||||
|
|
||||||
static void vhcurveto (ENV &env, PARAM& param)
|
static void vhcurveto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1, pt2, pt3;
|
point_t pt1, pt2, pt3;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
if ((env.argStack.get_count () % 8) >= 4)
|
if ((env.argStack.get_count () % 8) >= 4)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move_y (env.eval_arg (i));
|
pt1.move_y (env.eval_arg (i));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move_x (env.eval_arg (i+3));
|
pt3.move_x (env.eval_arg (i+3));
|
||||||
i += 4;
|
i += 4;
|
||||||
|
|
||||||
|
@ -689,15 +689,15 @@ struct PathProcs
|
||||||
|
|
||||||
static void hvcurveto (ENV &env, PARAM& param)
|
static void hvcurveto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1, pt2, pt3;
|
point_t pt1, pt2, pt3;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
if ((env.argStack.get_count () % 8) >= 4)
|
if ((env.argStack.get_count () % 8) >= 4)
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move_x (env.eval_arg (i));
|
pt1.move_x (env.eval_arg (i));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move_y (env.eval_arg (i+3));
|
pt3.move_y (env.eval_arg (i+3));
|
||||||
i += 4;
|
i += 4;
|
||||||
|
|
||||||
|
@ -749,31 +749,31 @@ struct PathProcs
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default actions to be overridden */
|
/* default actions to be overridden */
|
||||||
static void moveto (ENV &env, PARAM& param, const Point &pt)
|
static void moveto (ENV &env, PARAM& param, const point_t &pt)
|
||||||
{ env.moveto (pt); }
|
{ env.moveto (pt); }
|
||||||
|
|
||||||
static void line (ENV &env, PARAM& param, const Point &pt1)
|
static void line (ENV &env, PARAM& param, const point_t &pt1)
|
||||||
{ PATH::moveto (env, param, pt1); }
|
{ PATH::moveto (env, param, pt1); }
|
||||||
|
|
||||||
static void curve (ENV &env, PARAM& param, const Point &pt1, const Point &pt2, const Point &pt3)
|
static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
|
||||||
{ PATH::moveto (env, param, pt3); }
|
{ PATH::moveto (env, param, pt3); }
|
||||||
|
|
||||||
static void hflex (ENV &env, PARAM& param)
|
static void hflex (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
if (likely (env.argStack.get_count () == 7))
|
if (likely (env.argStack.get_count () == 7))
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move_x (env.eval_arg (0));
|
pt1.move_x (env.eval_arg (0));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (1), env.eval_arg (2));
|
pt2.move (env.eval_arg (1), env.eval_arg (2));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move_x (env.eval_arg (3));
|
pt3.move_x (env.eval_arg (3));
|
||||||
Point pt4 = pt3;
|
point_t pt4 = pt3;
|
||||||
pt4.move_x (env.eval_arg (4));
|
pt4.move_x (env.eval_arg (4));
|
||||||
Point pt5 = pt4;
|
point_t pt5 = pt4;
|
||||||
pt5.move_x (env.eval_arg (5));
|
pt5.move_x (env.eval_arg (5));
|
||||||
pt5.y = pt1.y;
|
pt5.y = pt1.y;
|
||||||
Point pt6 = pt5;
|
point_t pt6 = pt5;
|
||||||
pt6.move_x (env.eval_arg (6));
|
pt6.move_x (env.eval_arg (6));
|
||||||
|
|
||||||
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
||||||
|
@ -786,17 +786,17 @@ struct PathProcs
|
||||||
{
|
{
|
||||||
if (likely (env.argStack.get_count () == 13))
|
if (likely (env.argStack.get_count () == 13))
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
||||||
Point pt4 = pt3;
|
point_t pt4 = pt3;
|
||||||
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
||||||
Point pt5 = pt4;
|
point_t pt5 = pt4;
|
||||||
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
||||||
Point pt6 = pt5;
|
point_t pt6 = pt5;
|
||||||
pt6.move (env.eval_arg (10), env.eval_arg (11));
|
pt6.move (env.eval_arg (10), env.eval_arg (11));
|
||||||
|
|
||||||
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
||||||
|
@ -809,17 +809,17 @@ struct PathProcs
|
||||||
{
|
{
|
||||||
if (likely (env.argStack.get_count () == 9))
|
if (likely (env.argStack.get_count () == 9))
|
||||||
{
|
{
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move_x (env.eval_arg (4));
|
pt3.move_x (env.eval_arg (4));
|
||||||
Point pt4 = pt3;
|
point_t pt4 = pt3;
|
||||||
pt4.move_x (env.eval_arg (5));
|
pt4.move_x (env.eval_arg (5));
|
||||||
Point pt5 = pt4;
|
point_t pt5 = pt4;
|
||||||
pt5.move (env.eval_arg (6), env.eval_arg (7));
|
pt5.move (env.eval_arg (6), env.eval_arg (7));
|
||||||
Point pt6 = pt5;
|
point_t pt6 = pt5;
|
||||||
pt6.move_x (env.eval_arg (8));
|
pt6.move_x (env.eval_arg (8));
|
||||||
pt6.y = env.get_pt ().y;
|
pt6.y = env.get_pt ().y;
|
||||||
|
|
||||||
|
@ -833,22 +833,22 @@ struct PathProcs
|
||||||
{
|
{
|
||||||
if (likely (env.argStack.get_count () == 11))
|
if (likely (env.argStack.get_count () == 11))
|
||||||
{
|
{
|
||||||
Point d;
|
point_t d;
|
||||||
d.init ();
|
d.init ();
|
||||||
for (unsigned int i = 0; i < 10; i += 2)
|
for (unsigned int i = 0; i < 10; i += 2)
|
||||||
d.move (env.eval_arg (i), env.eval_arg (i+1));
|
d.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
|
|
||||||
Point pt1 = env.get_pt ();
|
point_t pt1 = env.get_pt ();
|
||||||
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
||||||
Point pt2 = pt1;
|
point_t pt2 = pt1;
|
||||||
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
||||||
Point pt3 = pt2;
|
point_t pt3 = pt2;
|
||||||
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
||||||
Point pt4 = pt3;
|
point_t pt4 = pt3;
|
||||||
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
||||||
Point pt5 = pt4;
|
point_t pt5 = pt4;
|
||||||
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
||||||
Point pt6 = pt5;
|
point_t pt6 = pt5;
|
||||||
|
|
||||||
if (fabs (d.x.to_real ()) > fabs (d.y.to_real ()))
|
if (fabs (d.x.to_real ()) > fabs (d.y.to_real ()))
|
||||||
{
|
{
|
||||||
|
@ -869,8 +869,8 @@ struct PathProcs
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void curve2 (ENV &env, PARAM& param,
|
static void curve2 (ENV &env, PARAM& param,
|
||||||
const Point &pt1, const Point &pt2, const Point &pt3,
|
const point_t &pt1, const point_t &pt2, const point_t &pt3,
|
||||||
const Point &pt4, const Point &pt5, const Point &pt6)
|
const point_t &pt4, const point_t &pt5, const point_t &pt6)
|
||||||
{
|
{
|
||||||
PATH::curve (env, param, pt1, pt2, pt3);
|
PATH::curve (env, param, pt1, pt2, pt3);
|
||||||
PATH::curve (env, param, pt4, pt5, pt6);
|
PATH::curve (env, param, pt4, pt5, pt6);
|
||||||
|
@ -878,7 +878,7 @@ struct PathProcs
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ENV, typename OPSET, typename PARAM>
|
template <typename ENV, typename OPSET, typename PARAM>
|
||||||
struct CSInterpreter : Interpreter<ENV>
|
struct cs_interpreter_t : interpreter_t<ENV>
|
||||||
{
|
{
|
||||||
bool interpret (PARAM& param)
|
bool interpret (PARAM& param)
|
||||||
{
|
{
|
||||||
|
@ -896,7 +896,7 @@ struct CSInterpreter : Interpreter<ENV>
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef Interpreter<ENV> SUPER;
|
typedef interpreter_t<ENV> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace CFF */
|
} /* namespace CFF */
|
||||||
|
|
|
@ -35,28 +35,28 @@ namespace CFF {
|
||||||
using namespace OT;
|
using namespace OT;
|
||||||
|
|
||||||
/* an opstr and the parsed out dict value(s) */
|
/* an opstr and the parsed out dict value(s) */
|
||||||
struct DictVal : OpStr
|
struct dict_val_t : op_str_t
|
||||||
{
|
{
|
||||||
void init () { single_val.set_int (0); }
|
void init () { single_val.set_int (0); }
|
||||||
void fini () {}
|
void fini () {}
|
||||||
|
|
||||||
Number single_val;
|
number_t single_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef DictVal NumDictVal;
|
typedef dict_val_t num_dict_val_t;
|
||||||
|
|
||||||
template <typename VAL> struct DictValues : ParsedValues<VAL> {};
|
template <typename VAL> struct dict_values_t : parsed_values_t<VAL> {};
|
||||||
|
|
||||||
template <typename OPSTR=OpStr>
|
template <typename OPSTR=op_str_t>
|
||||||
struct TopDictValues : DictValues<OPSTR>
|
struct top_dict_values_t : dict_values_t<OPSTR>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
DictValues<OPSTR>::init ();
|
dict_values_t<OPSTR>::init ();
|
||||||
charStringsOffset = 0;
|
charStringsOffset = 0;
|
||||||
FDArrayOffset = 0;
|
FDArrayOffset = 0;
|
||||||
}
|
}
|
||||||
void fini () { DictValues<OPSTR>::fini (); }
|
void fini () { dict_values_t<OPSTR>::fini (); }
|
||||||
|
|
||||||
unsigned int calculate_serialized_op_size (const OPSTR& opstr) const
|
unsigned int calculate_serialized_op_size (const OPSTR& opstr) const
|
||||||
{
|
{
|
||||||
|
@ -75,9 +75,9 @@ struct TopDictValues : DictValues<OPSTR>
|
||||||
unsigned int FDArrayOffset;
|
unsigned int FDArrayOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DictOpSet : OpSet<Number>
|
struct dict_opset_t : opset_t<number_t>
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, InterpEnv<Number>& env)
|
static void process_op (OpCode op, interp_env_t<number_t>& env)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_longintdict: /* 5-byte integer */
|
case OpCode_longintdict: /* 5-byte integer */
|
||||||
|
@ -89,7 +89,7 @@ struct DictOpSet : OpSet<Number>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
OpSet<Number>::process_op (op, env);
|
opset_t<number_t>::process_op (op, env);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,10 +245,10 @@ struct DictOpSet : OpSet<Number>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename VAL=OpStr>
|
template <typename VAL=op_str_t>
|
||||||
struct TopDictOpSet : DictOpSet
|
struct top_dict_opset_t : dict_opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, InterpEnv<Number>& env, TopDictValues<VAL> & dictval)
|
static void process_op (OpCode op, interp_env_t<number_t>& env, top_dict_values_t<VAL> & dictval)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_CharStrings:
|
case OpCode_CharStrings:
|
||||||
|
@ -263,14 +263,14 @@ struct TopDictOpSet : DictOpSet
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DictOpSet::process_op (op, env);
|
dict_opset_t::process_op (op, env);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename OPSET, typename PARAM, typename ENV=NumInterpEnv>
|
template <typename OPSET, typename PARAM, typename ENV=num_interp_env_t>
|
||||||
struct DictInterpreter : Interpreter<ENV>
|
struct dict_interpreter_t : interpreter_t<ENV>
|
||||||
{
|
{
|
||||||
bool interpret (PARAM& param)
|
bool interpret (PARAM& param)
|
||||||
{
|
{
|
||||||
|
@ -286,7 +286,7 @@ struct DictInterpreter : Interpreter<ENV>
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef Interpreter<ENV> SUPER;
|
typedef interpreter_t<ENV> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace CFF */
|
} /* namespace CFF */
|
||||||
|
|
|
@ -33,9 +33,9 @@ namespace CFF {
|
||||||
|
|
||||||
using namespace OT;
|
using namespace OT;
|
||||||
|
|
||||||
typedef BiasedSubrs<CFF1Subrs> CFF1BiasedSubrs;
|
typedef biased_subrs_t<CFF1Subrs> cff1_biased_subrs_t;
|
||||||
|
|
||||||
struct CFF1CSInterpEnv : CSInterpEnv<Number, CFF1Subrs>
|
struct cff1_cs_interp_env_t : cs_interp_env_t<number_t, CFF1Subrs>
|
||||||
{
|
{
|
||||||
template <typename ACC>
|
template <typename ACC>
|
||||||
void init (const byte_str_t &str, ACC &acc, unsigned int fd)
|
void init (const byte_str_t &str, ACC &acc, unsigned int fd)
|
||||||
|
@ -74,20 +74,20 @@ struct CFF1CSInterpEnv : CSInterpEnv<Number, CFF1Subrs>
|
||||||
bool processed_width;
|
bool processed_width;
|
||||||
bool has_width;
|
bool has_width;
|
||||||
unsigned int arg_start;
|
unsigned int arg_start;
|
||||||
Number width;
|
number_t width;
|
||||||
bool in_seac;
|
bool in_seac;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CSInterpEnv<Number, CFF1Subrs> SUPER;
|
typedef cs_interp_env_t<number_t, CFF1Subrs> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename OPSET, typename PARAM, typename PATH=PathProcsNull<CFF1CSInterpEnv, PARAM> >
|
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM> >
|
||||||
struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH>
|
struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
|
||||||
{
|
{
|
||||||
/* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
|
/* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
|
||||||
/* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */
|
/* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */
|
||||||
|
|
||||||
static void process_op (OpCode op, CFF1CSInterpEnv &env, PARAM& param)
|
static void process_op (OpCode op, cff1_cs_interp_env_t &env, PARAM& param)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_dotsection:
|
case OpCode_dotsection:
|
||||||
|
@ -109,7 +109,7 @@ struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_width (OpCode op, CFF1CSInterpEnv &env, PARAM& param)
|
static void check_width (OpCode op, cff1_cs_interp_env_t &env, PARAM& param)
|
||||||
{
|
{
|
||||||
if (!env.processed_width)
|
if (!env.processed_width)
|
||||||
{
|
{
|
||||||
|
@ -139,22 +139,22 @@ struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_seac (CFF1CSInterpEnv &env, PARAM& param)
|
static void process_seac (cff1_cs_interp_env_t &env, PARAM& param)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_args (CFF1CSInterpEnv &env, PARAM& param)
|
static void flush_args (cff1_cs_interp_env_t &env, PARAM& param)
|
||||||
{
|
{
|
||||||
SUPER::flush_args (env, param);
|
SUPER::flush_args (env, param);
|
||||||
env.clear_args (); /* pop off width */
|
env.clear_args (); /* pop off width */
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH> SUPER;
|
typedef cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename OPSET, typename PARAM>
|
template <typename OPSET, typename PARAM>
|
||||||
struct CFF1CSInterpreter : CSInterpreter<CFF1CSInterpEnv, OPSET, PARAM> {};
|
struct cff1_cs_interpreter_t : cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM> {};
|
||||||
|
|
||||||
} /* namespace CFF */
|
} /* namespace CFF */
|
||||||
|
|
||||||
|
|
|
@ -33,26 +33,26 @@ namespace CFF {
|
||||||
|
|
||||||
using namespace OT;
|
using namespace OT;
|
||||||
|
|
||||||
struct BlendArg : Number
|
struct blend_arg_t : number_t
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
Number::init ();
|
number_t::init ();
|
||||||
deltas.init ();
|
deltas.init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fini ()
|
void fini ()
|
||||||
{
|
{
|
||||||
Number::fini ();
|
number_t::fini ();
|
||||||
deltas.fini_deep ();
|
deltas.fini_deep ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_int (int v) { reset_blends (); Number::set_int (v); }
|
void set_int (int v) { reset_blends (); number_t::set_int (v); }
|
||||||
void set_fixed (int32_t v) { reset_blends (); Number::set_fixed (v); }
|
void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); }
|
||||||
void set_real (double v) { reset_blends (); Number::set_real (v); }
|
void set_real (double v) { reset_blends (); number_t::set_real (v); }
|
||||||
|
|
||||||
void set_blends (unsigned int numValues_, unsigned int valueIndex_,
|
void set_blends (unsigned int numValues_, unsigned int valueIndex_,
|
||||||
unsigned int numBlends, hb_array_t<const BlendArg> blends_)
|
unsigned int numBlends, hb_array_t<const blend_arg_t> blends_)
|
||||||
{
|
{
|
||||||
numValues = numValues_;
|
numValues = numValues_;
|
||||||
valueIndex = valueIndex_;
|
valueIndex = valueIndex_;
|
||||||
|
@ -70,13 +70,13 @@ struct BlendArg : Number
|
||||||
|
|
||||||
unsigned int numValues;
|
unsigned int numValues;
|
||||||
unsigned int valueIndex;
|
unsigned int valueIndex;
|
||||||
hb_vector_t<Number> deltas;
|
hb_vector_t<number_t> deltas;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef InterpEnv<BlendArg> BlendInterpEnv;
|
typedef interp_env_t<blend_arg_t> BlendInterpEnv;
|
||||||
typedef BiasedSubrs<CFF2Subrs> CFF2BiasedSubrs;
|
typedef biased_subrs_t<CFF2Subrs> cff2_biased_subrs_t;
|
||||||
|
|
||||||
struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
|
struct cff2_cs_interp_env_t : cs_interp_env_t<blend_arg_t, CFF2Subrs>
|
||||||
{
|
{
|
||||||
template <typename ACC>
|
template <typename ACC>
|
||||||
void init (const byte_str_t &str, ACC &acc, unsigned int fd,
|
void init (const byte_str_t &str, ACC &acc, unsigned int fd,
|
||||||
|
@ -112,16 +112,16 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
|
||||||
return OpCode_return;
|
return OpCode_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlendArg& eval_arg (unsigned int i)
|
const blend_arg_t& eval_arg (unsigned int i)
|
||||||
{
|
{
|
||||||
BlendArg &arg = argStack[i];
|
blend_arg_t &arg = argStack[i];
|
||||||
blend_arg (arg);
|
blend_arg (arg);
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlendArg& pop_arg ()
|
const blend_arg_t& pop_arg ()
|
||||||
{
|
{
|
||||||
BlendArg &arg = argStack.pop ();
|
blend_arg_t &arg = argStack.pop ();
|
||||||
blend_arg (arg);
|
blend_arg (arg);
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
|
||||||
bool seen_vsindex () const { return seen_vsindex_; }
|
bool seen_vsindex () const { return seen_vsindex_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void blend_arg (BlendArg &arg)
|
void blend_arg (blend_arg_t &arg)
|
||||||
{
|
{
|
||||||
if (do_blend && arg.blending ())
|
if (do_blend && arg.blending ())
|
||||||
{
|
{
|
||||||
|
@ -191,12 +191,12 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
|
||||||
bool seen_vsindex_;
|
bool seen_vsindex_;
|
||||||
bool seen_blend;
|
bool seen_blend;
|
||||||
|
|
||||||
typedef CSInterpEnv<BlendArg, CFF2Subrs> SUPER;
|
typedef cs_interp_env_t<blend_arg_t, CFF2Subrs> SUPER;
|
||||||
};
|
};
|
||||||
template <typename OPSET, typename PARAM, typename PATH=PathProcsNull<CFF2CSInterpEnv, PARAM> >
|
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff2_cs_interp_env_t, PARAM> >
|
||||||
struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
|
struct cff2_cs_opset_t : cs_opset_t<blend_arg_t, OPSET, cff2_cs_interp_env_t, PARAM, PATH>
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, CFF2CSInterpEnv &env, PARAM& param)
|
static void process_op (OpCode op, cff2_cs_interp_env_t &env, PARAM& param)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_callsubr:
|
case OpCode_callsubr:
|
||||||
|
@ -228,7 +228,7 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_blend (CFF2CSInterpEnv &env, PARAM& param)
|
static void process_blend (cff2_cs_interp_env_t &env, PARAM& param)
|
||||||
{
|
{
|
||||||
unsigned int n, k;
|
unsigned int n, k;
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < n; i++)
|
for (unsigned int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
const hb_array_t<const BlendArg> blends = env.argStack.get_subarray (start + n + (i * k));
|
const hb_array_t<const blend_arg_t> blends = env.argStack.get_subarray (start + n + (i * k));
|
||||||
env.argStack[start + i].set_blends (n, i, k, blends);
|
env.argStack[start + i].set_blends (n, i, k, blends);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,18 +253,18 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
|
||||||
env.argStack.pop (k * n);
|
env.argStack.pop (k * n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_vsindex (CFF2CSInterpEnv &env, PARAM& param)
|
static void process_vsindex (cff2_cs_interp_env_t &env, PARAM& param)
|
||||||
{
|
{
|
||||||
env.process_vsindex ();
|
env.process_vsindex ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH> SUPER;
|
typedef cs_opset_t<blend_arg_t, OPSET, cff2_cs_interp_env_t, PARAM, PATH> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename OPSET, typename PARAM>
|
template <typename OPSET, typename PARAM>
|
||||||
struct CFF2CSInterpreter : CSInterpreter<CFF2CSInterpEnv, OPSET, PARAM> {};
|
struct cff2_cs_interpreter_t : cs_interpreter_t<cff2_cs_interp_env_t, OPSET, PARAM> {};
|
||||||
|
|
||||||
} /* namespace CFF */
|
} /* namespace CFF */
|
||||||
|
|
||||||
|
|
|
@ -55,14 +55,14 @@ inline unsigned int calcOffSize(unsigned int dataSize)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct code_pair
|
struct code_pair_t
|
||||||
{
|
{
|
||||||
hb_codepoint_t code;
|
hb_codepoint_t code;
|
||||||
hb_codepoint_t glyph;
|
hb_codepoint_t glyph;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef hb_vector_t<unsigned char, 1> StrBuff;
|
typedef hb_vector_t<unsigned char, 1> str_buff_t;
|
||||||
struct StrBuffArray : hb_vector_t<StrBuff>
|
struct str_buff_vec_t : hb_vector_t<str_buff_t>
|
||||||
{
|
{
|
||||||
void fini () { SUPER::fini_deep (); }
|
void fini () { SUPER::fini_deep (); }
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ struct StrBuffArray : hb_vector_t<StrBuff>
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef hb_vector_t<StrBuff> SUPER;
|
typedef hb_vector_t<str_buff_t> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* CFF INDEX */
|
/* CFF INDEX */
|
||||||
|
@ -160,7 +160,7 @@ struct CFFIndex
|
||||||
|
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
unsigned int offSize_,
|
unsigned int offSize_,
|
||||||
const StrBuffArray &buffArray)
|
const str_buff_vec_t &buffArray)
|
||||||
{
|
{
|
||||||
byte_str_array_t byteArray;
|
byte_str_array_t byteArray;
|
||||||
byteArray.init ();
|
byteArray.init ();
|
||||||
|
@ -405,7 +405,7 @@ struct TopDict : Dict {};
|
||||||
struct FontDict : Dict {};
|
struct FontDict : Dict {};
|
||||||
struct PrivateDict : Dict {};
|
struct PrivateDict : Dict {};
|
||||||
|
|
||||||
struct TableInfo
|
struct table_info_t
|
||||||
{
|
{
|
||||||
void init () { offSize = offset = size = 0; }
|
void init () { offSize = offset = size = 0; }
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ struct TableInfo
|
||||||
|
|
||||||
/* used to remap font index or SID from fullset to subset.
|
/* used to remap font index or SID from fullset to subset.
|
||||||
* set to CFF_UNDEF_CODE if excluded from subset */
|
* set to CFF_UNDEF_CODE if excluded from subset */
|
||||||
struct Remap : hb_vector_t<hb_codepoint_t>
|
struct remap_t : hb_vector_t<hb_codepoint_t>
|
||||||
{
|
{
|
||||||
void init () { SUPER::init (); }
|
void init () { SUPER::init (); }
|
||||||
|
|
||||||
|
@ -508,9 +508,9 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
|
||||||
unsigned int offSize_,
|
unsigned int offSize_,
|
||||||
const hb_vector_t<DICTVAL> &fontDicts,
|
const hb_vector_t<DICTVAL> &fontDicts,
|
||||||
unsigned int fdCount,
|
unsigned int fdCount,
|
||||||
const Remap &fdmap,
|
const remap_t &fdmap,
|
||||||
OP_SERIALIZER& opszr,
|
OP_SERIALIZER& opszr,
|
||||||
const hb_vector_t<TableInfo> &privateInfos)
|
const hb_vector_t<table_info_t> &privateInfos)
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
if (unlikely (!c->extend_min (*this))) return_trace (false);
|
if (unlikely (!c->extend_min (*this))) return_trace (false);
|
||||||
|
@ -546,7 +546,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
|
||||||
static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */,
|
static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */,
|
||||||
const hb_vector_t<DICTVAL> &fontDicts,
|
const hb_vector_t<DICTVAL> &fontDicts,
|
||||||
unsigned int fdCount,
|
unsigned int fdCount,
|
||||||
const Remap &fdmap,
|
const remap_t &fdmap,
|
||||||
OP_SERIALIZER& opszr)
|
OP_SERIALIZER& opszr)
|
||||||
{
|
{
|
||||||
unsigned int dictsSize = 0;
|
unsigned int dictsSize = 0;
|
||||||
|
|
|
@ -161,7 +161,7 @@ hb_codepoint_t OT::cff1::lookup_standard_encoding_for_sid (hb_codepoint_t code)
|
||||||
return CFF_UNDEF_SID;
|
return CFF_UNDEF_SID;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Bounds
|
struct bounds_t
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ struct Bounds
|
||||||
max.set_int (-0x80000000, -0x80000000);
|
max.set_int (-0x80000000, -0x80000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update (const Point &pt)
|
void update (const point_t &pt)
|
||||||
{
|
{
|
||||||
if (pt.x < min.x) min.x = pt.x;
|
if (pt.x < min.x) min.x = pt.x;
|
||||||
if (pt.x > max.x) max.x = pt.x;
|
if (pt.x > max.x) max.x = pt.x;
|
||||||
|
@ -177,7 +177,7 @@ struct Bounds
|
||||||
if (pt.y > max.y) max.y = pt.y;
|
if (pt.y > max.y) max.y = pt.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void merge (const Bounds &b)
|
void merge (const bounds_t &b)
|
||||||
{
|
{
|
||||||
if (empty ())
|
if (empty ())
|
||||||
*this = b;
|
*this = b;
|
||||||
|
@ -190,7 +190,7 @@ struct Bounds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void offset (const Point &delta)
|
void offset (const point_t &delta)
|
||||||
{
|
{
|
||||||
if (!empty ())
|
if (!empty ())
|
||||||
{
|
{
|
||||||
|
@ -202,11 +202,11 @@ struct Bounds
|
||||||
bool empty () const
|
bool empty () const
|
||||||
{ return (min.x >= max.x) || (min.y >= max.y); }
|
{ return (min.x >= max.x) || (min.y >= max.y); }
|
||||||
|
|
||||||
Point min;
|
point_t min;
|
||||||
Point max;
|
point_t max;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ExtentsParam
|
struct extents_param_t
|
||||||
{
|
{
|
||||||
void init (const OT::cff1::accelerator_t *_cff)
|
void init (const OT::cff1::accelerator_t *_cff)
|
||||||
{
|
{
|
||||||
|
@ -220,20 +220,20 @@ struct ExtentsParam
|
||||||
bool is_path_open () const { return path_open; }
|
bool is_path_open () const { return path_open; }
|
||||||
|
|
||||||
bool path_open;
|
bool path_open;
|
||||||
Bounds bounds;
|
bounds_t bounds;
|
||||||
|
|
||||||
const OT::cff1::accelerator_t *cff;
|
const OT::cff1::accelerator_t *cff;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv, ExtentsParam>
|
struct cff1_path_procs_extents_t : path_procs_t<cff1_path_procs_extents_t, cff1_cs_interp_env_t, extents_param_t>
|
||||||
{
|
{
|
||||||
static void moveto (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt)
|
static void moveto (cff1_cs_interp_env_t &env, extents_param_t& param, const point_t &pt)
|
||||||
{
|
{
|
||||||
param.end_path ();
|
param.end_path ();
|
||||||
env.moveto (pt);
|
env.moveto (pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void line (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1)
|
static void line (cff1_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1)
|
||||||
{
|
{
|
||||||
if (!param.is_path_open ())
|
if (!param.is_path_open ())
|
||||||
{
|
{
|
||||||
|
@ -244,7 +244,7 @@ struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv,
|
||||||
param.bounds.update (env.get_pt ());
|
param.bounds.update (env.get_pt ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void curve (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1, const Point &pt2, const Point &pt3)
|
static void curve (cff1_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
|
||||||
{
|
{
|
||||||
if (!param.is_path_open ())
|
if (!param.is_path_open ())
|
||||||
{
|
{
|
||||||
|
@ -259,20 +259,20 @@ struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Bounds &bounds, bool in_seac=false);
|
static bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, bounds_t &bounds, bool in_seac=false);
|
||||||
|
|
||||||
struct CFF1CSOpSet_Extents : CFF1CSOpSet<CFF1CSOpSet_Extents, ExtentsParam, CFF1PathProcs_Extents>
|
struct cff1_cs_opset_extents_t : cff1_cs_opset_t<cff1_cs_opset_extents_t, extents_param_t, cff1_path_procs_extents_t>
|
||||||
{
|
{
|
||||||
static void process_seac (CFF1CSInterpEnv &env, ExtentsParam& param)
|
static void process_seac (cff1_cs_interp_env_t &env, extents_param_t& param)
|
||||||
{
|
{
|
||||||
unsigned int n = env.argStack.get_count ();
|
unsigned int n = env.argStack.get_count ();
|
||||||
Point delta;
|
point_t delta;
|
||||||
delta.x = env.argStack[n-4];
|
delta.x = env.argStack[n-4];
|
||||||
delta.y = env.argStack[n-3];
|
delta.y = env.argStack[n-3];
|
||||||
hb_codepoint_t base = param.cff->std_code_to_glyph (env.argStack[n-2].to_int ());
|
hb_codepoint_t base = param.cff->std_code_to_glyph (env.argStack[n-2].to_int ());
|
||||||
hb_codepoint_t accent = param.cff->std_code_to_glyph (env.argStack[n-1].to_int ());
|
hb_codepoint_t accent = param.cff->std_code_to_glyph (env.argStack[n-1].to_int ());
|
||||||
|
|
||||||
Bounds base_bounds, accent_bounds;
|
bounds_t base_bounds, accent_bounds;
|
||||||
if (likely (!env.in_seac && base && accent
|
if (likely (!env.in_seac && base && accent
|
||||||
&& _get_bounds (param.cff, base, base_bounds, true)
|
&& _get_bounds (param.cff, base, base_bounds, true)
|
||||||
&& _get_bounds (param.cff, accent, accent_bounds, true)))
|
&& _get_bounds (param.cff, accent, accent_bounds, true)))
|
||||||
|
@ -286,17 +286,17 @@ struct CFF1CSOpSet_Extents : CFF1CSOpSet<CFF1CSOpSet_Extents, ExtentsParam, CFF1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Bounds &bounds, bool in_seac)
|
bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, bounds_t &bounds, bool in_seac)
|
||||||
{
|
{
|
||||||
bounds.init ();
|
bounds.init ();
|
||||||
if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false;
|
if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false;
|
||||||
|
|
||||||
unsigned int fd = cff->fdSelect->get_fd (glyph);
|
unsigned int fd = cff->fdSelect->get_fd (glyph);
|
||||||
CFF1CSInterpreter<CFF1CSOpSet_Extents, ExtentsParam> interp;
|
cff1_cs_interpreter_t<cff1_cs_opset_extents_t, extents_param_t> interp;
|
||||||
const byte_str_t str = (*cff->charStrings)[glyph];
|
const byte_str_t str = (*cff->charStrings)[glyph];
|
||||||
interp.env.init (str, *cff, fd);
|
interp.env.init (str, *cff, fd);
|
||||||
interp.env.set_in_seac (in_seac);
|
interp.env.set_in_seac (in_seac);
|
||||||
ExtentsParam param;
|
extents_param_t param;
|
||||||
param.init (cff);
|
param.init (cff);
|
||||||
if (unlikely (!interp.interpret (param))) return false;
|
if (unlikely (!interp.interpret (param))) return false;
|
||||||
bounds = param.bounds;
|
bounds = param.bounds;
|
||||||
|
@ -305,7 +305,7 @@ bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Boun
|
||||||
|
|
||||||
bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
|
bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
|
||||||
{
|
{
|
||||||
Bounds bounds;
|
bounds_t bounds;
|
||||||
|
|
||||||
if (!_get_bounds (this, glyph, bounds))
|
if (!_get_bounds (this, glyph, bounds))
|
||||||
return false;
|
return false;
|
||||||
|
@ -334,7 +334,7 @@ bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extent
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GetSeacParam
|
struct get_seac_param_t
|
||||||
{
|
{
|
||||||
void init (const OT::cff1::accelerator_t *_cff)
|
void init (const OT::cff1::accelerator_t *_cff)
|
||||||
{
|
{
|
||||||
|
@ -350,9 +350,9 @@ struct GetSeacParam
|
||||||
hb_codepoint_t accent;
|
hb_codepoint_t accent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1CSOpSet_Seac : CFF1CSOpSet<CFF1CSOpSet_Seac, GetSeacParam>
|
struct cff1_cs_opset_seac_t : cff1_cs_opset_t<cff1_cs_opset_seac_t, get_seac_param_t>
|
||||||
{
|
{
|
||||||
static void process_seac (CFF1CSInterpEnv &env, GetSeacParam& param)
|
static void process_seac (cff1_cs_interp_env_t &env, get_seac_param_t& param)
|
||||||
{
|
{
|
||||||
unsigned int n = env.argStack.get_count ();
|
unsigned int n = env.argStack.get_count ();
|
||||||
hb_codepoint_t base_char = (hb_codepoint_t)env.argStack[n-2].to_int ();
|
hb_codepoint_t base_char = (hb_codepoint_t)env.argStack[n-2].to_int ();
|
||||||
|
@ -368,10 +368,10 @@ bool OT::cff1::accelerator_t::get_seac_components (hb_codepoint_t glyph, hb_code
|
||||||
if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false;
|
if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false;
|
||||||
|
|
||||||
unsigned int fd = fdSelect->get_fd (glyph);
|
unsigned int fd = fdSelect->get_fd (glyph);
|
||||||
CFF1CSInterpreter<CFF1CSOpSet_Seac, GetSeacParam> interp;
|
cff1_cs_interpreter_t<cff1_cs_opset_seac_t, get_seac_param_t> interp;
|
||||||
const byte_str_t str = (*charStrings)[glyph];
|
const byte_str_t str = (*charStrings)[glyph];
|
||||||
interp.env.init (str, *this, fd);
|
interp.env.init (str, *this, fd);
|
||||||
GetSeacParam param;
|
get_seac_param_t param;
|
||||||
param.init (this);
|
param.init (this);
|
||||||
if (unlikely (!interp.interpret (param))) return false;
|
if (unlikely (!interp.interpret (param))) return false;
|
||||||
|
|
||||||
|
|
|
@ -193,8 +193,8 @@ struct Encoding {
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
uint8_t format,
|
uint8_t format,
|
||||||
unsigned int enc_count,
|
unsigned int enc_count,
|
||||||
const hb_vector_t<code_pair>& code_ranges,
|
const hb_vector_t<code_pair_t>& code_ranges,
|
||||||
const hb_vector_t<code_pair>& supp_codes)
|
const hb_vector_t<code_pair_t>& supp_codes)
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
Encoding *dest = c->extend_min (*this);
|
Encoding *dest = c->extend_min (*this);
|
||||||
|
@ -467,7 +467,7 @@ struct Charset {
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
uint8_t format,
|
uint8_t format,
|
||||||
unsigned int num_glyphs,
|
unsigned int num_glyphs,
|
||||||
const hb_vector_t<code_pair>& sid_ranges)
|
const hb_vector_t<code_pair_t>& sid_ranges)
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
Charset *dest = c->extend_min (*this);
|
Charset *dest = c->extend_min (*this);
|
||||||
|
@ -573,7 +573,7 @@ struct Charset {
|
||||||
struct CFF1StringIndex : CFF1Index
|
struct CFF1StringIndex : CFF1Index
|
||||||
{
|
{
|
||||||
bool serialize (hb_serialize_context_t *c, const CFF1StringIndex &strings,
|
bool serialize (hb_serialize_context_t *c, const CFF1StringIndex &strings,
|
||||||
unsigned int offSize_, const Remap &sidmap)
|
unsigned int offSize_, const remap_t &sidmap)
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0)))
|
if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0)))
|
||||||
|
@ -601,7 +601,7 @@ struct CFF1StringIndex : CFF1Index
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in parallel to above */
|
/* in parallel to above */
|
||||||
unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const Remap &sidmap) const
|
unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const remap_t &sidmap) const
|
||||||
{
|
{
|
||||||
offSize = 0;
|
offSize = 0;
|
||||||
if ((count == 0) || (sidmap.get_count () == 0))
|
if ((count == 0) || (sidmap.get_count () == 0))
|
||||||
|
@ -617,16 +617,16 @@ struct CFF1StringIndex : CFF1Index
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1TopDictInterpEnv : NumInterpEnv
|
struct cff1_top_dict_interp_env_t : num_interp_env_t
|
||||||
{
|
{
|
||||||
CFF1TopDictInterpEnv ()
|
cff1_top_dict_interp_env_t ()
|
||||||
: NumInterpEnv(), prev_offset(0), last_offset(0) {}
|
: num_interp_env_t(), prev_offset(0), last_offset(0) {}
|
||||||
|
|
||||||
unsigned int prev_offset;
|
unsigned int prev_offset;
|
||||||
unsigned int last_offset;
|
unsigned int last_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NameDictValues
|
struct name_dict_values_t
|
||||||
{
|
{
|
||||||
enum NameDictValIndex
|
enum NameDictValIndex
|
||||||
{
|
{
|
||||||
|
@ -685,16 +685,16 @@ struct NameDictValues
|
||||||
unsigned int values[ValCount];
|
unsigned int values[ValCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1TopDictVal : OpStr
|
struct cff1_top_dict_val_t : op_str_t
|
||||||
{
|
{
|
||||||
unsigned int last_arg_offset;
|
unsigned int last_arg_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal>
|
struct cff1_top_dict_values_t : top_dict_values_t<cff1_top_dict_val_t>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
TopDictValues<CFF1TopDictVal>::init ();
|
top_dict_values_t<cff1_top_dict_val_t>::init ();
|
||||||
|
|
||||||
nameSIDs.init ();
|
nameSIDs.init ();
|
||||||
ros_supplement = 0;
|
ros_supplement = 0;
|
||||||
|
@ -704,12 +704,12 @@ struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal>
|
||||||
FDSelectOffset = 0;
|
FDSelectOffset = 0;
|
||||||
privateDictInfo.init ();
|
privateDictInfo.init ();
|
||||||
}
|
}
|
||||||
void fini () { TopDictValues<CFF1TopDictVal>::fini (); }
|
void fini () { top_dict_values_t<cff1_top_dict_val_t>::fini (); }
|
||||||
|
|
||||||
bool is_CID () const
|
bool is_CID () const
|
||||||
{ return nameSIDs[NameDictValues::registry] != CFF_UNDEF_SID; }
|
{ return nameSIDs[name_dict_values_t::registry] != CFF_UNDEF_SID; }
|
||||||
|
|
||||||
NameDictValues nameSIDs;
|
name_dict_values_t nameSIDs;
|
||||||
unsigned int ros_supplement_offset;
|
unsigned int ros_supplement_offset;
|
||||||
unsigned int ros_supplement;
|
unsigned int ros_supplement;
|
||||||
unsigned int cidCount;
|
unsigned int cidCount;
|
||||||
|
@ -717,14 +717,14 @@ struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal>
|
||||||
unsigned int EncodingOffset;
|
unsigned int EncodingOffset;
|
||||||
unsigned int CharsetOffset;
|
unsigned int CharsetOffset;
|
||||||
unsigned int FDSelectOffset;
|
unsigned int FDSelectOffset;
|
||||||
TableInfo privateDictInfo;
|
table_info_t privateDictInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
|
struct cff1_top_dict_opset_t : top_dict_opset_t<cff1_top_dict_val_t>
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, CFF1TopDictInterpEnv& env, CFF1TopDictValues& dictval)
|
static void process_op (OpCode op, cff1_top_dict_interp_env_t& env, cff1_top_dict_values_t& dictval)
|
||||||
{
|
{
|
||||||
CFF1TopDictVal val;
|
cff1_top_dict_val_t val;
|
||||||
val.last_arg_offset = (env.last_offset-1) - dictval.opStart; /* offset to the last argument */
|
val.last_arg_offset = (env.last_offset-1) - dictval.opStart; /* offset to the last argument */
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -736,7 +736,7 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
|
||||||
case OpCode_Weight:
|
case OpCode_Weight:
|
||||||
case OpCode_PostScript:
|
case OpCode_PostScript:
|
||||||
case OpCode_BaseFontName:
|
case OpCode_BaseFontName:
|
||||||
dictval.nameSIDs[NameDictValues::name_op_to_index (op)] = env.argStack.pop_uint ();
|
dictval.nameSIDs[name_dict_values_t::name_op_to_index (op)] = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
case OpCode_isFixedPitch:
|
case OpCode_isFixedPitch:
|
||||||
|
@ -765,8 +765,8 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
|
||||||
|
|
||||||
case OpCode_ROS:
|
case OpCode_ROS:
|
||||||
dictval.ros_supplement = env.argStack.pop_uint ();
|
dictval.ros_supplement = env.argStack.pop_uint ();
|
||||||
dictval.nameSIDs[NameDictValues::ordering] = env.argStack.pop_uint ();
|
dictval.nameSIDs[name_dict_values_t::ordering] = env.argStack.pop_uint ();
|
||||||
dictval.nameSIDs[NameDictValues::registry] = env.argStack.pop_uint ();
|
dictval.nameSIDs[name_dict_values_t::registry] = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -795,7 +795,7 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
|
||||||
|
|
||||||
default:
|
default:
|
||||||
env.last_offset = env.str_ref.offset;
|
env.last_offset = env.str_ref.offset;
|
||||||
TopDictOpSet<CFF1TopDictVal>::process_op (op, env, dictval);
|
top_dict_opset_t<cff1_top_dict_val_t>::process_op (op, env, dictval);
|
||||||
/* Record this operand below if stack is empty, otherwise done */
|
/* Record this operand below if stack is empty, otherwise done */
|
||||||
if (!env.argStack.is_empty ()) return;
|
if (!env.argStack.is_empty ()) return;
|
||||||
break;
|
break;
|
||||||
|
@ -807,23 +807,23 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1FontDictValues : DictValues<OpStr>
|
struct cff1_font_dict_values_t : dict_values_t<op_str_t>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
DictValues<OpStr>::init ();
|
dict_values_t<op_str_t>::init ();
|
||||||
privateDictInfo.init ();
|
privateDictInfo.init ();
|
||||||
fontName = CFF_UNDEF_SID;
|
fontName = CFF_UNDEF_SID;
|
||||||
}
|
}
|
||||||
void fini () { DictValues<OpStr>::fini (); }
|
void fini () { dict_values_t<op_str_t>::fini (); }
|
||||||
|
|
||||||
TableInfo privateDictInfo;
|
table_info_t privateDictInfo;
|
||||||
unsigned int fontName;
|
unsigned int fontName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1FontDictOpSet : DictOpSet
|
struct cff1_font_dict_opset_t : dict_opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, NumInterpEnv& env, CFF1FontDictValues& dictval)
|
static void process_op (OpCode op, num_interp_env_t& env, cff1_font_dict_values_t& dictval)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_FontName:
|
case OpCode_FontName:
|
||||||
|
@ -841,7 +841,7 @@ struct CFF1FontDictOpSet : DictOpSet
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DictOpSet::process_op (op, env);
|
dict_opset_t::process_op (op, env);
|
||||||
if (!env.argStack.is_empty ()) return;
|
if (!env.argStack.is_empty ()) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -853,24 +853,24 @@ struct CFF1FontDictOpSet : DictOpSet
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename VAL>
|
template <typename VAL>
|
||||||
struct CFF1PrivateDictValues_Base : DictValues<VAL>
|
struct cff1_private_dict_values_base_t : dict_values_t<VAL>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
DictValues<VAL>::init ();
|
dict_values_t<VAL>::init ();
|
||||||
subrsOffset = 0;
|
subrsOffset = 0;
|
||||||
localSubrs = &Null(CFF1Subrs);
|
localSubrs = &Null(CFF1Subrs);
|
||||||
}
|
}
|
||||||
void fini () { DictValues<VAL>::fini (); }
|
void fini () { dict_values_t<VAL>::fini (); }
|
||||||
|
|
||||||
unsigned int calculate_serialized_size () const
|
unsigned int calculate_serialized_size () const
|
||||||
{
|
{
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++)
|
for (unsigned int i = 0; i < dict_values_t<VAL>::get_count; i++)
|
||||||
if (DictValues<VAL>::get_value (i).op == OpCode_Subrs)
|
if (dict_values_t<VAL>::get_value (i).op == OpCode_Subrs)
|
||||||
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
|
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
|
||||||
else
|
else
|
||||||
size += DictValues<VAL>::get_value (i).str.len;
|
size += dict_values_t<VAL>::get_value (i).str.len;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,14 +878,14 @@ struct CFF1PrivateDictValues_Base : DictValues<VAL>
|
||||||
const CFF1Subrs *localSubrs;
|
const CFF1Subrs *localSubrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef CFF1PrivateDictValues_Base<OpStr> CFF1PrivateDictValues_Subset;
|
typedef cff1_private_dict_values_base_t<op_str_t> cff1_private_dict_values_subset_t;
|
||||||
typedef CFF1PrivateDictValues_Base<NumDictVal> CFF1PrivateDictValues;
|
typedef cff1_private_dict_values_base_t<num_dict_val_t> cff1_private_dict_values_t;
|
||||||
|
|
||||||
struct CFF1PrivateDictOpSet : DictOpSet
|
struct cff1_private_dict_opset_t : dict_opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues& dictval)
|
static void process_op (OpCode op, num_interp_env_t& env, cff1_private_dict_values_t& dictval)
|
||||||
{
|
{
|
||||||
NumDictVal val;
|
num_dict_val_t val;
|
||||||
val.init ();
|
val.init ();
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -917,7 +917,7 @@ struct CFF1PrivateDictOpSet : DictOpSet
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DictOpSet::process_op (op, env);
|
dict_opset_t::process_op (op, env);
|
||||||
if (!env.argStack.is_empty ()) return;
|
if (!env.argStack.is_empty ()) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -928,9 +928,9 @@ struct CFF1PrivateDictOpSet : DictOpSet
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1PrivateDictOpSet_Subset : DictOpSet
|
struct cff1_private_dict_opset_subset : dict_opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues_Subset& dictval)
|
static void process_op (OpCode op, num_interp_env_t& env, cff1_private_dict_values_subset_t& dictval)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_BlueValues:
|
case OpCode_BlueValues:
|
||||||
|
@ -959,7 +959,7 @@ struct CFF1PrivateDictOpSet_Subset : DictOpSet
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DictOpSet::process_op (op, env);
|
dict_opset_t::process_op (op, env);
|
||||||
if (!env.argStack.is_empty ()) return;
|
if (!env.argStack.is_empty ()) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -970,9 +970,8 @@ struct CFF1PrivateDictOpSet_Subset : DictOpSet
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef DictInterpreter<CFF1TopDictOpSet, CFF1TopDictValues, CFF1TopDictInterpEnv> CFF1TopDict_Interpreter;
|
typedef dict_interpreter_t<cff1_top_dict_opset_t, cff1_top_dict_values_t, cff1_top_dict_interp_env_t> cff1_top_dict_interpreter_t;
|
||||||
typedef DictInterpreter<CFF1FontDictOpSet, CFF1FontDictValues> CFF1FontDict_Interpreter;
|
typedef dict_interpreter_t<cff1_font_dict_opset_t, cff1_font_dict_values_t> cff1_font_dict_interpreter_t;
|
||||||
typedef DictInterpreter<CFF1PrivateDictOpSet, CFF1PrivateDictValues> CFF1PrivateDict_Interpreter;
|
|
||||||
|
|
||||||
typedef CFF1Index CFF1NameIndex;
|
typedef CFF1Index CFF1NameIndex;
|
||||||
typedef CFF1IndexOf<TopDict> CFF1TopDictIndex;
|
typedef CFF1IndexOf<TopDict> CFF1TopDictIndex;
|
||||||
|
@ -1025,7 +1024,7 @@ struct cff1
|
||||||
{ /* parse top dict */
|
{ /* parse top dict */
|
||||||
const byte_str_t topDictStr = (*topDictIndex)[0];
|
const byte_str_t topDictStr = (*topDictIndex)[0];
|
||||||
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
CFF1TopDict_Interpreter top_interp;
|
cff1_top_dict_interpreter_t top_interp;
|
||||||
top_interp.env.init (topDictStr);
|
top_interp.env.init (topDictStr);
|
||||||
topDict.init ();
|
topDict.init ();
|
||||||
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
||||||
|
@ -1084,17 +1083,17 @@ struct cff1
|
||||||
{
|
{
|
||||||
byte_str_t fontDictStr = (*fdArray)[i];
|
byte_str_t fontDictStr = (*fdArray)[i];
|
||||||
if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
CFF1FontDictValues *font;
|
cff1_font_dict_values_t *font;
|
||||||
CFF1FontDict_Interpreter font_interp;
|
cff1_font_dict_interpreter_t font_interp;
|
||||||
font_interp.env.init (fontDictStr);
|
font_interp.env.init (fontDictStr);
|
||||||
font = fontDicts.push ();
|
font = fontDicts.push ();
|
||||||
if (unlikely (font == &Crap(CFF1FontDictValues))) { fini (); return; }
|
if (unlikely (font == &Crap(cff1_font_dict_values_t))) { fini (); return; }
|
||||||
font->init ();
|
font->init ();
|
||||||
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
|
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
|
||||||
PRIVDICTVAL *priv = &privateDicts[i];
|
PRIVDICTVAL *priv = &privateDicts[i];
|
||||||
const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||||
priv_interp.env.init (privDictStr);
|
priv_interp.env.init (privDictStr);
|
||||||
priv->init ();
|
priv->init ();
|
||||||
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
|
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
|
||||||
|
@ -1107,12 +1106,12 @@ struct cff1
|
||||||
}
|
}
|
||||||
else /* non-CID */
|
else /* non-CID */
|
||||||
{
|
{
|
||||||
CFF1TopDictValues *font = &topDict;
|
cff1_top_dict_values_t *font = &topDict;
|
||||||
PRIVDICTVAL *priv = &privateDicts[0];
|
PRIVDICTVAL *priv = &privateDicts[0];
|
||||||
|
|
||||||
const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||||
priv_interp.env.init (privDictStr);
|
priv_interp.env.init (privDictStr);
|
||||||
priv->init ();
|
priv->init ();
|
||||||
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
|
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
|
||||||
|
@ -1167,20 +1166,20 @@ struct cff1
|
||||||
const CFF1FDSelect *fdSelect;
|
const CFF1FDSelect *fdSelect;
|
||||||
unsigned int fdCount;
|
unsigned int fdCount;
|
||||||
|
|
||||||
CFF1TopDictValues topDict;
|
cff1_top_dict_values_t topDict;
|
||||||
hb_vector_t<CFF1FontDictValues> fontDicts;
|
hb_vector_t<cff1_font_dict_values_t> fontDicts;
|
||||||
hb_vector_t<PRIVDICTVAL> privateDicts;
|
hb_vector_t<PRIVDICTVAL> privateDicts;
|
||||||
|
|
||||||
unsigned int num_glyphs;
|
unsigned int num_glyphs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct accelerator_t : accelerator_templ_t<CFF1PrivateDictOpSet, CFF1PrivateDictValues>
|
struct accelerator_t : accelerator_templ_t<cff1_private_dict_opset_t, cff1_private_dict_values_t>
|
||||||
{
|
{
|
||||||
HB_INTERNAL bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const;
|
HB_INTERNAL bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const;
|
||||||
HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
|
HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct accelerator_subset_t : accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset>
|
struct accelerator_subset_t : accelerator_templ_t<cff1_private_dict_opset_subset, cff1_private_dict_values_subset_t>
|
||||||
{
|
{
|
||||||
void init (hb_face_t *face)
|
void init (hb_face_t *face)
|
||||||
{
|
{
|
||||||
|
@ -1257,7 +1256,7 @@ struct cff1
|
||||||
const Encoding *encoding;
|
const Encoding *encoding;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset> SUPER;
|
typedef accelerator_templ_t<cff1_private_dict_opset_subset, cff1_private_dict_values_subset_t> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool subset (hb_subset_plan_t *plan) const
|
bool subset (hb_subset_plan_t *plan) const
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
using namespace CFF;
|
using namespace CFF;
|
||||||
|
|
||||||
struct ExtentsParam
|
struct extents_param_t
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ struct ExtentsParam
|
||||||
void end_path () { path_open = false; }
|
void end_path () { path_open = false; }
|
||||||
bool is_path_open () const { return path_open; }
|
bool is_path_open () const { return path_open; }
|
||||||
|
|
||||||
void update_bounds (const Point &pt)
|
void update_bounds (const point_t &pt)
|
||||||
{
|
{
|
||||||
if (pt.x < min_x) min_x = pt.x;
|
if (pt.x < min_x) min_x = pt.x;
|
||||||
if (pt.x > max_x) max_x = pt.x;
|
if (pt.x > max_x) max_x = pt.x;
|
||||||
|
@ -53,21 +53,21 @@ struct ExtentsParam
|
||||||
}
|
}
|
||||||
|
|
||||||
bool path_open;
|
bool path_open;
|
||||||
Number min_x;
|
number_t min_x;
|
||||||
Number min_y;
|
number_t min_y;
|
||||||
Number max_x;
|
number_t max_x;
|
||||||
Number max_y;
|
number_t max_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv, ExtentsParam>
|
struct cff2_path_procs_extents_t : path_procs_t<cff2_path_procs_extents_t, cff2_cs_interp_env_t, extents_param_t>
|
||||||
{
|
{
|
||||||
static void moveto (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt)
|
static void moveto (cff2_cs_interp_env_t &env, extents_param_t& param, const point_t &pt)
|
||||||
{
|
{
|
||||||
param.end_path ();
|
param.end_path ();
|
||||||
env.moveto (pt);
|
env.moveto (pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void line (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt1)
|
static void line (cff2_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1)
|
||||||
{
|
{
|
||||||
if (!param.is_path_open ())
|
if (!param.is_path_open ())
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv,
|
||||||
param.update_bounds (env.get_pt ());
|
param.update_bounds (env.get_pt ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void curve (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt1, const Point &pt2, const Point &pt3)
|
static void curve (cff2_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
|
||||||
{
|
{
|
||||||
if (!param.is_path_open ())
|
if (!param.is_path_open ())
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2CSOpSet_Extents : CFF2CSOpSet<CFF2CSOpSet_Extents, ExtentsParam, CFF2PathProcs_Extents> {};
|
struct cff2_cs_opset_extents_t : cff2_cs_opset_t<cff2_cs_opset_extents_t, extents_param_t, cff2_path_procs_extents_t> {};
|
||||||
|
|
||||||
bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
|
bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
|
@ -104,10 +104,10 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
|
||||||
unsigned int num_coords;
|
unsigned int num_coords;
|
||||||
const int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
|
const int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
|
||||||
unsigned int fd = fdSelect->get_fd (glyph);
|
unsigned int fd = fdSelect->get_fd (glyph);
|
||||||
CFF2CSInterpreter<CFF2CSOpSet_Extents, ExtentsParam> interp;
|
cff2_cs_interpreter_t<cff2_cs_opset_extents_t, extents_param_t> interp;
|
||||||
const byte_str_t str = (*charStrings)[glyph];
|
const byte_str_t str = (*charStrings)[glyph];
|
||||||
interp.env.init (str, *this, fd, coords, num_coords);
|
interp.env.init (str, *this, fd, coords, num_coords);
|
||||||
ExtentsParam param;
|
extents_param_t param;
|
||||||
param.init ();
|
param.init ();
|
||||||
if (unlikely (!interp.interpret (param))) return false;
|
if (unlikely (!interp.interpret (param))) return false;
|
||||||
|
|
||||||
|
|
|
@ -136,15 +136,15 @@ struct CFF2VariationStore
|
||||||
DEFINE_SIZE_MIN (2 + VariationStore::min_size);
|
DEFINE_SIZE_MIN (2 + VariationStore::min_size);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2TopDictValues : TopDictValues<>
|
struct cff2_top_dict_values_t : top_dict_values_t<>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
TopDictValues<>::init ();
|
top_dict_values_t<>::init ();
|
||||||
vstoreOffset = 0;
|
vstoreOffset = 0;
|
||||||
FDSelectOffset = 0;
|
FDSelectOffset = 0;
|
||||||
}
|
}
|
||||||
void fini () { TopDictValues<>::fini (); }
|
void fini () { top_dict_values_t<>::fini (); }
|
||||||
|
|
||||||
unsigned int calculate_serialized_size () const
|
unsigned int calculate_serialized_size () const
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,7 @@ struct CFF2TopDictValues : TopDictValues<>
|
||||||
size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op);
|
size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
size += TopDictValues<>::calculate_serialized_op_size (get_value (i));
|
size += top_dict_values_t<>::calculate_serialized_op_size (get_value (i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,14 +170,14 @@ struct CFF2TopDictValues : TopDictValues<>
|
||||||
unsigned int FDSelectOffset;
|
unsigned int FDSelectOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2TopDictOpSet : TopDictOpSet<>
|
struct cff2_top_dict_opset_t : top_dict_opset_t<>
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, NumInterpEnv& env, CFF2TopDictValues& dictval)
|
static void process_op (OpCode op, num_interp_env_t& env, cff2_top_dict_values_t& dictval)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_FontMatrix:
|
case OpCode_FontMatrix:
|
||||||
{
|
{
|
||||||
DictVal val;
|
dict_val_t val;
|
||||||
val.init ();
|
val.init ();
|
||||||
dictval.add_op (op, env.str_ref);
|
dictval.add_op (op, env.str_ref);
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
|
@ -204,24 +204,24 @@ struct CFF2TopDictOpSet : TopDictOpSet<>
|
||||||
dictval.add_op (op, env.str_ref);
|
dictval.add_op (op, env.str_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef TopDictOpSet<> SUPER;
|
typedef top_dict_opset_t<> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2FontDictValues : DictValues<OpStr>
|
struct cff2_font_dict_values_t : dict_values_t<op_str_t>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
DictValues<OpStr>::init ();
|
dict_values_t<op_str_t>::init ();
|
||||||
privateDictInfo.init ();
|
privateDictInfo.init ();
|
||||||
}
|
}
|
||||||
void fini () { DictValues<OpStr>::fini (); }
|
void fini () { dict_values_t<op_str_t>::fini (); }
|
||||||
|
|
||||||
TableInfo privateDictInfo;
|
table_info_t privateDictInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2FontDictOpSet : DictOpSet
|
struct cff2_font_dict_opset_t : dict_opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, NumInterpEnv& env, CFF2FontDictValues& dictval)
|
static void process_op (OpCode op, num_interp_env_t& env, cff2_font_dict_values_t& dictval)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_Private:
|
case OpCode_Private:
|
||||||
|
@ -242,29 +242,29 @@ struct CFF2FontDictOpSet : DictOpSet
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef DictOpSet SUPER;
|
typedef dict_opset_t SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename VAL>
|
template <typename VAL>
|
||||||
struct CFF2PrivateDictValues_Base : DictValues<VAL>
|
struct cff2_private_dict_values_base_t : dict_values_t<VAL>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
DictValues<VAL>::init ();
|
dict_values_t<VAL>::init ();
|
||||||
subrsOffset = 0;
|
subrsOffset = 0;
|
||||||
localSubrs = &Null(CFF2Subrs);
|
localSubrs = &Null(CFF2Subrs);
|
||||||
ivs = 0;
|
ivs = 0;
|
||||||
}
|
}
|
||||||
void fini () { DictValues<VAL>::fini (); }
|
void fini () { dict_values_t<VAL>::fini (); }
|
||||||
|
|
||||||
unsigned int calculate_serialized_size () const
|
unsigned int calculate_serialized_size () const
|
||||||
{
|
{
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++)
|
for (unsigned int i = 0; i < dict_values_t<VAL>::get_count; i++)
|
||||||
if (DictValues<VAL>::get_value (i).op == OpCode_Subrs)
|
if (dict_values_t<VAL>::get_value (i).op == OpCode_Subrs)
|
||||||
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
|
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
|
||||||
else
|
else
|
||||||
size += DictValues<VAL>::get_value (i).str.len;
|
size += dict_values_t<VAL>::get_value (i).str.len;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,14 +273,14 @@ struct CFF2PrivateDictValues_Base : DictValues<VAL>
|
||||||
unsigned int ivs;
|
unsigned int ivs;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef CFF2PrivateDictValues_Base<OpStr> CFF2PrivateDictValues_Subset;
|
typedef cff2_private_dict_values_base_t<op_str_t> cff2_private_dict_values_subset_t;
|
||||||
typedef CFF2PrivateDictValues_Base<NumDictVal> CFF2PrivateDictValues;
|
typedef cff2_private_dict_values_base_t<num_dict_val_t> cff2_private_dict_values_t;
|
||||||
|
|
||||||
struct CFF2PrivDictInterpEnv : NumInterpEnv
|
struct cff2_priv_dict_interp_env_t : num_interp_env_t
|
||||||
{
|
{
|
||||||
void init (const byte_str_t &str)
|
void init (const byte_str_t &str)
|
||||||
{
|
{
|
||||||
NumInterpEnv::init (str);
|
num_interp_env_t::init (str);
|
||||||
ivs = 0;
|
ivs = 0;
|
||||||
seen_vsindex = false;
|
seen_vsindex = false;
|
||||||
}
|
}
|
||||||
|
@ -302,11 +302,11 @@ struct CFF2PrivDictInterpEnv : NumInterpEnv
|
||||||
bool seen_vsindex;
|
bool seen_vsindex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2PrivateDictOpSet : DictOpSet
|
struct cff2_private_dict_opset_t : dict_opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, CFF2PrivDictInterpEnv& env, CFF2PrivateDictValues& dictval)
|
static void process_op (OpCode op, cff2_priv_dict_interp_env_t& env, cff2_private_dict_values_t& dictval)
|
||||||
{
|
{
|
||||||
NumDictVal val;
|
num_dict_val_t val;
|
||||||
val.init ();
|
val.init ();
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -341,7 +341,7 @@ struct CFF2PrivateDictOpSet : DictOpSet
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DictOpSet::process_op (op, env);
|
dict_opset_t::process_op (op, env);
|
||||||
if (!env.argStack.is_empty ()) return;
|
if (!env.argStack.is_empty ()) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -352,9 +352,9 @@ struct CFF2PrivateDictOpSet : DictOpSet
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2PrivateDictOpSet_Subset : DictOpSet
|
struct cff2_private_dict_opset_subset_t : dict_opset_t
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, CFF2PrivDictInterpEnv& env, CFF2PrivateDictValues_Subset& dictval)
|
static void process_op (OpCode op, cff2_priv_dict_interp_env_t& env, cff2_private_dict_values_subset_t& dictval)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OpCode_BlueValues:
|
case OpCode_BlueValues:
|
||||||
|
@ -394,11 +394,11 @@ struct CFF2PrivateDictOpSet_Subset : DictOpSet
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef DictOpSet SUPER;
|
typedef dict_opset_t SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef DictInterpreter<CFF2TopDictOpSet, CFF2TopDictValues> CFF2TopDict_Interpreter;
|
typedef dict_interpreter_t<cff2_top_dict_opset_t, cff2_top_dict_values_t> cff2_top_dict_interpreter_t;
|
||||||
typedef DictInterpreter<CFF2FontDictOpSet, CFF2FontDictValues> CFF2FontDict_Interpreter;
|
typedef dict_interpreter_t<cff2_font_dict_opset_t, cff2_font_dict_values_t> cff2_font_dict_interpreter_t;
|
||||||
|
|
||||||
}; /* namespace CFF */
|
}; /* namespace CFF */
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ struct cff2
|
||||||
{ /* parse top dict */
|
{ /* parse top dict */
|
||||||
byte_str_t topDictStr (cff2 + cff2->topDict, cff2->topDictSize);
|
byte_str_t topDictStr (cff2 + cff2->topDict, cff2->topDictSize);
|
||||||
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
CFF2TopDict_Interpreter top_interp;
|
cff2_top_dict_interpreter_t top_interp;
|
||||||
top_interp.env.init (topDictStr);
|
top_interp.env.init (topDictStr);
|
||||||
topDict.init ();
|
topDict.init ();
|
||||||
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
||||||
|
@ -471,17 +471,17 @@ struct cff2
|
||||||
{
|
{
|
||||||
const byte_str_t fontDictStr = (*fdArray)[i];
|
const byte_str_t fontDictStr = (*fdArray)[i];
|
||||||
if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
CFF2FontDictValues *font;
|
cff2_font_dict_values_t *font;
|
||||||
CFF2FontDict_Interpreter font_interp;
|
cff2_font_dict_interpreter_t font_interp;
|
||||||
font_interp.env.init (fontDictStr);
|
font_interp.env.init (fontDictStr);
|
||||||
font = fontDicts.push ();
|
font = fontDicts.push ();
|
||||||
if (unlikely (font == &Crap(CFF2FontDictValues))) { fini (); return; }
|
if (unlikely (font == &Crap(cff2_font_dict_values_t))) { fini (); return; }
|
||||||
font->init ();
|
font->init ();
|
||||||
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
|
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
|
||||||
|
|
||||||
const byte_str_t privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size);
|
const byte_str_t privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
DictInterpreter<PRIVOPSET, PRIVDICTVAL, CFF2PrivDictInterpEnv> priv_interp;
|
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL, cff2_priv_dict_interp_env_t> priv_interp;
|
||||||
priv_interp.env.init(privDictStr);
|
priv_interp.env.init(privDictStr);
|
||||||
privateDicts[i].init ();
|
privateDicts[i].init ();
|
||||||
if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; }
|
if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; }
|
||||||
|
@ -509,7 +509,7 @@ struct cff2
|
||||||
hb_sanitize_context_t sc;
|
hb_sanitize_context_t sc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFF2TopDictValues topDict;
|
cff2_top_dict_values_t topDict;
|
||||||
const CFF2Subrs *globalSubrs;
|
const CFF2Subrs *globalSubrs;
|
||||||
const CFF2VariationStore *varStore;
|
const CFF2VariationStore *varStore;
|
||||||
const CFF2CharStrings *charStrings;
|
const CFF2CharStrings *charStrings;
|
||||||
|
@ -517,20 +517,20 @@ struct cff2
|
||||||
const CFF2FDSelect *fdSelect;
|
const CFF2FDSelect *fdSelect;
|
||||||
unsigned int fdCount;
|
unsigned int fdCount;
|
||||||
|
|
||||||
hb_vector_t<CFF2FontDictValues> fontDicts;
|
hb_vector_t<cff2_font_dict_values_t> fontDicts;
|
||||||
hb_vector_t<PRIVDICTVAL> privateDicts;
|
hb_vector_t<PRIVDICTVAL> privateDicts;
|
||||||
|
|
||||||
unsigned int num_glyphs;
|
unsigned int num_glyphs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct accelerator_t : accelerator_templ_t<CFF2PrivateDictOpSet, CFF2PrivateDictValues>
|
struct accelerator_t : accelerator_templ_t<cff2_private_dict_opset_t, cff2_private_dict_values_t>
|
||||||
{
|
{
|
||||||
HB_INTERNAL bool get_extents (hb_font_t *font,
|
HB_INTERNAL bool get_extents (hb_font_t *font,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
hb_glyph_extents_t *extents) const;
|
hb_glyph_extents_t *extents) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef accelerator_templ_t<CFF2PrivateDictOpSet_Subset, CFF2PrivateDictValues_Subset> accelerator_subset_t;
|
typedef accelerator_templ_t<cff2_private_dict_opset_subset_t, cff2_private_dict_values_subset_t> accelerator_subset_t;
|
||||||
|
|
||||||
bool subset (hb_subset_plan_t *plan) const
|
bool subset (hb_subset_plan_t *plan) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,8 +49,8 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
|
||||||
unsigned int &subset_fd_count /* OUT */,
|
unsigned int &subset_fd_count /* OUT */,
|
||||||
unsigned int &subset_fdselect_size /* OUT */,
|
unsigned int &subset_fdselect_size /* OUT */,
|
||||||
unsigned int &subset_fdselect_format /* OUT */,
|
unsigned int &subset_fdselect_format /* OUT */,
|
||||||
hb_vector_t<code_pair> &fdselect_ranges /* OUT */,
|
hb_vector_t<code_pair_t> &fdselect_ranges /* OUT */,
|
||||||
Remap &fdmap /* OUT */)
|
remap_t &fdmap /* OUT */)
|
||||||
{
|
{
|
||||||
subset_fd_count = 0;
|
subset_fd_count = 0;
|
||||||
subset_fdselect_size = 0;
|
subset_fdselect_size = 0;
|
||||||
|
@ -76,7 +76,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
|
||||||
{
|
{
|
||||||
num_ranges++;
|
num_ranges++;
|
||||||
prev_fd = fd;
|
prev_fd = fd;
|
||||||
code_pair pair = { fd, i };
|
code_pair_t pair = { fd, i };
|
||||||
fdselect_ranges.push (pair);
|
fdselect_ranges.push (pair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c,
|
||||||
const unsigned int num_glyphs,
|
const unsigned int num_glyphs,
|
||||||
const FDSelect &src,
|
const FDSelect &src,
|
||||||
unsigned int size,
|
unsigned int size,
|
||||||
const hb_vector_t<code_pair> &fdselect_ranges)
|
const hb_vector_t<code_pair_t> &fdselect_ranges)
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size);
|
FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size);
|
||||||
|
@ -174,7 +174,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||||
unsigned int fd_count,
|
unsigned int fd_count,
|
||||||
unsigned int fdselect_format,
|
unsigned int fdselect_format,
|
||||||
unsigned int size,
|
unsigned int size,
|
||||||
const hb_vector_t<code_pair> &fdselect_ranges)
|
const hb_vector_t<code_pair_t> &fdselect_ranges)
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
FDSelect *p = c->allocate_min<FDSelect> ();
|
FDSelect *p = c->allocate_min<FDSelect> ();
|
||||||
|
|
|
@ -35,9 +35,9 @@
|
||||||
namespace CFF {
|
namespace CFF {
|
||||||
|
|
||||||
/* Used for writing a temporary charstring */
|
/* Used for writing a temporary charstring */
|
||||||
struct StrEncoder
|
struct str_encoder_t
|
||||||
{
|
{
|
||||||
StrEncoder (StrBuff &buff_)
|
str_encoder_t (str_buff_t &buff_)
|
||||||
: buff (buff_), error (false) {}
|
: buff (buff_), error (false) {}
|
||||||
|
|
||||||
void reset () { buff.resize (0); }
|
void reset () { buff.resize (0); }
|
||||||
|
@ -79,7 +79,7 @@ struct StrEncoder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void encode_num (const Number& n)
|
void encode_num (const number_t& n)
|
||||||
{
|
{
|
||||||
if (n.in_int_range ())
|
if (n.in_int_range ())
|
||||||
{
|
{
|
||||||
|
@ -124,12 +124,12 @@ struct StrEncoder
|
||||||
protected:
|
protected:
|
||||||
void set_error () { error = true; }
|
void set_error () { error = true; }
|
||||||
|
|
||||||
StrBuff &buff;
|
str_buff_t &buff;
|
||||||
bool error;
|
bool error;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFFSubTableOffsets {
|
struct cff_sub_table_offsets_t {
|
||||||
CFFSubTableOffsets () : privateDictsOffset (0)
|
cff_sub_table_offsets_t () : privateDictsOffset (0)
|
||||||
{
|
{
|
||||||
topDictInfo.init ();
|
topDictInfo.init ();
|
||||||
FDSelectInfo.init ();
|
FDSelectInfo.init ();
|
||||||
|
@ -139,23 +139,23 @@ struct CFFSubTableOffsets {
|
||||||
localSubrsInfos.init ();
|
localSubrsInfos.init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
~CFFSubTableOffsets () { localSubrsInfos.fini (); }
|
~cff_sub_table_offsets_t () { localSubrsInfos.fini (); }
|
||||||
|
|
||||||
TableInfo topDictInfo;
|
table_info_t topDictInfo;
|
||||||
TableInfo FDSelectInfo;
|
table_info_t FDSelectInfo;
|
||||||
TableInfo FDArrayInfo;
|
table_info_t FDArrayInfo;
|
||||||
TableInfo charStringsInfo;
|
table_info_t charStringsInfo;
|
||||||
unsigned int privateDictsOffset;
|
unsigned int privateDictsOffset;
|
||||||
TableInfo globalSubrsInfo;
|
table_info_t globalSubrsInfo;
|
||||||
hb_vector_t<TableInfo> localSubrsInfos;
|
hb_vector_t<table_info_t> localSubrsInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename OPSTR=OpStr>
|
template <typename OPSTR=op_str_t>
|
||||||
struct CFFTopDict_OpSerializer : OpSerializer
|
struct cff_top_dict_op_serializer_t : op_serializer_t
|
||||||
{
|
{
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
const OPSTR &opstr,
|
const OPSTR &opstr,
|
||||||
const CFFSubTableOffsets &offsets) const
|
const cff_sub_table_offsets_t &offsets) const
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
|
@ -191,11 +191,11 @@ struct CFFTopDict_OpSerializer : OpSerializer
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFFFontDict_OpSerializer : OpSerializer
|
struct cff_font_dict_op_serializer_t : op_serializer_t
|
||||||
{
|
{
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
const OpStr &opstr,
|
const op_str_t &opstr,
|
||||||
const TableInfo &privateDictInfo) const
|
const table_info_t &privateDictInfo) const
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ struct CFFFontDict_OpSerializer : OpSerializer
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculate_serialized_size (const OpStr &opstr) const
|
unsigned int calculate_serialized_size (const op_str_t &opstr) const
|
||||||
{
|
{
|
||||||
if (opstr.op == OpCode_Private)
|
if (opstr.op == OpCode_Private)
|
||||||
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private);
|
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private);
|
||||||
|
@ -231,18 +231,18 @@ struct CFFFontDict_OpSerializer : OpSerializer
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFFPrivateDict_OpSerializer : OpSerializer
|
struct cff_private_dict_op_serializer_t : op_serializer_t
|
||||||
{
|
{
|
||||||
CFFPrivateDict_OpSerializer (bool desubroutinize_, bool drop_hints_)
|
cff_private_dict_op_serializer_t (bool desubroutinize_, bool drop_hints_)
|
||||||
: desubroutinize (desubroutinize_), drop_hints (drop_hints_) {}
|
: desubroutinize (desubroutinize_), drop_hints (drop_hints_) {}
|
||||||
|
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
const OpStr &opstr,
|
const op_str_t &opstr,
|
||||||
const unsigned int subrsOffset) const
|
const unsigned int subrsOffset) const
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
if (drop_hints && DictOpSet::is_hint_op (opstr.op))
|
if (drop_hints && dict_opset_t::is_hint_op (opstr.op))
|
||||||
return true;
|
return true;
|
||||||
if (opstr.op == OpCode_Subrs)
|
if (opstr.op == OpCode_Subrs)
|
||||||
{
|
{
|
||||||
|
@ -255,10 +255,10 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
|
||||||
return_trace (copy_opstr (c, opstr));
|
return_trace (copy_opstr (c, opstr));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculate_serialized_size (const OpStr &opstr,
|
unsigned int calculate_serialized_size (const op_str_t &opstr,
|
||||||
bool has_localsubr=true) const
|
bool has_localsubr=true) const
|
||||||
{
|
{
|
||||||
if (drop_hints && DictOpSet::is_hint_op (opstr.op))
|
if (drop_hints && dict_opset_t::is_hint_op (opstr.op))
|
||||||
return 0;
|
return 0;
|
||||||
if (opstr.op == OpCode_Subrs)
|
if (opstr.op == OpCode_Subrs)
|
||||||
{
|
{
|
||||||
|
@ -276,16 +276,16 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
|
||||||
const bool drop_hints;
|
const bool drop_hints;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FlattenParam
|
struct flatten_param_t
|
||||||
{
|
{
|
||||||
StrBuff &flatStr;
|
str_buff_t &flatStr;
|
||||||
bool drop_hints;
|
bool drop_hints;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ACC, typename ENV, typename OPSET>
|
template <typename ACC, typename ENV, typename OPSET>
|
||||||
struct SubrFlattener
|
struct subr_flattener_t
|
||||||
{
|
{
|
||||||
SubrFlattener (const ACC &acc_,
|
subr_flattener_t (const ACC &acc_,
|
||||||
const hb_vector_t<hb_codepoint_t> &glyphs_,
|
const hb_vector_t<hb_codepoint_t> &glyphs_,
|
||||||
bool drop_hints_)
|
bool drop_hints_)
|
||||||
: acc (acc_),
|
: acc (acc_),
|
||||||
|
@ -293,7 +293,7 @@ struct SubrFlattener
|
||||||
drop_hints (drop_hints_)
|
drop_hints (drop_hints_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool flatten (StrBuffArray &flat_charstrings)
|
bool flatten (str_buff_vec_t &flat_charstrings)
|
||||||
{
|
{
|
||||||
if (!flat_charstrings.resize (glyphs.len))
|
if (!flat_charstrings.resize (glyphs.len))
|
||||||
return false;
|
return false;
|
||||||
|
@ -306,9 +306,9 @@ struct SubrFlattener
|
||||||
unsigned int fd = acc.fdSelect->get_fd (glyph);
|
unsigned int fd = acc.fdSelect->get_fd (glyph);
|
||||||
if (unlikely (fd >= acc.fdCount))
|
if (unlikely (fd >= acc.fdCount))
|
||||||
return false;
|
return false;
|
||||||
CSInterpreter<ENV, OPSET, FlattenParam> interp;
|
cs_interpreter_t<ENV, OPSET, flatten_param_t> interp;
|
||||||
interp.env.init (str, acc, fd);
|
interp.env.init (str, acc, fd);
|
||||||
FlattenParam param = { flat_charstrings[i], drop_hints };
|
flatten_param_t param = { flat_charstrings[i], drop_hints };
|
||||||
if (unlikely (!interp.interpret (param)))
|
if (unlikely (!interp.interpret (param)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -320,9 +320,9 @@ struct SubrFlattener
|
||||||
bool drop_hints;
|
bool drop_hints;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubrClosures
|
struct subr_closures_t
|
||||||
{
|
{
|
||||||
SubrClosures () : valid (false), global_closure (nullptr)
|
subr_closures_t () : valid (false), global_closure (nullptr)
|
||||||
{ local_closures.init (); }
|
{ local_closures.init (); }
|
||||||
|
|
||||||
void init (unsigned int fd_count)
|
void init (unsigned int fd_count)
|
||||||
|
@ -363,18 +363,18 @@ struct SubrClosures
|
||||||
hb_vector_t<hb_set_t *> local_closures;
|
hb_vector_t<hb_set_t *> local_closures;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParsedCSOp : OpStr
|
struct parsed_cs_op_t : op_str_t
|
||||||
{
|
{
|
||||||
void init (unsigned int subr_num_ = 0)
|
void init (unsigned int subr_num_ = 0)
|
||||||
{
|
{
|
||||||
OpStr::init ();
|
op_str_t::init ();
|
||||||
subr_num = subr_num_;
|
subr_num = subr_num_;
|
||||||
drop_flag = false;
|
drop_flag = false;
|
||||||
keep_flag = false;
|
keep_flag = false;
|
||||||
skip_flag = false;
|
skip_flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fini () { OpStr::fini (); }
|
void fini () { op_str_t::fini (); }
|
||||||
|
|
||||||
bool for_drop () const { return drop_flag; }
|
bool for_drop () const { return drop_flag; }
|
||||||
void set_drop () { if (!for_keep ()) drop_flag = true; }
|
void set_drop () { if (!for_keep ()) drop_flag = true; }
|
||||||
|
@ -393,7 +393,7 @@ struct ParsedCSOp : OpStr
|
||||||
bool skip_flag : 1;
|
bool skip_flag : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParsedCStr : ParsedValues<ParsedCSOp>
|
struct parsed_cs_str_t : parsed_values_t<parsed_cs_op_t>
|
||||||
{
|
{
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
|
@ -417,13 +417,13 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
|
||||||
if (likely (parsed_len > 0))
|
if (likely (parsed_len > 0))
|
||||||
values[parsed_len-1].set_skip ();
|
values[parsed_len-1].set_skip ();
|
||||||
|
|
||||||
ParsedCSOp val;
|
parsed_cs_op_t val;
|
||||||
val.init (subr_num);
|
val.init (subr_num);
|
||||||
SUPER::add_op (op, str_ref, val);
|
SUPER::add_op (op, str_ref, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_prefix (const Number &num, OpCode op = OpCode_Invalid)
|
void set_prefix (const number_t &num, OpCode op = OpCode_Invalid)
|
||||||
{
|
{
|
||||||
has_prefix_ = true;
|
has_prefix_ = true;
|
||||||
prefix_op_ = op;
|
prefix_op_ = op;
|
||||||
|
@ -447,7 +447,7 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
|
||||||
|
|
||||||
bool has_prefix () const { return has_prefix_; }
|
bool has_prefix () const { return has_prefix_; }
|
||||||
OpCode prefix_op () const { return prefix_op_; }
|
OpCode prefix_op () const { return prefix_op_; }
|
||||||
const Number &prefix_num () const { return prefix_num_; }
|
const number_t &prefix_num () const { return prefix_num_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool parsed;
|
bool parsed;
|
||||||
|
@ -455,13 +455,13 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
|
||||||
bool vsindex_dropped;
|
bool vsindex_dropped;
|
||||||
bool has_prefix_;
|
bool has_prefix_;
|
||||||
OpCode prefix_op_;
|
OpCode prefix_op_;
|
||||||
Number prefix_num_;
|
number_t prefix_num_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef ParsedValues<ParsedCSOp> SUPER;
|
typedef parsed_values_t<parsed_cs_op_t> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParsedCStrs : hb_vector_t<ParsedCStr>
|
struct parsed_cs_str_vec_t : hb_vector_t<parsed_cs_str_t>
|
||||||
{
|
{
|
||||||
void init (unsigned int len_ = 0)
|
void init (unsigned int len_ = 0)
|
||||||
{
|
{
|
||||||
|
@ -473,13 +473,13 @@ struct ParsedCStrs : hb_vector_t<ParsedCStr>
|
||||||
void fini () { SUPER::fini_deep (); }
|
void fini () { SUPER::fini_deep (); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef hb_vector_t<ParsedCStr> SUPER;
|
typedef hb_vector_t<parsed_cs_str_t> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubrSubsetParam
|
struct subr_subset_param_t
|
||||||
{
|
{
|
||||||
void init (ParsedCStr *parsed_charstring_,
|
void init (parsed_cs_str_t *parsed_charstring_,
|
||||||
ParsedCStrs *parsed_global_subrs_, ParsedCStrs *parsed_local_subrs_,
|
parsed_cs_str_vec_t *parsed_global_subrs_, parsed_cs_str_vec_t *parsed_local_subrs_,
|
||||||
hb_set_t *global_closure_, hb_set_t *local_closure_,
|
hb_set_t *global_closure_, hb_set_t *local_closure_,
|
||||||
bool drop_hints_)
|
bool drop_hints_)
|
||||||
{
|
{
|
||||||
|
@ -492,7 +492,7 @@ struct SubrSubsetParam
|
||||||
drop_hints = drop_hints_;
|
drop_hints = drop_hints_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsedCStr *get_parsed_str_for_context (CallContext &context)
|
parsed_cs_str_t *get_parsed_str_for_context (call_context_t &context)
|
||||||
{
|
{
|
||||||
switch (context.type)
|
switch (context.type)
|
||||||
{
|
{
|
||||||
|
@ -515,7 +515,7 @@ struct SubrSubsetParam
|
||||||
template <typename ENV>
|
template <typename ENV>
|
||||||
void set_current_str (ENV &env, bool calling)
|
void set_current_str (ENV &env, bool calling)
|
||||||
{
|
{
|
||||||
ParsedCStr *parsed_str = get_parsed_str_for_context (env.context);
|
parsed_cs_str_t *parsed_str = get_parsed_str_for_context (env.context);
|
||||||
if (likely (parsed_str != nullptr))
|
if (likely (parsed_str != nullptr))
|
||||||
{
|
{
|
||||||
/* If the called subroutine is parsed partially but not completely yet,
|
/* If the called subroutine is parsed partially but not completely yet,
|
||||||
|
@ -530,17 +530,17 @@ struct SubrSubsetParam
|
||||||
env.set_error ();
|
env.set_error ();
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsedCStr *current_parsed_str;
|
parsed_cs_str_t *current_parsed_str;
|
||||||
|
|
||||||
ParsedCStr *parsed_charstring;
|
parsed_cs_str_t *parsed_charstring;
|
||||||
ParsedCStrs *parsed_global_subrs;
|
parsed_cs_str_vec_t *parsed_global_subrs;
|
||||||
ParsedCStrs *parsed_local_subrs;
|
parsed_cs_str_vec_t *parsed_local_subrs;
|
||||||
hb_set_t *global_closure;
|
hb_set_t *global_closure;
|
||||||
hb_set_t *local_closure;
|
hb_set_t *local_closure;
|
||||||
bool drop_hints;
|
bool drop_hints;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubrRemap : Remap
|
struct subr_remap_t : remap_t
|
||||||
{
|
{
|
||||||
void create (hb_set_t *closure)
|
void create (hb_set_t *closure)
|
||||||
{
|
{
|
||||||
|
@ -567,7 +567,7 @@ struct SubrRemap : Remap
|
||||||
if (old_num >= len)
|
if (old_num >= len)
|
||||||
return CFF_UNDEF_CODE;
|
return CFF_UNDEF_CODE;
|
||||||
else
|
else
|
||||||
return Remap::operator[] (old_num);
|
return remap_t::operator[] (old_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
int biased_num (unsigned int old_num) const
|
int biased_num (unsigned int old_num) const
|
||||||
|
@ -580,15 +580,15 @@ struct SubrRemap : Remap
|
||||||
int bias;
|
int bias;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubrRemaps
|
struct subr_remap_ts
|
||||||
{
|
{
|
||||||
SubrRemaps ()
|
subr_remap_ts ()
|
||||||
{
|
{
|
||||||
global_remap.init ();
|
global_remap.init ();
|
||||||
local_remaps.init ();
|
local_remaps.init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
~SubrRemaps () { fini (); }
|
~subr_remap_ts () { fini (); }
|
||||||
|
|
||||||
void init (unsigned int fdCount)
|
void init (unsigned int fdCount)
|
||||||
{
|
{
|
||||||
|
@ -597,7 +597,7 @@ struct SubrRemaps
|
||||||
local_remaps[i].init ();
|
local_remaps[i].init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void create (SubrClosures& closures)
|
void create (subr_closures_t& closures)
|
||||||
{
|
{
|
||||||
global_remap.create (closures.global_closure);
|
global_remap.create (closures.global_closure);
|
||||||
for (unsigned int i = 0; i < local_remaps.len; i++)
|
for (unsigned int i = 0; i < local_remaps.len; i++)
|
||||||
|
@ -610,21 +610,21 @@ struct SubrRemaps
|
||||||
local_remaps.fini_deep ();
|
local_remaps.fini_deep ();
|
||||||
}
|
}
|
||||||
|
|
||||||
SubrRemap global_remap;
|
subr_remap_t global_remap;
|
||||||
hb_vector_t<SubrRemap> local_remaps;
|
hb_vector_t<subr_remap_t> local_remaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename SUBSETTER, typename SUBRS, typename ACC, typename ENV, typename OPSET>
|
template <typename SUBSETTER, typename SUBRS, typename ACC, typename ENV, typename OPSET>
|
||||||
struct SubrSubsetter
|
struct subr_subsetter_t
|
||||||
{
|
{
|
||||||
SubrSubsetter ()
|
subr_subsetter_t ()
|
||||||
{
|
{
|
||||||
parsed_charstrings.init ();
|
parsed_charstrings.init ();
|
||||||
parsed_global_subrs.init ();
|
parsed_global_subrs.init ();
|
||||||
parsed_local_subrs.init ();
|
parsed_local_subrs.init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
~SubrSubsetter ()
|
~subr_subsetter_t ()
|
||||||
{
|
{
|
||||||
closures.fini ();
|
closures.fini ();
|
||||||
remaps.fini ();
|
remaps.fini ();
|
||||||
|
@ -671,10 +671,10 @@ struct SubrSubsetter
|
||||||
if (unlikely (fd >= acc.fdCount))
|
if (unlikely (fd >= acc.fdCount))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CSInterpreter<ENV, OPSET, SubrSubsetParam> interp;
|
cs_interpreter_t<ENV, OPSET, subr_subset_param_t> interp;
|
||||||
interp.env.init (str, acc, fd);
|
interp.env.init (str, acc, fd);
|
||||||
|
|
||||||
SubrSubsetParam param;
|
subr_subset_param_t param;
|
||||||
param.init (&parsed_charstrings[i],
|
param.init (&parsed_charstrings[i],
|
||||||
&parsed_global_subrs, &parsed_local_subrs[fd],
|
&parsed_global_subrs, &parsed_local_subrs[fd],
|
||||||
closures.global_closure, closures.local_closures[fd],
|
closures.global_closure, closures.local_closures[fd],
|
||||||
|
@ -695,13 +695,13 @@ struct SubrSubsetter
|
||||||
unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
|
unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
|
||||||
if (unlikely (fd >= acc.fdCount))
|
if (unlikely (fd >= acc.fdCount))
|
||||||
return false;
|
return false;
|
||||||
SubrSubsetParam param;
|
subr_subset_param_t param;
|
||||||
param.init (&parsed_charstrings[i],
|
param.init (&parsed_charstrings[i],
|
||||||
&parsed_global_subrs, &parsed_local_subrs[fd],
|
&parsed_global_subrs, &parsed_local_subrs[fd],
|
||||||
closures.global_closure, closures.local_closures[fd],
|
closures.global_closure, closures.local_closures[fd],
|
||||||
drop_hints);
|
drop_hints);
|
||||||
|
|
||||||
DropHintsParam drop;
|
drop_hints_param_t drop;
|
||||||
if (drop_hints_in_str (parsed_charstrings[i], param, drop))
|
if (drop_hints_in_str (parsed_charstrings[i], param, drop))
|
||||||
{
|
{
|
||||||
parsed_charstrings[i].set_hint_dropped ();
|
parsed_charstrings[i].set_hint_dropped ();
|
||||||
|
@ -717,7 +717,7 @@ struct SubrSubsetter
|
||||||
unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
|
unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
|
||||||
if (unlikely (fd >= acc.fdCount))
|
if (unlikely (fd >= acc.fdCount))
|
||||||
return false;
|
return false;
|
||||||
SubrSubsetParam param;
|
subr_subset_param_t param;
|
||||||
param.init (&parsed_charstrings[i],
|
param.init (&parsed_charstrings[i],
|
||||||
&parsed_global_subrs, &parsed_local_subrs[fd],
|
&parsed_global_subrs, &parsed_local_subrs[fd],
|
||||||
closures.global_closure, closures.local_closures[fd],
|
closures.global_closure, closures.local_closures[fd],
|
||||||
|
@ -731,7 +731,7 @@ struct SubrSubsetter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encode_charstrings (ACC &acc, const hb_vector_t<hb_codepoint_t> &glyphs, StrBuffArray &buffArray) const
|
bool encode_charstrings (ACC &acc, const hb_vector_t<hb_codepoint_t> &glyphs, str_buff_vec_t &buffArray) const
|
||||||
{
|
{
|
||||||
if (unlikely (!buffArray.resize (glyphs.len)))
|
if (unlikely (!buffArray.resize (glyphs.len)))
|
||||||
return false;
|
return false;
|
||||||
|
@ -746,7 +746,7 @@ struct SubrSubsetter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encode_subrs (const ParsedCStrs &subrs, const SubrRemap& remap, unsigned int fd, StrBuffArray &buffArray) const
|
bool encode_subrs (const parsed_cs_str_vec_t &subrs, const subr_remap_t& remap, unsigned int fd, str_buff_vec_t &buffArray) const
|
||||||
{
|
{
|
||||||
unsigned int count = remap.get_count ();
|
unsigned int count = remap.get_count ();
|
||||||
|
|
||||||
|
@ -764,20 +764,20 @@ struct SubrSubsetter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encode_globalsubrs (StrBuffArray &buffArray)
|
bool encode_globalsubrs (str_buff_vec_t &buffArray)
|
||||||
{
|
{
|
||||||
return encode_subrs (parsed_global_subrs, remaps.global_remap, 0, buffArray);
|
return encode_subrs (parsed_global_subrs, remaps.global_remap, 0, buffArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encode_localsubrs (unsigned int fd, StrBuffArray &buffArray) const
|
bool encode_localsubrs (unsigned int fd, str_buff_vec_t &buffArray) const
|
||||||
{
|
{
|
||||||
return encode_subrs (parsed_local_subrs[fd], remaps.local_remaps[fd], fd, buffArray);
|
return encode_subrs (parsed_local_subrs[fd], remaps.local_remaps[fd], fd, buffArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct DropHintsParam
|
struct drop_hints_param_t
|
||||||
{
|
{
|
||||||
DropHintsParam ()
|
drop_hints_param_t ()
|
||||||
: seen_moveto (false),
|
: seen_moveto (false),
|
||||||
ends_in_hint (false),
|
ends_in_hint (false),
|
||||||
vsindex_dropped (false) {}
|
vsindex_dropped (false) {}
|
||||||
|
@ -787,9 +787,9 @@ struct SubrSubsetter
|
||||||
bool vsindex_dropped;
|
bool vsindex_dropped;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos,
|
bool drop_hints_in_subr (parsed_cs_str_t &str, unsigned int pos,
|
||||||
ParsedCStrs &subrs, unsigned int subr_num,
|
parsed_cs_str_vec_t &subrs, unsigned int subr_num,
|
||||||
const SubrSubsetParam ¶m, DropHintsParam &drop)
|
const subr_subset_param_t ¶m, drop_hints_param_t &drop)
|
||||||
{
|
{
|
||||||
drop.ends_in_hint = false;
|
drop.ends_in_hint = false;
|
||||||
bool has_hint = drop_hints_in_str (subrs[subr_num], param, drop);
|
bool has_hint = drop_hints_in_str (subrs[subr_num], param, drop);
|
||||||
|
@ -809,7 +809,7 @@ struct SubrSubsetter
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns true if it sees a hint op before the first moveto */
|
/* returns true if it sees a hint op before the first moveto */
|
||||||
bool drop_hints_in_str (ParsedCStr &str, const SubrSubsetParam ¶m, DropHintsParam &drop)
|
bool drop_hints_in_str (parsed_cs_str_t &str, const subr_subset_param_t ¶m, drop_hints_param_t &drop)
|
||||||
{
|
{
|
||||||
bool seen_hint = false;
|
bool seen_hint = false;
|
||||||
|
|
||||||
|
@ -868,7 +868,7 @@ struct SubrSubsetter
|
||||||
{
|
{
|
||||||
for (int i = pos - 1; i >= 0; i--)
|
for (int i = pos - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
ParsedCSOp &csop = str.values[(unsigned)i];
|
parsed_cs_op_t &csop = str.values[(unsigned)i];
|
||||||
if (csop.for_drop ())
|
if (csop.for_drop ())
|
||||||
break;
|
break;
|
||||||
csop.set_drop ();
|
csop.set_drop ();
|
||||||
|
@ -882,16 +882,16 @@ struct SubrSubsetter
|
||||||
return seen_hint;
|
return seen_hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void collect_subr_refs_in_subr (ParsedCStr &str, unsigned int pos,
|
void collect_subr_refs_in_subr (parsed_cs_str_t &str, unsigned int pos,
|
||||||
unsigned int subr_num, ParsedCStrs &subrs,
|
unsigned int subr_num, parsed_cs_str_vec_t &subrs,
|
||||||
hb_set_t *closure,
|
hb_set_t *closure,
|
||||||
const SubrSubsetParam ¶m)
|
const subr_subset_param_t ¶m)
|
||||||
{
|
{
|
||||||
hb_set_add (closure, subr_num);
|
hb_set_add (closure, subr_num);
|
||||||
collect_subr_refs_in_str (subrs[subr_num], param);
|
collect_subr_refs_in_str (subrs[subr_num], param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void collect_subr_refs_in_str (ParsedCStr &str, const SubrSubsetParam ¶m)
|
void collect_subr_refs_in_str (parsed_cs_str_t &str, const subr_subset_param_t ¶m)
|
||||||
{
|
{
|
||||||
for (unsigned int pos = 0; pos < str.values.len; pos++)
|
for (unsigned int pos = 0; pos < str.values.len; pos++)
|
||||||
{
|
{
|
||||||
|
@ -917,10 +917,10 @@ struct SubrSubsetter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encode_str (const ParsedCStr &str, const unsigned int fd, StrBuff &buff) const
|
bool encode_str (const parsed_cs_str_t &str, const unsigned int fd, str_buff_t &buff) const
|
||||||
{
|
{
|
||||||
buff.init ();
|
buff.init ();
|
||||||
StrEncoder encoder (buff);
|
str_encoder_t encoder (buff);
|
||||||
encoder.reset ();
|
encoder.reset ();
|
||||||
/* if a prefix (CFF1 width or CFF2 vsindex) has been removed along with hints,
|
/* if a prefix (CFF1 width or CFF2 vsindex) has been removed along with hints,
|
||||||
* re-insert it at the beginning of charstreing */
|
* re-insert it at the beginning of charstreing */
|
||||||
|
@ -932,7 +932,7 @@ struct SubrSubsetter
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < str.get_count(); i++)
|
for (unsigned int i = 0; i < str.get_count(); i++)
|
||||||
{
|
{
|
||||||
const ParsedCSOp &opstr = str.values[i];
|
const parsed_cs_op_t &opstr = str.values[i];
|
||||||
if (!opstr.for_drop () && !opstr.for_skip ())
|
if (!opstr.for_drop () && !opstr.for_skip ())
|
||||||
{
|
{
|
||||||
switch (opstr.op)
|
switch (opstr.op)
|
||||||
|
@ -957,13 +957,13 @@ struct SubrSubsetter
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SubrClosures closures;
|
subr_closures_t closures;
|
||||||
|
|
||||||
ParsedCStrs parsed_charstrings;
|
parsed_cs_str_vec_t parsed_charstrings;
|
||||||
ParsedCStrs parsed_global_subrs;
|
parsed_cs_str_vec_t parsed_global_subrs;
|
||||||
hb_vector_t<ParsedCStrs> parsed_local_subrs;
|
hb_vector_t<parsed_cs_str_vec_t> parsed_local_subrs;
|
||||||
|
|
||||||
SubrRemaps remaps;
|
subr_remap_ts remaps;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef typename SUBRS::count_type subr_count_type;
|
typedef typename SUBRS::count_type subr_count_type;
|
||||||
|
@ -977,8 +977,8 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
|
||||||
unsigned int &subset_fd_count /* OUT */,
|
unsigned int &subset_fd_count /* OUT */,
|
||||||
unsigned int &subset_fdselect_size /* OUT */,
|
unsigned int &subset_fdselect_size /* OUT */,
|
||||||
unsigned int &subset_fdselect_format /* OUT */,
|
unsigned int &subset_fdselect_format /* OUT */,
|
||||||
hb_vector_t<CFF::code_pair> &fdselect_ranges /* OUT */,
|
hb_vector_t<CFF::code_pair_t> &fdselect_ranges /* OUT */,
|
||||||
CFF::Remap &fdmap /* OUT */);
|
CFF::remap_t &fdmap /* OUT */);
|
||||||
|
|
||||||
HB_INTERNAL bool
|
HB_INTERNAL bool
|
||||||
hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||||
|
@ -987,6 +987,6 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||||
unsigned int fd_count,
|
unsigned int fd_count,
|
||||||
unsigned int fdselect_format,
|
unsigned int fdselect_format,
|
||||||
unsigned int size,
|
unsigned int size,
|
||||||
const hb_vector_t<CFF::code_pair> &fdselect_ranges);
|
const hb_vector_t<CFF::code_pair_t> &fdselect_ranges);
|
||||||
|
|
||||||
#endif /* HB_SUBSET_CFF_COMMON_HH */
|
#endif /* HB_SUBSET_CFF_COMMON_HH */
|
||||||
|
|
|
@ -34,12 +34,12 @@
|
||||||
|
|
||||||
using namespace CFF;
|
using namespace CFF;
|
||||||
|
|
||||||
struct RemapSID : Remap
|
struct remap_sid_t : remap_t
|
||||||
{
|
{
|
||||||
unsigned int add (unsigned int sid)
|
unsigned int add (unsigned int sid)
|
||||||
{
|
{
|
||||||
if ((sid != CFF_UNDEF_SID) && !is_std_std (sid))
|
if ((sid != CFF_UNDEF_SID) && !is_std_std (sid))
|
||||||
return offset_sid (Remap::add (unoffset_sid (sid)));
|
return offset_sid (remap_t::add (unoffset_sid (sid)));
|
||||||
else
|
else
|
||||||
return sid;
|
return sid;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ struct RemapSID : Remap
|
||||||
if (is_std_std (sid) || (sid == CFF_UNDEF_SID))
|
if (is_std_std (sid) || (sid == CFF_UNDEF_SID))
|
||||||
return sid;
|
return sid;
|
||||||
else
|
else
|
||||||
return offset_sid (Remap::operator [] (unoffset_sid (sid)));
|
return offset_sid (remap_t::operator [] (unoffset_sid (sid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned int num_std_strings = 391;
|
static const unsigned int num_std_strings = 391;
|
||||||
|
@ -59,10 +59,10 @@ struct RemapSID : Remap
|
||||||
static unsigned int unoffset_sid (unsigned int sid) { return sid - num_std_strings; }
|
static unsigned int unoffset_sid (unsigned int sid) { return sid - num_std_strings; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1SubTableOffsets : CFFSubTableOffsets
|
struct cff1_sub_table_offsets_t : cff_sub_table_offsets_t
|
||||||
{
|
{
|
||||||
CFF1SubTableOffsets ()
|
cff1_sub_table_offsets_t ()
|
||||||
: CFFSubTableOffsets (),
|
: cff_sub_table_offsets_t (),
|
||||||
nameIndexOffset (0),
|
nameIndexOffset (0),
|
||||||
encodingOffset (0)
|
encodingOffset (0)
|
||||||
{
|
{
|
||||||
|
@ -72,16 +72,16 @@ struct CFF1SubTableOffsets : CFFSubTableOffsets
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int nameIndexOffset;
|
unsigned int nameIndexOffset;
|
||||||
TableInfo stringIndexInfo;
|
table_info_t stringIndexInfo;
|
||||||
unsigned int encodingOffset;
|
unsigned int encodingOffset;
|
||||||
TableInfo charsetInfo;
|
table_info_t charsetInfo;
|
||||||
TableInfo privateDictInfo;
|
table_info_t privateDictInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* a copy of a parsed out CFF1TopDictValues augmented with additional operators */
|
/* a copy of a parsed out cff1_top_dict_values_t augmented with additional operators */
|
||||||
struct CFF1TopDictValuesMod : CFF1TopDictValues
|
struct cff1_top_dict_values_mod_t : cff1_top_dict_values_t
|
||||||
{
|
{
|
||||||
void init (const CFF1TopDictValues *base_= &Null(CFF1TopDictValues))
|
void init (const cff1_top_dict_values_t *base_= &Null(cff1_top_dict_values_t))
|
||||||
{
|
{
|
||||||
SUPER::init ();
|
SUPER::init ();
|
||||||
base = base_;
|
base = base_;
|
||||||
|
@ -90,43 +90,43 @@ struct CFF1TopDictValuesMod : CFF1TopDictValues
|
||||||
void fini () { SUPER::fini (); }
|
void fini () { SUPER::fini (); }
|
||||||
|
|
||||||
unsigned get_count () const { return base->get_count () + SUPER::get_count (); }
|
unsigned get_count () const { return base->get_count () + SUPER::get_count (); }
|
||||||
const CFF1TopDictVal &get_value (unsigned int i) const
|
const cff1_top_dict_val_t &get_value (unsigned int i) const
|
||||||
{
|
{
|
||||||
if (i < base->get_count ())
|
if (i < base->get_count ())
|
||||||
return (*base)[i];
|
return (*base)[i];
|
||||||
else
|
else
|
||||||
return SUPER::values[i - base->get_count ()];
|
return SUPER::values[i - base->get_count ()];
|
||||||
}
|
}
|
||||||
const CFF1TopDictVal &operator [] (unsigned int i) const { return get_value (i); }
|
const cff1_top_dict_val_t &operator [] (unsigned int i) const { return get_value (i); }
|
||||||
|
|
||||||
void reassignSIDs (const RemapSID& sidmap)
|
void reassignSIDs (const remap_sid_t& sidmap)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < NameDictValues::ValCount; i++)
|
for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++)
|
||||||
nameSIDs[i] = sidmap[base->nameSIDs[i]];
|
nameSIDs[i] = sidmap[base->nameSIDs[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef CFF1TopDictValues SUPER;
|
typedef cff1_top_dict_values_t SUPER;
|
||||||
const CFF1TopDictValues *base;
|
const cff1_top_dict_values_t *base;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TopDictModifiers
|
struct top_dict_modifiers_t
|
||||||
{
|
{
|
||||||
TopDictModifiers (const CFF1SubTableOffsets &offsets_,
|
top_dict_modifiers_t (const cff1_sub_table_offsets_t &offsets_,
|
||||||
const unsigned int (&nameSIDs_)[NameDictValues::ValCount])
|
const unsigned int (&nameSIDs_)[name_dict_values_t::ValCount])
|
||||||
: offsets (offsets_),
|
: offsets (offsets_),
|
||||||
nameSIDs (nameSIDs_)
|
nameSIDs (nameSIDs_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const CFF1SubTableOffsets &offsets;
|
const cff1_sub_table_offsets_t &offsets;
|
||||||
const unsigned int (&nameSIDs)[NameDictValues::ValCount];
|
const unsigned int (&nameSIDs)[name_dict_values_t::ValCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
|
struct cff1_top_dict_op_serializer_t : cff_top_dict_op_serializer_t<cff1_top_dict_val_t>
|
||||||
{
|
{
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
const CFF1TopDictVal &opstr,
|
const cff1_top_dict_val_t &opstr,
|
||||||
const TopDictModifiers &mod) const
|
const top_dict_modifiers_t &mod) const
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
|
@ -160,28 +160,28 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
|
||||||
case OpCode_PostScript:
|
case OpCode_PostScript:
|
||||||
case OpCode_BaseFontName:
|
case OpCode_BaseFontName:
|
||||||
case OpCode_FontName:
|
case OpCode_FontName:
|
||||||
return_trace (FontDict::serialize_offset2_op(c, op, mod.nameSIDs[NameDictValues::name_op_to_index (op)]));
|
return_trace (FontDict::serialize_offset2_op(c, op, mod.nameSIDs[name_dict_values_t::name_op_to_index (op)]));
|
||||||
|
|
||||||
case OpCode_ROS:
|
case OpCode_ROS:
|
||||||
{
|
{
|
||||||
/* for registry & ordering, reassigned SIDs are serialized
|
/* for registry & ordering, reassigned SIDs are serialized
|
||||||
* for supplement, the original byte string is copied along with the op code */
|
* for supplement, the original byte string is copied along with the op code */
|
||||||
OpStr supp_op;
|
op_str_t supp_op;
|
||||||
supp_op.op = op;
|
supp_op.op = op;
|
||||||
if ( unlikely (!(opstr.str.len >= opstr.last_arg_offset + 3)))
|
if ( unlikely (!(opstr.str.len >= opstr.last_arg_offset + 3)))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
supp_op.str = byte_str_t (&opstr.str + opstr.last_arg_offset, opstr.str.len - opstr.last_arg_offset);
|
supp_op.str = byte_str_t (&opstr.str + opstr.last_arg_offset, opstr.str.len - opstr.last_arg_offset);
|
||||||
return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::registry]) &&
|
return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::registry]) &&
|
||||||
UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::ordering]) &&
|
UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::ordering]) &&
|
||||||
copy_opstr (c, supp_op));
|
copy_opstr (c, supp_op));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return_trace (CFFTopDict_OpSerializer<CFF1TopDictVal>::serialize (c, opstr, mod.offsets));
|
return_trace (cff_top_dict_op_serializer_t<cff1_top_dict_val_t>::serialize (c, opstr, mod.offsets));
|
||||||
}
|
}
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculate_serialized_size (const CFF1TopDictVal &opstr) const
|
unsigned int calculate_serialized_size (const cff1_top_dict_val_t &opstr) const
|
||||||
{
|
{
|
||||||
OpCode op = opstr.op;
|
OpCode op = opstr.op;
|
||||||
switch (op)
|
switch (op)
|
||||||
|
@ -208,16 +208,16 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
|
||||||
return ((OpCode_Size (OpCode_shortint) + 2) * 2) + (opstr.str.len - opstr.last_arg_offset)/* supplement + op */;
|
return ((OpCode_Size (OpCode_shortint) + 2) * 2) + (opstr.str.len - opstr.last_arg_offset)/* supplement + op */;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return CFFTopDict_OpSerializer<CFF1TopDictVal>::calculate_serialized_size (opstr);
|
return cff_top_dict_op_serializer_t<cff1_top_dict_val_t>::calculate_serialized_size (opstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FontDictValuesMod
|
struct font_dict_values_mod_t
|
||||||
{
|
{
|
||||||
void init (const CFF1FontDictValues *base_,
|
void init (const cff1_font_dict_values_t *base_,
|
||||||
unsigned int fontName_,
|
unsigned int fontName_,
|
||||||
const TableInfo &privateDictInfo_)
|
const table_info_t &privateDictInfo_)
|
||||||
{
|
{
|
||||||
base = base_;
|
base = base_;
|
||||||
fontName = fontName_;
|
fontName = fontName_;
|
||||||
|
@ -226,18 +226,18 @@ struct FontDictValuesMod
|
||||||
|
|
||||||
unsigned get_count () const { return base->get_count (); }
|
unsigned get_count () const { return base->get_count (); }
|
||||||
|
|
||||||
const OpStr &operator [] (unsigned int i) const { return (*base)[i]; }
|
const op_str_t &operator [] (unsigned int i) const { return (*base)[i]; }
|
||||||
|
|
||||||
const CFF1FontDictValues *base;
|
const cff1_font_dict_values_t *base;
|
||||||
TableInfo privateDictInfo;
|
table_info_t privateDictInfo;
|
||||||
unsigned int fontName;
|
unsigned int fontName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer
|
struct cff1_font_dict_op_serializer_t : cff_font_dict_op_serializer_t
|
||||||
{
|
{
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
const OpStr &opstr,
|
const op_str_t &opstr,
|
||||||
const FontDictValuesMod &mod) const
|
const font_dict_values_mod_t &mod) const
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer
|
||||||
return_trace (SUPER::serialize (c, opstr, mod.privateDictInfo));
|
return_trace (SUPER::serialize (c, opstr, mod.privateDictInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculate_serialized_size (const OpStr &opstr) const
|
unsigned int calculate_serialized_size (const op_str_t &opstr) const
|
||||||
{
|
{
|
||||||
if (opstr.op == OpCode_FontName)
|
if (opstr.op == OpCode_FontName)
|
||||||
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_FontName);
|
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_FontName);
|
||||||
|
@ -256,12 +256,12 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CFFFontDict_OpSerializer SUPER;
|
typedef cff_font_dict_op_serializer_t SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam>
|
struct cff1_cs_opset_flatten_t : cff1_cs_opset_t<cff1_cs_opset_flatten_t, flatten_param_t>
|
||||||
{
|
{
|
||||||
static void flush_args_and_op (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param)
|
static void flush_args_and_op (OpCode op, cff1_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
if (env.arg_start > 0)
|
if (env.arg_start > 0)
|
||||||
flush_width (env, param);
|
flush_width (env, param);
|
||||||
|
@ -287,43 +287,43 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void flush_args (CFF1CSInterpEnv &env, FlattenParam& param)
|
static void flush_args (cff1_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
StrEncoder encoder (param.flatStr);
|
str_encoder_t encoder (param.flatStr);
|
||||||
for (unsigned int i = env.arg_start; i < env.argStack.get_count (); i++)
|
for (unsigned int i = env.arg_start; i < env.argStack.get_count (); i++)
|
||||||
encoder.encode_num (env.eval_arg (i));
|
encoder.encode_num (env.eval_arg (i));
|
||||||
SUPER::flush_args (env, param);
|
SUPER::flush_args (env, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_op (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param)
|
static void flush_op (OpCode op, cff1_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
StrEncoder encoder (param.flatStr);
|
str_encoder_t encoder (param.flatStr);
|
||||||
encoder.encode_op (op);
|
encoder.encode_op (op);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_width (CFF1CSInterpEnv &env, FlattenParam& param)
|
static void flush_width (cff1_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
assert (env.has_width);
|
assert (env.has_width);
|
||||||
StrEncoder encoder (param.flatStr);
|
str_encoder_t encoder (param.flatStr);
|
||||||
encoder.encode_num (env.width);
|
encoder.encode_num (env.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_hintmask (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param)
|
static void flush_hintmask (OpCode op, cff1_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
SUPER::flush_hintmask (op, env, param);
|
SUPER::flush_hintmask (op, env, param);
|
||||||
if (!param.drop_hints)
|
if (!param.drop_hints)
|
||||||
{
|
{
|
||||||
StrEncoder encoder (param.flatStr);
|
str_encoder_t encoder (param.flatStr);
|
||||||
for (unsigned int i = 0; i < env.hintmask_size; i++)
|
for (unsigned int i = 0; i < env.hintmask_size; i++)
|
||||||
encoder.encode_byte (env.str_ref[i]);
|
encoder.encode_byte (env.str_ref[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam> SUPER;
|
typedef cff1_cs_opset_t<cff1_cs_opset_flatten_t, flatten_param_t> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RangeList : hb_vector_t<code_pair>
|
struct range_list_t : hb_vector_t<code_pair_t>
|
||||||
{
|
{
|
||||||
/* replace the first glyph ID in the "glyph" field each range with a nLeft value */
|
/* replace the first glyph ID in the "glyph" field each range with a nLeft value */
|
||||||
bool finalize (unsigned int last_glyph)
|
bool finalize (unsigned int last_glyph)
|
||||||
|
@ -331,7 +331,7 @@ struct RangeList : hb_vector_t<code_pair>
|
||||||
bool two_byte = false;
|
bool two_byte = false;
|
||||||
for (unsigned int i = (*this).len; i > 0; i--)
|
for (unsigned int i = (*this).len; i > 0; i--)
|
||||||
{
|
{
|
||||||
code_pair &pair = (*this)[i - 1];
|
code_pair_t &pair = (*this)[i - 1];
|
||||||
unsigned int nLeft = last_glyph - pair.glyph - 1;
|
unsigned int nLeft = last_glyph - pair.glyph - 1;
|
||||||
if (nLeft >= 0x100)
|
if (nLeft >= 0x100)
|
||||||
two_byte = true;
|
two_byte = true;
|
||||||
|
@ -342,9 +342,9 @@ struct RangeList : hb_vector_t<code_pair>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetParam>
|
struct cff1_cs_opset_subr_subset_t : cff1_cs_opset_t<cff1_cs_opset_subr_subset_t, subr_subset_param_t>
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, CFF1CSInterpEnv &env, SubrSubsetParam& param)
|
static void process_op (OpCode op, cff1_cs_interp_env_t &env, subr_subset_param_t& param)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
|
||||||
|
@ -378,8 +378,8 @@ struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetPa
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void process_call_subr (OpCode op, CSType type,
|
static void process_call_subr (OpCode op, CSType type,
|
||||||
CFF1CSInterpEnv &env, SubrSubsetParam& param,
|
cff1_cs_interp_env_t &env, subr_subset_param_t& param,
|
||||||
CFF1BiasedSubrs& subrs, hb_set_t *closure)
|
cff1_biased_subrs_t& subrs, hb_set_t *closure)
|
||||||
{
|
{
|
||||||
byte_str_ref_t str_ref = env.str_ref;
|
byte_str_ref_t str_ref = env.str_ref;
|
||||||
env.callSubr (subrs, type);
|
env.callSubr (subrs, type);
|
||||||
|
@ -389,12 +389,12 @@ struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetPa
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetParam> SUPER;
|
typedef cff1_cs_opset_t<cff1_cs_opset_subr_subset_t, subr_subset_param_t> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF1SubrSubsetter : SubrSubsetter<CFF1SubrSubsetter, CFF1Subrs, const OT::cff1::accelerator_subset_t, CFF1CSInterpEnv, CFF1CSOpSet_SubrSubset>
|
struct cff1_subr_subsetter_t : subr_subsetter_t<cff1_subr_subsetter_t, CFF1Subrs, const OT::cff1::accelerator_subset_t, cff1_cs_interp_env_t, cff1_cs_opset_subr_subset_t>
|
||||||
{
|
{
|
||||||
static void finalize_parsed_str (CFF1CSInterpEnv &env, SubrSubsetParam& param, ParsedCStr &charstring)
|
static void finalize_parsed_str (cff1_cs_interp_env_t &env, subr_subset_param_t& param, parsed_cs_str_t &charstring)
|
||||||
{
|
{
|
||||||
/* insert width at the beginning of the charstring as necessary */
|
/* insert width at the beginning of the charstring as necessary */
|
||||||
if (env.has_width)
|
if (env.has_width)
|
||||||
|
@ -406,7 +406,7 @@ struct CFF1SubrSubsetter : SubrSubsetter<CFF1SubrSubsetter, CFF1Subrs, const OT:
|
||||||
param.current_parsed_str->set_parsed ();
|
param.current_parsed_str->set_parsed ();
|
||||||
for (unsigned int i = 0; i < env.callStack.get_count (); i++)
|
for (unsigned int i = 0; i < env.callStack.get_count (); i++)
|
||||||
{
|
{
|
||||||
ParsedCStr *parsed_str = param.get_parsed_str_for_context (env.callStack[i]);
|
parsed_cs_str_t *parsed_str = param.get_parsed_str_for_context (env.callStack[i]);
|
||||||
if (likely (parsed_str != nullptr))
|
if (likely (parsed_str != nullptr))
|
||||||
parsed_str->set_parsed ();
|
parsed_str->set_parsed ();
|
||||||
else
|
else
|
||||||
|
@ -438,7 +438,7 @@ struct cff_subset_plan {
|
||||||
subset_enc_supp_codes.init ();
|
subset_enc_supp_codes.init ();
|
||||||
subset_charset_ranges.init ();
|
subset_charset_ranges.init ();
|
||||||
sidmap.init ();
|
sidmap.init ();
|
||||||
for (unsigned int i = 0; i < NameDictValues::ValCount; i++)
|
for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++)
|
||||||
topDictModSIDs[i] = CFF_UNDEF_SID;
|
topDictModSIDs[i] = CFF_UNDEF_SID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ struct cff_subset_plan {
|
||||||
|
|
||||||
if (code != last_code + 1)
|
if (code != last_code + 1)
|
||||||
{
|
{
|
||||||
code_pair pair = { code, glyph };
|
code_pair_t pair = { code, glyph };
|
||||||
subset_enc_code_ranges.push (pair);
|
subset_enc_code_ranges.push (pair);
|
||||||
}
|
}
|
||||||
last_code = code;
|
last_code = code;
|
||||||
|
@ -495,7 +495,7 @@ struct cff_subset_plan {
|
||||||
encoding->get_supplement_codes (sid, supp_codes);
|
encoding->get_supplement_codes (sid, supp_codes);
|
||||||
for (unsigned int i = 0; i < supp_codes.len; i++)
|
for (unsigned int i = 0; i < supp_codes.len; i++)
|
||||||
{
|
{
|
||||||
code_pair pair = { supp_codes[i], sid };
|
code_pair_t pair = { supp_codes[i], sid };
|
||||||
subset_enc_supp_codes.push (pair);
|
subset_enc_supp_codes.push (pair);
|
||||||
}
|
}
|
||||||
supp_size += SuppEncoding::static_size * supp_codes.len;
|
supp_size += SuppEncoding::static_size * supp_codes.len;
|
||||||
|
@ -537,7 +537,7 @@ struct cff_subset_plan {
|
||||||
|
|
||||||
if (sid != last_sid + 1)
|
if (sid != last_sid + 1)
|
||||||
{
|
{
|
||||||
code_pair pair = { sid, glyph };
|
code_pair_t pair = { sid, glyph };
|
||||||
subset_charset_ranges.push (pair);
|
subset_charset_ranges.push (pair);
|
||||||
}
|
}
|
||||||
last_sid = sid;
|
last_sid = sid;
|
||||||
|
@ -568,7 +568,7 @@ struct cff_subset_plan {
|
||||||
if (unlikely (!sidmap.reset (acc.stringIndex->count)))
|
if (unlikely (!sidmap.reset (acc.stringIndex->count)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < NameDictValues::ValCount; i++)
|
for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++)
|
||||||
{
|
{
|
||||||
unsigned int sid = acc.topDict.nameSIDs[i];
|
unsigned int sid = acc.topDict.nameSIDs[i];
|
||||||
if (sid != CFF_UNDEF_SID)
|
if (sid != CFF_UNDEF_SID)
|
||||||
|
@ -632,12 +632,12 @@ struct cff_subset_plan {
|
||||||
topdict_mod.add_op (OpCode_charset);
|
topdict_mod.add_op (OpCode_charset);
|
||||||
}
|
}
|
||||||
offsets.topDictInfo.offset = final_size;
|
offsets.topDictInfo.offset = final_size;
|
||||||
CFF1TopDict_OpSerializer topSzr;
|
cff1_top_dict_op_serializer_t topSzr;
|
||||||
unsigned int topDictSize = TopDict::calculate_serialized_size (topdict_mod, topSzr);
|
unsigned int topDictSize = TopDict::calculate_serialized_size (topdict_mod, topSzr);
|
||||||
offsets.topDictInfo.offSize = calcOffSize(topDictSize);
|
offsets.topDictInfo.offSize = calcOffSize(topDictSize);
|
||||||
if (unlikely (offsets.topDictInfo.offSize > 4))
|
if (unlikely (offsets.topDictInfo.offSize > 4))
|
||||||
return false;
|
return false;
|
||||||
final_size += CFF1IndexOf<TopDict>::calculate_serialized_size<CFF1TopDictValuesMod>
|
final_size += CFF1IndexOf<TopDict>::calculate_serialized_size<cff1_top_dict_values_mod_t>
|
||||||
(offsets.topDictInfo.offSize,
|
(offsets.topDictInfo.offSize,
|
||||||
&topdict_mod, 1, topdict_sizes, topSzr);
|
&topdict_mod, 1, topdict_sizes, topSzr);
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ struct cff_subset_plan {
|
||||||
if (desubroutinize)
|
if (desubroutinize)
|
||||||
{
|
{
|
||||||
/* Flatten global & local subrs */
|
/* Flatten global & local subrs */
|
||||||
SubrFlattener<const OT::cff1::accelerator_subset_t, CFF1CSInterpEnv, CFF1CSOpSet_Flatten>
|
subr_flattener_t<const OT::cff1::accelerator_subset_t, cff1_cs_interp_env_t, cff1_cs_opset_flatten_t>
|
||||||
flattener(acc, plan->glyphs, plan->drop_hints);
|
flattener(acc, plan->glyphs, plan->drop_hints);
|
||||||
if (!flattener.flatten (subset_charstrings))
|
if (!flattener.flatten (subset_charstrings))
|
||||||
return false;
|
return false;
|
||||||
|
@ -766,7 +766,7 @@ struct cff_subset_plan {
|
||||||
/* FDArray (FDIndex) */
|
/* FDArray (FDIndex) */
|
||||||
if (acc.fdArray != &Null(CFF1FDArray)) {
|
if (acc.fdArray != &Null(CFF1FDArray)) {
|
||||||
offsets.FDArrayInfo.offset = final_size;
|
offsets.FDArrayInfo.offset = final_size;
|
||||||
CFF1FontDict_OpSerializer fontSzr;
|
cff1_font_dict_op_serializer_t fontSzr;
|
||||||
unsigned int dictsSize = 0;
|
unsigned int dictsSize = 0;
|
||||||
for (unsigned int i = 0; i < acc.fontDicts.len; i++)
|
for (unsigned int i = 0; i < acc.fontDicts.len; i++)
|
||||||
if (fdmap.includes (i))
|
if (fdmap.includes (i))
|
||||||
|
@ -795,12 +795,12 @@ struct cff_subset_plan {
|
||||||
if (fdmap.includes (i))
|
if (fdmap.includes (i))
|
||||||
{
|
{
|
||||||
bool has_localsubrs = offsets.localSubrsInfos[i].size > 0;
|
bool has_localsubrs = offsets.localSubrsInfos[i].size > 0;
|
||||||
CFFPrivateDict_OpSerializer privSzr (desubroutinize, plan->drop_hints);
|
cff_private_dict_op_serializer_t privSzr (desubroutinize, plan->drop_hints);
|
||||||
unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs);
|
unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs);
|
||||||
TableInfo privInfo = { final_size, priv_size, 0 };
|
table_info_t privInfo = { final_size, priv_size, 0 };
|
||||||
FontDictValuesMod fontdict_mod;
|
font_dict_values_mod_t fontdict_mod;
|
||||||
if (!acc.is_CID ())
|
if (!acc.is_CID ())
|
||||||
fontdict_mod.init ( &Null(CFF1FontDictValues), CFF_UNDEF_SID, privInfo );
|
fontdict_mod.init ( &Null(cff1_font_dict_values_t), CFF_UNDEF_SID, privInfo );
|
||||||
else
|
else
|
||||||
fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo );
|
fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo );
|
||||||
fontdicts_mod.push (fontdict_mod);
|
fontdicts_mod.push (fontdict_mod);
|
||||||
|
@ -825,23 +825,23 @@ struct cff_subset_plan {
|
||||||
|
|
||||||
unsigned int final_size;
|
unsigned int final_size;
|
||||||
hb_vector_t<unsigned int> topdict_sizes;
|
hb_vector_t<unsigned int> topdict_sizes;
|
||||||
CFF1TopDictValuesMod topdict_mod;
|
cff1_top_dict_values_mod_t topdict_mod;
|
||||||
CFF1SubTableOffsets offsets;
|
cff1_sub_table_offsets_t offsets;
|
||||||
|
|
||||||
unsigned int num_glyphs;
|
unsigned int num_glyphs;
|
||||||
unsigned int orig_fdcount;
|
unsigned int orig_fdcount;
|
||||||
unsigned int subset_fdcount;
|
unsigned int subset_fdcount;
|
||||||
unsigned int subset_fdselect_format;
|
unsigned int subset_fdselect_format;
|
||||||
hb_vector_t<code_pair> subset_fdselect_ranges;
|
hb_vector_t<code_pair_t> subset_fdselect_ranges;
|
||||||
|
|
||||||
/* font dict index remap table from fullset FDArray to subset FDArray.
|
/* font dict index remap table from fullset FDArray to subset FDArray.
|
||||||
* set to CFF_UNDEF_CODE if excluded from subset */
|
* set to CFF_UNDEF_CODE if excluded from subset */
|
||||||
Remap fdmap;
|
remap_t fdmap;
|
||||||
|
|
||||||
StrBuffArray subset_charstrings;
|
str_buff_vec_t subset_charstrings;
|
||||||
StrBuffArray subset_globalsubrs;
|
str_buff_vec_t subset_globalsubrs;
|
||||||
hb_vector_t<StrBuffArray> subset_localsubrs;
|
hb_vector_t<str_buff_vec_t> subset_localsubrs;
|
||||||
hb_vector_t<FontDictValuesMod> fontdicts_mod;
|
hb_vector_t<font_dict_values_mod_t> fontdicts_mod;
|
||||||
|
|
||||||
bool drop_hints;
|
bool drop_hints;
|
||||||
|
|
||||||
|
@ -849,18 +849,18 @@ struct cff_subset_plan {
|
||||||
bool subset_encoding;
|
bool subset_encoding;
|
||||||
uint8_t subset_enc_format;
|
uint8_t subset_enc_format;
|
||||||
unsigned int subset_enc_num_codes;
|
unsigned int subset_enc_num_codes;
|
||||||
RangeList subset_enc_code_ranges;
|
range_list_t subset_enc_code_ranges;
|
||||||
hb_vector_t<code_pair> subset_enc_supp_codes;
|
hb_vector_t<code_pair_t> subset_enc_supp_codes;
|
||||||
|
|
||||||
uint8_t subset_charset_format;
|
uint8_t subset_charset_format;
|
||||||
RangeList subset_charset_ranges;
|
range_list_t subset_charset_ranges;
|
||||||
bool subset_charset;
|
bool subset_charset;
|
||||||
|
|
||||||
RemapSID sidmap;
|
remap_sid_t sidmap;
|
||||||
unsigned int topDictModSIDs[NameDictValues::ValCount];
|
unsigned int topDictModSIDs[name_dict_values_t::ValCount];
|
||||||
|
|
||||||
bool desubroutinize;
|
bool desubroutinize;
|
||||||
CFF1SubrSubsetter subr_subsetter;
|
cff1_subr_subsetter_t subr_subsetter;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool _write_cff1 (const cff_subset_plan &plan,
|
static inline bool _write_cff1 (const cff_subset_plan &plan,
|
||||||
|
@ -898,8 +898,8 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
|
||||||
assert (plan.offsets.topDictInfo.offset == c.head - c.start);
|
assert (plan.offsets.topDictInfo.offset == c.head - c.start);
|
||||||
CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > ();
|
CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > ();
|
||||||
if (dest == nullptr) return false;
|
if (dest == nullptr) return false;
|
||||||
CFF1TopDict_OpSerializer topSzr;
|
cff1_top_dict_op_serializer_t topSzr;
|
||||||
TopDictModifiers modifier (plan.offsets, plan.topDictModSIDs);
|
top_dict_modifiers_t modifier (plan.offsets, plan.topDictModSIDs);
|
||||||
if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize,
|
if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize,
|
||||||
&plan.topdict_mod, 1,
|
&plan.topdict_mod, 1,
|
||||||
plan.topdict_sizes, topSzr, modifier)))
|
plan.topdict_sizes, topSzr, modifier)))
|
||||||
|
@ -988,7 +988,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
|
||||||
assert (plan.offsets.FDArrayInfo.offset == c.head - c.start);
|
assert (plan.offsets.FDArrayInfo.offset == c.head - c.start);
|
||||||
CFF1FDArray *fda = c.start_embed<CFF1FDArray> ();
|
CFF1FDArray *fda = c.start_embed<CFF1FDArray> ();
|
||||||
if (unlikely (fda == nullptr)) return false;
|
if (unlikely (fda == nullptr)) return false;
|
||||||
CFF1FontDict_OpSerializer fontSzr;
|
cff1_font_dict_op_serializer_t fontSzr;
|
||||||
if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize,
|
if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize,
|
||||||
plan.fontdicts_mod,
|
plan.fontdicts_mod,
|
||||||
fontSzr)))
|
fontSzr)))
|
||||||
|
@ -1020,7 +1020,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
|
||||||
if (unlikely (pd == nullptr)) return false;
|
if (unlikely (pd == nullptr)) return false;
|
||||||
unsigned int priv_size = plan.fontdicts_mod[plan.fdmap[i]].privateDictInfo.size;
|
unsigned int priv_size = plan.fontdicts_mod[plan.fdmap[i]].privateDictInfo.size;
|
||||||
bool result;
|
bool result;
|
||||||
CFFPrivateDict_OpSerializer privSzr (plan.desubroutinize, plan.drop_hints);
|
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
|
||||||
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
|
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
|
||||||
unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
|
unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
|
||||||
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset);
|
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset);
|
||||||
|
|
|
@ -34,21 +34,21 @@
|
||||||
|
|
||||||
using namespace CFF;
|
using namespace CFF;
|
||||||
|
|
||||||
struct CFF2SubTableOffsets : CFFSubTableOffsets
|
struct cff2_sub_table_offsets_t : cff_sub_table_offsets_t
|
||||||
{
|
{
|
||||||
CFF2SubTableOffsets ()
|
cff2_sub_table_offsets_t ()
|
||||||
: CFFSubTableOffsets (),
|
: cff_sub_table_offsets_t (),
|
||||||
varStoreOffset (0)
|
varStoreOffset (0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
unsigned int varStoreOffset;
|
unsigned int varStoreOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
|
struct cff2_top_dict_op_serializer_t : cff_top_dict_op_serializer_t<>
|
||||||
{
|
{
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
const OpStr &opstr,
|
const op_str_t &opstr,
|
||||||
const CFF2SubTableOffsets &offsets) const
|
const cff2_sub_table_offsets_t &offsets) const
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
|
||||||
return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset));
|
return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return_trace (CFFTopDict_OpSerializer<>::serialize (c, opstr, offsets));
|
return_trace (cff_top_dict_op_serializer_t<>::serialize (c, opstr, offsets));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculate_serialized_size (const OpStr &opstr) const
|
unsigned int calculate_serialized_size (const op_str_t &opstr) const
|
||||||
{
|
{
|
||||||
switch (opstr.op)
|
switch (opstr.op)
|
||||||
{
|
{
|
||||||
|
@ -70,14 +70,14 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
|
||||||
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
|
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr);
|
return cff_top_dict_op_serializer_t<>::calculate_serialized_size (opstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
struct cff2_cs_opset_flatten_t : cff2_cs_opset_t<cff2_cs_opset_flatten_t, flatten_param_t>
|
||||||
{
|
{
|
||||||
static void flush_args_and_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param)
|
static void flush_args_and_op (OpCode op, cff2_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
|
@ -105,11 +105,11 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_args (CFF2CSInterpEnv &env, FlattenParam& param)
|
static void flush_args (cff2_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < env.argStack.get_count ();)
|
for (unsigned int i = 0; i < env.argStack.get_count ();)
|
||||||
{
|
{
|
||||||
const BlendArg &arg = env.argStack[i];
|
const blend_arg_t &arg = env.argStack[i];
|
||||||
if (arg.blending ())
|
if (arg.blending ())
|
||||||
{
|
{
|
||||||
if (unlikely (!((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues))))
|
if (unlikely (!((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues))))
|
||||||
|
@ -122,7 +122,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StrEncoder encoder (param.flatStr);
|
str_encoder_t encoder (param.flatStr);
|
||||||
encoder.encode_num (arg);
|
encoder.encode_num (arg);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -130,13 +130,13 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
SUPER::flush_args (env, param);
|
SUPER::flush_args (env, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flatten_blends (const BlendArg &arg, unsigned int i, CFF2CSInterpEnv &env, FlattenParam& param)
|
static void flatten_blends (const blend_arg_t &arg, unsigned int i, cff2_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
/* flatten the default values */
|
/* flatten the default values */
|
||||||
StrEncoder encoder (param.flatStr);
|
str_encoder_t encoder (param.flatStr);
|
||||||
for (unsigned int j = 0; j < arg.numValues; j++)
|
for (unsigned int j = 0; j < arg.numValues; j++)
|
||||||
{
|
{
|
||||||
const BlendArg &arg1 = env.argStack[i + j];
|
const blend_arg_t &arg1 = env.argStack[i + j];
|
||||||
if (unlikely (!((arg1.blending () && (arg.numValues == arg1.numValues) && (arg1.valueIndex == j) &&
|
if (unlikely (!((arg1.blending () && (arg.numValues == arg1.numValues) && (arg1.valueIndex == j) &&
|
||||||
(arg1.deltas.len == env.get_region_count ())))))
|
(arg1.deltas.len == env.get_region_count ())))))
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
/* flatten deltas for each value */
|
/* flatten deltas for each value */
|
||||||
for (unsigned int j = 0; j < arg.numValues; j++)
|
for (unsigned int j = 0; j < arg.numValues; j++)
|
||||||
{
|
{
|
||||||
const BlendArg &arg1 = env.argStack[i + j];
|
const blend_arg_t &arg1 = env.argStack[i + j];
|
||||||
for (unsigned int k = 0; k < arg1.deltas.len; k++)
|
for (unsigned int k = 0; k < arg1.deltas.len; k++)
|
||||||
encoder.encode_num (arg1.deltas[k]);
|
encoder.encode_num (arg1.deltas[k]);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
encoder.encode_op (OpCode_blendcs);
|
encoder.encode_op (OpCode_blendcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param)
|
static void flush_op (OpCode op, cff2_cs_interp_env_t &env, flatten_param_t& param)
|
||||||
{
|
{
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
|
@ -165,19 +165,19 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
case OpCode_endchar:
|
case OpCode_endchar:
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
StrEncoder encoder (param.flatStr);
|
str_encoder_t encoder (param.flatStr);
|
||||||
encoder.encode_op (op);
|
encoder.encode_op (op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam> SUPER;
|
typedef cff2_cs_opset_t<cff2_cs_opset_flatten_t, flatten_param_t> SUPER;
|
||||||
typedef CSOpSet<BlendArg, CFF2CSOpSet_Flatten, CFF2CSOpSet_Flatten, CFF2CSInterpEnv, FlattenParam> CSOPSET;
|
typedef cs_opset_t<blend_arg_t, cff2_cs_opset_flatten_t, cff2_cs_opset_flatten_t, cff2_cs_interp_env_t, flatten_param_t> CSOPSET;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetParam>
|
struct cff2_cs_opset_subr_subset_t : cff2_cs_opset_t<cff2_cs_opset_subr_subset_t, subr_subset_param_t>
|
||||||
{
|
{
|
||||||
static void process_op (OpCode op, CFF2CSInterpEnv &env, SubrSubsetParam& param)
|
static void process_op (OpCode op, cff2_cs_interp_env_t &env, subr_subset_param_t& param)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
|
||||||
|
@ -209,8 +209,8 @@ struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetPa
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void process_call_subr (OpCode op, CSType type,
|
static void process_call_subr (OpCode op, CSType type,
|
||||||
CFF2CSInterpEnv &env, SubrSubsetParam& param,
|
cff2_cs_interp_env_t &env, subr_subset_param_t& param,
|
||||||
CFF2BiasedSubrs& subrs, hb_set_t *closure)
|
cff2_biased_subrs_t& subrs, hb_set_t *closure)
|
||||||
{
|
{
|
||||||
byte_str_ref_t str_ref = env.str_ref;
|
byte_str_ref_t str_ref = env.str_ref;
|
||||||
env.callSubr (subrs, type);
|
env.callSubr (subrs, type);
|
||||||
|
@ -220,17 +220,17 @@ struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetPa
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetParam> SUPER;
|
typedef cff2_cs_opset_t<cff2_cs_opset_subr_subset_t, subr_subset_param_t> SUPER;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFF2SubrSubsetter : SubrSubsetter<CFF2SubrSubsetter, CFF2Subrs, const OT::cff2::accelerator_subset_t, CFF2CSInterpEnv, CFF2CSOpSet_SubrSubset>
|
struct cff2_subr_subsetter_t : subr_subsetter_t<cff2_subr_subsetter_t, CFF2Subrs, const OT::cff2::accelerator_subset_t, cff2_cs_interp_env_t, cff2_cs_opset_subr_subset_t>
|
||||||
{
|
{
|
||||||
static void finalize_parsed_str (CFF2CSInterpEnv &env, SubrSubsetParam& param, ParsedCStr &charstring)
|
static void finalize_parsed_str (cff2_cs_interp_env_t &env, subr_subset_param_t& param, parsed_cs_str_t &charstring)
|
||||||
{
|
{
|
||||||
/* vsindex is inserted at the beginning of the charstring as necessary */
|
/* vsindex is inserted at the beginning of the charstring as necessary */
|
||||||
if (env.seen_vsindex ())
|
if (env.seen_vsindex ())
|
||||||
{
|
{
|
||||||
Number ivs;
|
number_t ivs;
|
||||||
ivs.set_int ((int)env.get_ivs ());
|
ivs.set_int ((int)env.get_ivs ());
|
||||||
charstring.set_prefix (ivs, OpCode_vsindexcs);
|
charstring.set_prefix (ivs, OpCode_vsindexcs);
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ struct cff2_subset_plan {
|
||||||
|
|
||||||
/* top dict */
|
/* top dict */
|
||||||
{
|
{
|
||||||
CFF2TopDict_OpSerializer topSzr;
|
cff2_top_dict_op_serializer_t topSzr;
|
||||||
offsets.topDictInfo.size = TopDict::calculate_serialized_size (acc.topDict, topSzr);
|
offsets.topDictInfo.size = TopDict::calculate_serialized_size (acc.topDict, topSzr);
|
||||||
final_size += offsets.topDictInfo.size;
|
final_size += offsets.topDictInfo.size;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ struct cff2_subset_plan {
|
||||||
if (desubroutinize)
|
if (desubroutinize)
|
||||||
{
|
{
|
||||||
/* Flatten global & local subrs */
|
/* Flatten global & local subrs */
|
||||||
SubrFlattener<const OT::cff2::accelerator_subset_t, CFF2CSInterpEnv, CFF2CSOpSet_Flatten>
|
subr_flattener_t<const OT::cff2::accelerator_subset_t, cff2_cs_interp_env_t, cff2_cs_opset_flatten_t>
|
||||||
flattener(acc, plan->glyphs, plan->drop_hints);
|
flattener(acc, plan->glyphs, plan->drop_hints);
|
||||||
if (!flattener.flatten (subset_charstrings))
|
if (!flattener.flatten (subset_charstrings))
|
||||||
return false;
|
return false;
|
||||||
|
@ -370,7 +370,7 @@ struct cff2_subset_plan {
|
||||||
/* FDArray (FDIndex) */
|
/* FDArray (FDIndex) */
|
||||||
{
|
{
|
||||||
offsets.FDArrayInfo.offset = final_size;
|
offsets.FDArrayInfo.offset = final_size;
|
||||||
CFFFontDict_OpSerializer fontSzr;
|
cff_font_dict_op_serializer_t fontSzr;
|
||||||
unsigned int dictsSize = 0;
|
unsigned int dictsSize = 0;
|
||||||
for (unsigned int i = 0; i < acc.fontDicts.len; i++)
|
for (unsigned int i = 0; i < acc.fontDicts.len; i++)
|
||||||
if (fdmap.includes (i))
|
if (fdmap.includes (i))
|
||||||
|
@ -395,9 +395,9 @@ struct cff2_subset_plan {
|
||||||
if (fdmap.includes (i))
|
if (fdmap.includes (i))
|
||||||
{
|
{
|
||||||
bool has_localsubrs = offsets.localSubrsInfos[i].size > 0;
|
bool has_localsubrs = offsets.localSubrsInfos[i].size > 0;
|
||||||
CFFPrivateDict_OpSerializer privSzr (desubroutinize, drop_hints);
|
cff_private_dict_op_serializer_t privSzr (desubroutinize, drop_hints);
|
||||||
unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs);
|
unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs);
|
||||||
TableInfo privInfo = { final_size, priv_size, 0 };
|
table_info_t privInfo = { final_size, priv_size, 0 };
|
||||||
privateDictInfos.push (privInfo);
|
privateDictInfos.push (privInfo);
|
||||||
final_size += privInfo.size;
|
final_size += privInfo.size;
|
||||||
|
|
||||||
|
@ -415,23 +415,23 @@ struct cff2_subset_plan {
|
||||||
unsigned int get_final_size () const { return final_size; }
|
unsigned int get_final_size () const { return final_size; }
|
||||||
|
|
||||||
unsigned int final_size;
|
unsigned int final_size;
|
||||||
CFF2SubTableOffsets offsets;
|
cff2_sub_table_offsets_t offsets;
|
||||||
|
|
||||||
unsigned int orig_fdcount;
|
unsigned int orig_fdcount;
|
||||||
unsigned int subset_fdcount;
|
unsigned int subset_fdcount;
|
||||||
unsigned int subset_fdselect_format;
|
unsigned int subset_fdselect_format;
|
||||||
hb_vector_t<code_pair> subset_fdselect_ranges;
|
hb_vector_t<code_pair_t> subset_fdselect_ranges;
|
||||||
|
|
||||||
Remap fdmap;
|
remap_t fdmap;
|
||||||
|
|
||||||
StrBuffArray subset_charstrings;
|
str_buff_vec_t subset_charstrings;
|
||||||
StrBuffArray subset_globalsubrs;
|
str_buff_vec_t subset_globalsubrs;
|
||||||
hb_vector_t<StrBuffArray> subset_localsubrs;
|
hb_vector_t<str_buff_vec_t> subset_localsubrs;
|
||||||
hb_vector_t<TableInfo> privateDictInfos;
|
hb_vector_t<table_info_t> privateDictInfos;
|
||||||
|
|
||||||
bool drop_hints;
|
bool drop_hints;
|
||||||
bool desubroutinize;
|
bool desubroutinize;
|
||||||
CFF2SubrSubsetter subr_subsetter;
|
cff2_subr_subsetter_t subr_subsetter;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool _write_cff2 (const cff2_subset_plan &plan,
|
static inline bool _write_cff2 (const cff2_subset_plan &plan,
|
||||||
|
@ -456,7 +456,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
|
||||||
assert (cff2->topDict == c.head - c.start);
|
assert (cff2->topDict == c.head - c.start);
|
||||||
cff2->topDictSize.set (plan.offsets.topDictInfo.size);
|
cff2->topDictSize.set (plan.offsets.topDictInfo.size);
|
||||||
TopDict &dict = cff2 + cff2->topDict;
|
TopDict &dict = cff2 + cff2->topDict;
|
||||||
CFF2TopDict_OpSerializer topSzr;
|
cff2_top_dict_op_serializer_t topSzr;
|
||||||
if (unlikely (!dict.serialize (&c, acc.topDict, topSzr, plan.offsets)))
|
if (unlikely (!dict.serialize (&c, acc.topDict, topSzr, plan.offsets)))
|
||||||
{
|
{
|
||||||
DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 top dict");
|
DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 top dict");
|
||||||
|
@ -507,7 +507,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
|
||||||
assert (plan.offsets.FDArrayInfo.offset == c.head - c.start);
|
assert (plan.offsets.FDArrayInfo.offset == c.head - c.start);
|
||||||
CFF2FDArray *fda = c.start_embed<CFF2FDArray> ();
|
CFF2FDArray *fda = c.start_embed<CFF2FDArray> ();
|
||||||
if (unlikely (fda == nullptr)) return false;
|
if (unlikely (fda == nullptr)) return false;
|
||||||
CFFFontDict_OpSerializer fontSzr;
|
cff_font_dict_op_serializer_t fontSzr;
|
||||||
if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize,
|
if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize,
|
||||||
acc.fontDicts, plan.subset_fdcount, plan.fdmap,
|
acc.fontDicts, plan.subset_fdcount, plan.fdmap,
|
||||||
fontSzr, plan.privateDictInfos)))
|
fontSzr, plan.privateDictInfos)))
|
||||||
|
@ -539,7 +539,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
|
||||||
if (unlikely (pd == nullptr)) return false;
|
if (unlikely (pd == nullptr)) return false;
|
||||||
unsigned int priv_size = plan.privateDictInfos[plan.fdmap[i]].size;
|
unsigned int priv_size = plan.privateDictInfos[plan.fdmap[i]].size;
|
||||||
bool result;
|
bool result;
|
||||||
CFFPrivateDict_OpSerializer privSzr (plan.desubroutinize, plan.drop_hints);
|
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
|
||||||
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
|
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
|
||||||
unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
|
unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
|
||||||
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset);
|
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset);
|
||||||
|
|
Loading…
Reference in New Issue