CFF renaming (#1507)

* reimplement ByteStr as byte_str_t based on hb_ubytes_t

Unuse start_embed<ByteStr>
Also renamed SubByteStr to byte_str_ref_t
More renaming to come

* substr renamed to str_ref in line with its type byte_str_ref_t

* uncamelize non-table struct names

* uncamelized non-struct types OpCode etc

* add byte_str_t copy ctor

* test

* test2

* undo tests

* fix bot failure

* undo the previous change

* fixed tabs, added inline

* Revert "fixed tabs, added inline"

This reverts commit 21163c30e9.

* fix tabs
This commit is contained in:
Michiharu Ariza 2018-12-22 07:47:04 -08:00 committed by Behdad Esfahbod
parent 89d04129e2
commit 29f0b6bce7
14 changed files with 795 additions and 818 deletions

View File

@ -30,7 +30,7 @@ namespace CFF {
using namespace OT;
typedef unsigned int OpCode;
typedef unsigned int op_code_t;
/* === Dict operators === */
@ -88,11 +88,11 @@ typedef unsigned int OpCode;
/* Two byte escape operators 12, (0-41) */
#define OpCode_ESC_Base 256
#define Make_OpCode_ESC(byte2) ((OpCode)(OpCode_ESC_Base + (byte2)))
#define Make_OpCode_ESC(byte2) ((op_code_t)(OpCode_ESC_Base + (byte2)))
inline OpCode Unmake_OpCode_ESC (OpCode op) { return (OpCode)(op - OpCode_ESC_Base); }
inline bool Is_OpCode_ESC (OpCode op) { return op >= OpCode_ESC_Base; }
inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op) ? 2: 1; }
inline op_code_t Unmake_OpCode_ESC (op_code_t op) { return (op_code_t)(op - OpCode_ESC_Base); }
inline bool Is_OpCode_ESC (op_code_t op) { return op >= OpCode_ESC_Base; }
inline unsigned int OpCode_Size (op_code_t op) { return Is_OpCode_ESC (op) ? 2: 1; }
#define OpCode_Copyright Make_OpCode_ESC(0) /* CFF Top */
#define OpCode_isFixedPitch Make_OpCode_ESC(1) /* CFF Top (false) */
@ -215,7 +215,7 @@ inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op) ? 2: 1;
#define OpCode_Invalid 0xFFFFu
struct Number
struct number_t
{
void init () { set_real (0.0); }
void fini () {}
@ -235,19 +235,19 @@ struct Number
bool in_int_range () const
{ 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 (); }
bool operator < (const Number &n) const
bool operator < (const number_t &n) const
{ return n > *this; }
bool operator >= (const Number &n) const
bool operator >= (const number_t &n) const
{ return !(*this < n); }
bool operator <= (const Number &n) const
bool operator <= (const number_t &n) const
{ return !(*this > n); }
const Number &operator += (const Number &n)
const number_t &operator += (const number_t &n)
{
set_real (to_real () + n.to_real ());
@ -263,7 +263,7 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
{
// encode 2-byte int (Dict/CharString) or 4-byte int (Dict)
template <typename INTTYPE, int minVal, int maxVal>
static bool serialize_int (hb_serialize_context_t *c, OpCode intOp, int value)
static bool serialize_int (hb_serialize_context_t *c, op_code_t intOp, int value)
{
TRACE_SERIALIZE (this);
@ -290,92 +290,73 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
/* Defining null_size allows a Null object may be created. Should be safe because:
* A descendent struct Dict uses a Null pointer to indicate a missing table,
* checked before access.
* ByteStr, a wrapper struct pairing a byte pointer along with its length, always
* byte_str_t, a wrapper struct pairing a byte pointer along with its length, always
* checks the length before access. A Null pointer is used as the initial pointer
* along with zero length by the default ctor.
*/
DEFINE_SIZE_MIN(0);
};
struct ByteStr
/* Holder of a section of byte string within a CFFIndex entry */
struct byte_str_t : hb_ubytes_t
{
ByteStr ()
: str (&Null(UnsizedByteStr)), len (0) {}
ByteStr (const UnsizedByteStr& s, unsigned int l)
: str (&s), len (l) {}
ByteStr (const char *s, unsigned int l=0)
: str ((const UnsizedByteStr *)s), len (l) {}
byte_str_t ()
: hb_ubytes_t () {}
byte_str_t (const UnsizedByteStr& s, unsigned int l)
: hb_ubytes_t ((const unsigned char*)&s, l) {}
byte_str_t (const unsigned char *s, unsigned int l)
: hb_ubytes_t (s, l) {}
byte_str_t (const hb_ubytes_t &ub) /* conversion from hb_ubytes_t */
: hb_ubytes_t (ub) {}
/* sub-string */
ByteStr (const ByteStr &bs, unsigned int offset, unsigned int len_)
{
str = (const UnsizedByteStr *)&bs.str[offset];
len = len_;
}
bool sanitize (hb_sanitize_context_t *c) const { return str->sanitize (c, len); }
const HBUINT8& operator [] (unsigned int i) const
{
if (likely (str && (i < len)))
return (*str)[i];
else
return Null(HBUINT8);
}
bool serialize (hb_serialize_context_t *c, const ByteStr &src)
{
TRACE_SERIALIZE (this);
HBUINT8 *dest = c->allocate_size<HBUINT8> (src.len);
if (unlikely (dest == nullptr))
return_trace (false);
memcpy (dest, src.str, src.len);
return_trace (true);
}
unsigned int get_size () const { return len; }
byte_str_t sub_str (unsigned int offset, unsigned int len_) const
{ return byte_str_t (hb_ubytes_t::sub_array (offset, len_)); }
bool check_limit (unsigned int offset, unsigned int count) const
{ return (offset + count <= len); }
const UnsizedByteStr *str;
unsigned int len;
{ return (offset + count <= length); }
};
struct SubByteStr
/* A byte string associated with the current offset and an error condition */
struct byte_str_ref_t
{
SubByteStr ()
byte_str_ref_t ()
{ init (); }
void init ()
{
str = ByteStr (0);
str = byte_str_t ();
offset = 0;
error = false;
}
void fini () {}
SubByteStr (const ByteStr &str_, unsigned int offset_ = 0)
byte_str_ref_t (const byte_str_t &str_, unsigned int offset_ = 0)
: str (str_), offset (offset_), error (false) {}
void reset (const ByteStr &str_, unsigned int offset_ = 0)
void reset (const byte_str_t &str_, unsigned int offset_ = 0)
{
str = str_;
offset = offset_;
error = false;
}
const HBUINT8& operator [] (int i) {
if (unlikely ((unsigned int)(offset + i) >= str.len))
const unsigned char& operator [] (int i) {
if (unlikely ((unsigned int)(offset + i) >= str.length))
{
set_error ();
return Null(HBUINT8);
return Null(unsigned char);
}
else
return str[offset + i];
}
operator ByteStr () const { return ByteStr (str, offset, str.len - offset); }
/* Conversion to byte_str_t */
operator byte_str_t () const { return str.sub_str (offset, str.length - offset); }
byte_str_t sub_str (unsigned int offset_, unsigned int len_) const
{ return str.sub_str (offset_, len_); }
bool avail (unsigned int count=1) const
{
@ -383,13 +364,13 @@ struct SubByteStr
}
void inc (unsigned int count=1)
{
if (likely (!in_error () && (offset <= str.len) && (offset + count <= str.len)))
if (likely (!in_error () && (offset <= str.length) && (offset + count <= str.length)))
{
offset += count;
}
else
{
offset = str.len;
offset = str.length;
set_error ();
}
}
@ -397,18 +378,18 @@ struct SubByteStr
void set_error () { error = true; }
bool in_error () const { return error; }
ByteStr str;
byte_str_t str;
unsigned int offset; /* beginning of the sub-string within str */
protected:
bool error;
};
typedef hb_vector_t<ByteStr> ByteStrArray;
typedef hb_vector_t<byte_str_t> byte_str_array_t;
/* stack */
template <typename ELEM, int LIMIT>
struct Stack
struct stack_t
{
void init ()
{
@ -505,8 +486,8 @@ struct Stack
};
/* argument stack */
template <typename ARG=Number>
struct ArgStack : Stack<ARG, 513>
template <typename ARG=number_t>
struct arg_stack_t : stack_t<ARG, 513>
{
void push_int (int v)
{
@ -541,18 +522,18 @@ struct ArgStack : Stack<ARG, 513>
return (unsigned)i;
}
void push_longint_from_substr (SubByteStr& substr)
void push_longint_from_substr (byte_str_ref_t& str_ref)
{
push_int ((substr[0] << 24) | (substr[1] << 16) | (substr[2] << 8) | (substr[3]));
substr.inc (4);
push_int ((str_ref[0] << 24) | (str_ref[1] << 16) | (str_ref[2] << 8) | (str_ref[3]));
str_ref.inc (4);
}
bool push_fixed_from_substr (SubByteStr& substr)
bool push_fixed_from_substr (byte_str_ref_t& str_ref)
{
if (unlikely (!substr.avail (4)))
if (unlikely (!str_ref.avail (4)))
return false;
push_fixed ((int32_t)*(const HBUINT32*)&substr[0]);
substr.inc (4);
push_fixed ((int32_t)*(const HBUINT32*)&str_ref[0]);
str_ref.inc (4);
return true;
}
@ -562,36 +543,36 @@ struct ArgStack : Stack<ARG, 513>
}
private:
typedef Stack<ARG, 513> S;
typedef stack_t<ARG, 513> S;
};
/* an operator prefixed by its operands in a byte string */
struct OpStr
struct op_str_t
{
void init () {}
void fini () {}
OpCode op;
ByteStr str;
op_code_t op;
byte_str_t str;
};
/* base of OP_SERIALIZER */
struct OpSerializer
struct op_serializer_t
{
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);
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.len);
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
if (unlikely (d == nullptr)) return_trace (false);
memcpy (d, &opstr.str.str[0], opstr.str.len);
memcpy (d, &opstr.str[0], opstr.str.length);
return_trace (true);
}
};
template <typename VAL>
struct ParsedValues
struct parsed_values_t
{
void init ()
{
@ -600,23 +581,23 @@ struct ParsedValues
}
void fini () { values.fini_deep (); }
void add_op (OpCode op, const SubByteStr& substr = SubByteStr ())
void add_op (op_code_t op, const byte_str_ref_t& str_ref = byte_str_ref_t ())
{
VAL *val = values.push ();
val->op = op;
val->str = ByteStr (substr.str, opStart, substr.offset - opStart);
opStart = substr.offset;
val->str = str_ref.str.sub_str (opStart, str_ref.offset - opStart);
opStart = str_ref.offset;
}
void add_op (OpCode op, const SubByteStr& substr, const VAL &v)
void add_op (op_code_t op, const byte_str_ref_t& str_ref, const VAL &v)
{
VAL *val = values.push (v);
val->op = op;
val->str = ByteStr (substr.str, opStart, substr.offset - opStart);
opStart = substr.offset;
val->str = str_ref.sub_str ( opStart, str_ref.offset - opStart);
opStart = str_ref.offset;
}
bool has_op (OpCode op) const
bool has_op (op_code_t op) const
{
for (unsigned int i = 0; i < get_count (); i++)
if (get_value (i).op == op) return true;
@ -631,35 +612,35 @@ struct ParsedValues
hb_vector_t<VAL> values;
};
template <typename ARG=Number>
struct InterpEnv
template <typename ARG=number_t>
struct interp_env_t
{
void init (const ByteStr &str_)
void init (const byte_str_t &str_)
{
substr.reset (str_);
str_ref.reset (str_);
argStack.init ();
error = false;
}
void fini () { argStack.fini (); }
bool in_error () const
{ return error || substr.in_error () || argStack.in_error (); }
{ return error || str_ref.in_error () || argStack.in_error (); }
void set_error () { error = true; }
OpCode fetch_op ()
op_code_t fetch_op ()
{
OpCode op = OpCode_Invalid;
if (unlikely (!substr.avail ()))
op_code_t op = OpCode_Invalid;
if (unlikely (!str_ref.avail ()))
return OpCode_Invalid;
op = (OpCode)(unsigned char)substr[0];
op = (op_code_t)(unsigned char)str_ref[0];
if (op == OpCode_escape) {
if (unlikely (!substr.avail ()))
if (unlikely (!str_ref.avail ()))
return OpCode_Invalid;
op = Make_OpCode_ESC(substr[1]);
substr.inc ();
op = Make_OpCode_ESC(str_ref[1]);
str_ref.inc ();
}
substr.inc ();
str_ref.inc ();
return op;
}
@ -683,35 +664,35 @@ struct InterpEnv
pop_n_args (argStack.get_count ());
}
SubByteStr substr;
ArgStack<ARG> argStack;
byte_str_ref_t str_ref;
arg_stack_t<ARG> argStack;
protected:
bool error;
};
typedef InterpEnv<> NumInterpEnv;
typedef interp_env_t<> num_interp_env_t;
template <typename ARG=Number>
struct OpSet
template <typename ARG=number_t>
struct opset_t
{
static void process_op (OpCode op, InterpEnv<ARG>& env)
static void process_op (op_code_t op, interp_env_t<ARG>& env)
{
switch (op) {
case OpCode_shortint:
env.argStack.push_int ((int16_t)((env.substr[0] << 8) | env.substr[1]));
env.substr.inc (2);
env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1]));
env.str_ref.inc (2);
break;
case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.substr[0] + 108));
env.substr.inc ();
env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108));
env.str_ref.inc ();
break;
case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.substr[0] - 108));
env.substr.inc ();
env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108));
env.str_ref.inc ();
break;
default:
@ -730,9 +711,9 @@ struct OpSet
};
template <typename ENV>
struct Interpreter {
struct interpreter_t {
~Interpreter() { fini (); }
~interpreter_t() { fini (); }
void fini () { env.fini (); }

View File

@ -33,34 +33,34 @@ namespace CFF {
using namespace OT;
enum CSType {
enum cs_type_t {
CSType_CharString,
CSType_GlobalSubr,
CSType_LocalSubr
};
struct CallContext
struct call_context_t
{
void init (const SubByteStr substr_=SubByteStr (), CSType type_=CSType_CharString, unsigned int subr_num_=0)
void init (const byte_str_ref_t substr_=byte_str_ref_t (), cs_type_t type_=CSType_CharString, unsigned int subr_num_=0)
{
substr = substr_;
str_ref = substr_;
type = type_;
subr_num = subr_num_;
}
void fini () {}
SubByteStr substr;
CSType type;
byte_str_ref_t str_ref;
cs_type_t type;
unsigned int subr_num;
};
/* call stack */
const unsigned int kMaxCallLimit = 10;
struct CallStack : Stack<CallContext, kMaxCallLimit> {};
struct call_stack_t : stack_t<call_context_t, kMaxCallLimit> {};
template <typename SUBRS>
struct BiasedSubrs
struct biased_subrs_t
{
void init (const SUBRS &subrs_)
{
@ -79,10 +79,10 @@ struct BiasedSubrs
unsigned int get_count () const { return (subrs == nullptr)? 0: subrs->count; }
unsigned int get_bias () const { return bias; }
ByteStr operator [] (unsigned int index) const
byte_str_t operator [] (unsigned int index) const
{
if (unlikely ((subrs == nullptr) || index >= subrs->count))
return Null(ByteStr);
return Null(byte_str_t);
else
return (*subrs)[index];
}
@ -92,7 +92,7 @@ struct BiasedSubrs
const SUBRS *subrs;
};
struct Point
struct point_t
{
void init ()
{
@ -106,21 +106,21 @@ struct Point
y.set_int (_y);
}
void move_x (const Number &dx) { x += dx; }
void move_y (const Number &dy) { y += dy; }
void move (const Number &dx, const Number &dy) { move_x (dx); move_y (dy); }
void move (const Point &d) { move_x (d.x); move_y (d.y); }
void move_x (const number_t &dx) { x += dx; }
void move_y (const number_t &dy) { y += dy; }
void move (const number_t &dx, const number_t &dy) { move_x (dx); move_y (dy); }
void move (const point_t &d) { move_x (d.x); move_y (d.y); }
Number x;
Number y;
number_t x;
number_t y;
};
template <typename ARG, typename SUBRS>
struct CSInterpEnv : InterpEnv<ARG>
struct cs_interp_env_t : interp_env_t<ARG>
{
void init (const ByteStr &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);
seen_moveto = true;
@ -134,7 +134,7 @@ struct CSInterpEnv : InterpEnv<ARG>
}
void fini ()
{
InterpEnv<ARG>::fini ();
interp_env_t<ARG>::fini ();
callStack.fini ();
globalSubrs.fini ();
@ -146,7 +146,7 @@ struct CSInterpEnv : InterpEnv<ARG>
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 ();
n += biasedSubrs.get_bias ();
@ -157,7 +157,7 @@ struct CSInterpEnv : InterpEnv<ARG>
return true;
}
void callSubr (const BiasedSubrs<SUBRS>& biasedSubrs, CSType type)
void callSubr (const biased_subrs_t<SUBRS>& biasedSubrs, cs_type_t type)
{
unsigned int subr_num;
@ -167,19 +167,19 @@ struct CSInterpEnv : InterpEnv<ARG>
SUPER::set_error ();
return;
}
context.substr = SUPER::substr;
context.str_ref = SUPER::str_ref;
callStack.push (context);
context.init ( biasedSubrs[subr_num], type, subr_num);
SUPER::substr = context.substr;
SUPER::str_ref = context.str_ref;
}
void returnFromSubr ()
{
if (unlikely (SUPER::substr.in_error ()))
if (unlikely (SUPER::str_ref.in_error ()))
SUPER::set_error ();
context = callStack.pop ();
SUPER::substr = context.substr;
SUPER::str_ref = context.str_ref;
}
void determine_hintmask_size ()
@ -195,14 +195,14 @@ struct CSInterpEnv : InterpEnv<ARG>
void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; }
bool is_endchar () const { return endchar_flag; }
const Number &get_x () const { return pt.x; }
const Number &get_y () const { return pt.y; }
const Point &get_pt () const { return pt; }
const number_t &get_x () const { return pt.x; }
const number_t &get_y () const { return pt.y; }
const point_t &get_pt () const { return pt; }
void moveto (const Point &pt_ ) { pt = pt_; }
void moveto (const point_t &pt_ ) { pt = pt_; }
public:
CallContext context;
call_context_t context;
bool endchar_flag;
bool seen_moveto;
bool seen_hintmask;
@ -210,18 +210,18 @@ struct CSInterpEnv : InterpEnv<ARG>
unsigned int hstem_count;
unsigned int vstem_count;
unsigned int hintmask_size;
CallStack callStack;
BiasedSubrs<SUBRS> globalSubrs;
BiasedSubrs<SUBRS> localSubrs;
call_stack_t callStack;
biased_subrs_t<SUBRS> globalSubrs;
biased_subrs_t<SUBRS> localSubrs;
private:
Point pt;
point_t pt;
typedef InterpEnv<ARG> SUPER;
typedef interp_env_t<ARG> SUPER;
};
template <typename ENV, typename PARAM>
struct PathProcsNull
struct path_procs_null_t
{
static void rmoveto (ENV &env, PARAM& param) {}
static void hmoveto (ENV &env, PARAM& param) {}
@ -236,19 +236,19 @@ struct PathProcsNull
static void hhcurveto (ENV &env, PARAM& param) {}
static void vhcurveto (ENV &env, PARAM& param) {}
static void hvcurveto (ENV &env, PARAM& param) {}
static void moveto (ENV &env, PARAM& param, const Point &pt) {}
static void line (ENV &env, PARAM& param, const Point &pt1) {}
static void curve (ENV &env, PARAM& param, const Point &pt1, const Point &pt2, const Point &pt3) {}
static void moveto (ENV &env, PARAM& param, const point_t &pt) {}
static void line (ENV &env, PARAM& param, const point_t &pt1) {}
static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &pt3) {}
static void hflex (ENV &env, PARAM& param) {}
static void flex (ENV &env, PARAM& param) {}
static void hflex1 (ENV &env, PARAM& param) {}
static void flex1 (ENV &env, PARAM& param) {}
};
template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=PathProcsNull<ENV, PARAM> >
struct CSOpSet : OpSet<ARG>
template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=path_procs_null_t<ENV, PARAM> >
struct cs_opset_t : opset_t<ARG>
{
static void process_op (OpCode op, ENV &env, PARAM& param)
static void process_op (op_code_t op, ENV &env, PARAM& param)
{
switch (op) {
@ -262,7 +262,7 @@ struct CSOpSet : OpSet<ARG>
break;
case OpCode_fixedcs:
env.argStack.push_fixed_from_substr (env.substr);
env.argStack.push_fixed_from_substr (env.str_ref);
break;
case OpCode_callsubr:
@ -370,37 +370,37 @@ struct CSOpSet : OpSet<ARG>
}
}
static void process_hstem (OpCode op, ENV &env, PARAM& param)
static void process_hstem (op_code_t op, ENV &env, PARAM& param)
{
env.hstem_count += env.argStack.get_count () / 2;
OPSET::flush_args_and_op (op, env, param);
}
static void process_vstem (OpCode op, ENV &env, PARAM& param)
static void process_vstem (op_code_t op, ENV &env, PARAM& param)
{
env.vstem_count += env.argStack.get_count () / 2;
OPSET::flush_args_and_op (op, env, param);
}
static void process_hintmask (OpCode op, ENV &env, PARAM& param)
static void process_hintmask (op_code_t op, ENV &env, PARAM& param)
{
env.determine_hintmask_size ();
if (likely (env.substr.avail (env.hintmask_size)))
if (likely (env.str_ref.avail (env.hintmask_size)))
{
OPSET::flush_hintmask (op, env, param);
env.substr.inc (env.hintmask_size);
env.str_ref.inc (env.hintmask_size);
}
}
static void process_post_flex (OpCode op, ENV &env, PARAM& param)
static void process_post_flex (op_code_t op, ENV &env, PARAM& param)
{
OPSET::flush_args_and_op (op, env, param);
}
static void check_width (OpCode op, ENV &env, PARAM& param)
static void check_width (op_code_t op, ENV &env, PARAM& param)
{}
static void process_post_move (OpCode op, ENV &env, PARAM& param)
static void process_post_move (op_code_t op, ENV &env, PARAM& param)
{
if (!env.seen_moveto)
{
@ -410,12 +410,12 @@ struct CSOpSet : OpSet<ARG>
OPSET::flush_args_and_op (op, env, param);
}
static void process_post_path (OpCode op, ENV &env, PARAM& param)
static void process_post_path (op_code_t op, ENV &env, PARAM& param)
{
OPSET::flush_args_and_op (op, env, param);
}
static void flush_args_and_op (OpCode op, ENV &env, PARAM& param)
static void flush_args_and_op (op_code_t op, ENV &env, PARAM& param)
{
OPSET::flush_args (env, param);
OPSET::flush_op (op, env, param);
@ -426,16 +426,16 @@ struct CSOpSet : OpSet<ARG>
env.pop_n_args (env.argStack.get_count ());
}
static void flush_op (OpCode op, ENV &env, PARAM& param)
static void flush_op (op_code_t op, ENV &env, PARAM& param)
{
}
static void flush_hintmask (OpCode op, ENV &env, PARAM& param)
static void flush_hintmask (op_code_t op, ENV &env, PARAM& param)
{
OPSET::flush_args_and_op (op, env, param);
}
static bool is_number_op (OpCode op)
static bool is_number_op (op_code_t op)
{
switch (op)
{
@ -454,31 +454,31 @@ struct CSOpSet : OpSet<ARG>
}
protected:
typedef OpSet<ARG> SUPER;
typedef opset_t<ARG> SUPER;
};
template <typename PATH, typename ENV, typename PARAM>
struct PathProcs
struct path_procs_t
{
static void rmoveto (ENV &env, PARAM& param)
{
Point pt1 = env.get_pt ();
const Number &dy = env.pop_arg ();
const Number &dx = env.pop_arg ();
point_t pt1 = env.get_pt ();
const number_t &dy = env.pop_arg ();
const number_t &dx = env.pop_arg ();
pt1.move (dx, dy);
PATH::moveto (env, param, pt1);
}
static void hmoveto (ENV &env, PARAM& param)
{
Point pt1 = env.get_pt ();
point_t pt1 = env.get_pt ();
pt1.move_x (env.pop_arg ());
PATH::moveto (env, param, pt1);
}
static void vmoveto (ENV &env, PARAM& param)
{
Point pt1 = env.get_pt ();
point_t pt1 = env.get_pt ();
pt1.move_y (env.pop_arg ());
PATH::moveto (env, param, pt1);
}
@ -487,7 +487,7 @@ struct PathProcs
{
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));
PATH::line (env, param, pt1);
}
@ -495,7 +495,7 @@ struct PathProcs
static void hlineto (ENV &env, PARAM& param)
{
Point pt1;
point_t pt1;
unsigned int i = 0;
for (; i + 2 <= env.argStack.get_count (); i += 2)
{
@ -515,7 +515,7 @@ struct PathProcs
static void vlineto (ENV &env, PARAM& param)
{
Point pt1;
point_t pt1;
unsigned int i = 0;
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)
{
Point pt1 = env.get_pt ();
point_t pt1 = env.get_pt ();
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));
Point pt3 = pt2;
point_t pt3 = pt2;
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
PATH::curve (env, param, pt1, pt2, pt3);
}
@ -552,17 +552,17 @@ struct PathProcs
unsigned int i = 0;
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));
Point pt2 = pt1;
point_t pt2 = pt1;
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));
PATH::curve (env, param, pt1, pt2, pt3);
}
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));
PATH::line (env, param, pt1);
}
@ -574,17 +574,17 @@ struct PathProcs
unsigned int line_limit = (env.argStack.get_count () % 6);
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));
PATH::line (env, param, pt1);
}
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));
Point pt2 = pt1;
point_t pt2 = pt1;
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));
PATH::curve (env, param, pt1, pt2, pt3);
}
@ -593,15 +593,15 @@ struct PathProcs
static void vvcurveto (ENV &env, PARAM& param)
{
unsigned int i = 0;
Point pt1 = env.get_pt ();
point_t pt1 = env.get_pt ();
if ((env.argStack.get_count () & 1) != 0)
pt1.move_x (env.eval_arg (i++));
for (; i + 4 <= env.argStack.get_count (); i += 4)
{
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));
Point pt3 = pt2;
point_t pt3 = pt2;
pt3.move_y (env.eval_arg (i+3));
PATH::curve (env, param, pt1, pt2, pt3);
pt1 = env.get_pt ();
@ -611,15 +611,15 @@ struct PathProcs
static void hhcurveto (ENV &env, PARAM& param)
{
unsigned int i = 0;
Point pt1 = env.get_pt ();
point_t pt1 = env.get_pt ();
if ((env.argStack.get_count () & 1) != 0)
pt1.move_y (env.eval_arg (i++));
for (; i + 4 <= env.argStack.get_count (); i += 4)
{
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));
Point pt3 = pt2;
point_t pt3 = pt2;
pt3.move_x (env.eval_arg (i+3));
PATH::curve (env, param, pt1, pt2, pt3);
pt1 = env.get_pt ();
@ -628,15 +628,15 @@ struct PathProcs
static void vhcurveto (ENV &env, PARAM& param)
{
Point pt1, pt2, pt3;
point_t pt1, pt2, pt3;
unsigned int i = 0;
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));
Point pt2 = pt1;
point_t pt2 = pt1;
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));
i += 4;
@ -689,15 +689,15 @@ struct PathProcs
static void hvcurveto (ENV &env, PARAM& param)
{
Point pt1, pt2, pt3;
point_t pt1, pt2, pt3;
unsigned int i = 0;
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));
Point pt2 = pt1;
point_t pt2 = pt1;
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));
i += 4;
@ -749,31 +749,31 @@ struct PathProcs
}
/* 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); }
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); }
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); }
static void hflex (ENV &env, PARAM& param)
{
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));
Point pt2 = pt1;
point_t pt2 = pt1;
pt2.move (env.eval_arg (1), env.eval_arg (2));
Point pt3 = pt2;
point_t pt3 = pt2;
pt3.move_x (env.eval_arg (3));
Point pt4 = pt3;
point_t pt4 = pt3;
pt4.move_x (env.eval_arg (4));
Point pt5 = pt4;
point_t pt5 = pt4;
pt5.move_x (env.eval_arg (5));
pt5.y = pt1.y;
Point pt6 = pt5;
point_t pt6 = pt5;
pt6.move_x (env.eval_arg (6));
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
@ -786,17 +786,17 @@ struct PathProcs
{
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));
Point pt2 = pt1;
point_t pt2 = pt1;
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));
Point pt4 = pt3;
point_t pt4 = pt3;
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));
Point pt6 = pt5;
point_t pt6 = pt5;
pt6.move (env.eval_arg (10), env.eval_arg (11));
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
@ -809,17 +809,17 @@ struct PathProcs
{
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));
Point pt2 = pt1;
point_t pt2 = pt1;
pt2.move (env.eval_arg (2), env.eval_arg (3));
Point pt3 = pt2;
point_t pt3 = pt2;
pt3.move_x (env.eval_arg (4));
Point pt4 = pt3;
point_t pt4 = pt3;
pt4.move_x (env.eval_arg (5));
Point pt5 = pt4;
point_t pt5 = pt4;
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.y = env.get_pt ().y;
@ -833,22 +833,22 @@ struct PathProcs
{
if (likely (env.argStack.get_count () == 11))
{
Point d;
point_t d;
d.init ();
for (unsigned int i = 0; i < 10; i += 2)
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));
Point pt2 = pt1;
point_t pt2 = pt1;
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));
Point pt4 = pt3;
point_t pt4 = pt3;
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));
Point pt6 = pt5;
point_t pt6 = pt5;
if (fabs (d.x.to_real ()) > fabs (d.y.to_real ()))
{
@ -869,8 +869,8 @@ struct PathProcs
protected:
static void curve2 (ENV &env, PARAM& param,
const Point &pt1, const Point &pt2, const Point &pt3,
const Point &pt4, const Point &pt5, const Point &pt6)
const point_t &pt1, const point_t &pt2, const point_t &pt3,
const point_t &pt4, const point_t &pt5, const point_t &pt6)
{
PATH::curve (env, param, pt1, pt2, pt3);
PATH::curve (env, param, pt4, pt5, pt6);
@ -878,7 +878,7 @@ struct PathProcs
};
template <typename ENV, typename OPSET, typename PARAM>
struct CSInterpreter : Interpreter<ENV>
struct cs_interpreter_t : interpreter_t<ENV>
{
bool interpret (PARAM& param)
{
@ -896,7 +896,7 @@ struct CSInterpreter : Interpreter<ENV>
}
private:
typedef Interpreter<ENV> SUPER;
typedef interpreter_t<ENV> SUPER;
};
} /* namespace CFF */

View File

@ -35,28 +35,28 @@ namespace CFF {
using namespace OT;
/* 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 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>
struct TopDictValues : DictValues<OPSTR>
template <typename OPSTR=op_str_t>
struct top_dict_values_t : dict_values_t<OPSTR>
{
void init ()
{
DictValues<OPSTR>::init ();
dict_values_t<OPSTR>::init ();
charStringsOffset = 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
{
@ -67,7 +67,7 @@ struct TopDictValues : DictValues<OPSTR>
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
default:
return opstr.str.len;
return opstr.str.length;
}
}
@ -75,26 +75,26 @@ struct TopDictValues : DictValues<OPSTR>
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 (op_code_t op, interp_env_t<number_t>& env)
{
switch (op) {
case OpCode_longintdict: /* 5-byte integer */
env.argStack.push_longint_from_substr (env.substr);
env.argStack.push_longint_from_substr (env.str_ref);
break;
case OpCode_BCD: /* real number */
env.argStack.push_real (parse_bcd (env.substr));
env.argStack.push_real (parse_bcd (env.str_ref));
break;
default:
OpSet<Number>::process_op (op, env);
opset_t<number_t>::process_op (op, env);
break;
}
}
static double parse_bcd (SubByteStr& substr)
static double parse_bcd (byte_str_ref_t& str_ref)
{
bool neg = false;
double int_part = 0;
@ -115,13 +115,13 @@ struct DictOpSet : OpSet<Number>
char d;
if ((i & 1) == 0)
{
if (!substr.avail ())
if (!str_ref.avail ())
{
substr.set_error ();
str_ref.set_error ();
return 0.0;
}
byte = substr[0];
substr.inc ();
byte = str_ref[0];
str_ref.inc ();
d = byte >> 4;
}
else
@ -130,7 +130,7 @@ struct DictOpSet : OpSet<Number>
switch (d)
{
case RESERVED:
substr.set_error ();
str_ref.set_error ();
return value;
case END:
@ -162,7 +162,7 @@ struct DictOpSet : OpSet<Number>
case NEG:
if (i != 0)
{
substr.set_error ();
str_ref.set_error ();
return 0.0;
}
neg = true;
@ -171,7 +171,7 @@ struct DictOpSet : OpSet<Number>
case DECIMAL:
if (part != INT_PART)
{
substr.set_error ();
str_ref.set_error ();
return value;
}
part = FRAC_PART;
@ -184,7 +184,7 @@ struct DictOpSet : OpSet<Number>
case EXP_POS:
if (part == EXP_PART)
{
substr.set_error ();
str_ref.set_error ();
return value;
}
part = EXP_PART;
@ -220,7 +220,7 @@ struct DictOpSet : OpSet<Number>
return value;
}
static bool is_hint_op (OpCode op)
static bool is_hint_op (op_code_t op)
{
switch (op)
{
@ -245,10 +245,10 @@ struct DictOpSet : OpSet<Number>
}
};
template <typename VAL=OpStr>
struct TopDictOpSet : DictOpSet
template <typename VAL=op_str_t>
struct top_dict_opset_t : dict_opset_t
{
static void process_op (OpCode op, InterpEnv<Number>& env, TopDictValues<VAL> & dictval)
static void process_op (op_code_t op, interp_env_t<number_t>& env, top_dict_values_t<VAL> & dictval)
{
switch (op) {
case OpCode_CharStrings:
@ -263,19 +263,19 @@ struct TopDictOpSet : DictOpSet
env.clear_args ();
break;
default:
DictOpSet::process_op (op, env);
dict_opset_t::process_op (op, env);
break;
}
}
};
template <typename OPSET, typename PARAM, typename ENV=NumInterpEnv>
struct DictInterpreter : Interpreter<ENV>
template <typename OPSET, typename PARAM, typename ENV=num_interp_env_t>
struct dict_interpreter_t : interpreter_t<ENV>
{
bool interpret (PARAM& param)
{
param.init ();
while (SUPER::env.substr.avail ())
while (SUPER::env.str_ref.avail ())
{
OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param);
if (unlikely (SUPER::env.in_error ()))
@ -286,7 +286,7 @@ struct DictInterpreter : Interpreter<ENV>
}
private:
typedef Interpreter<ENV> SUPER;
typedef interpreter_t<ENV> SUPER;
};
} /* namespace CFF */

View File

@ -33,12 +33,12 @@ namespace CFF {
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>
void init (const ByteStr &str, ACC &acc, unsigned int fd)
void init (const byte_str_t &str, ACC &acc, unsigned int fd)
{
SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
processed_width = false;
@ -74,20 +74,20 @@ struct CFF1CSInterpEnv : CSInterpEnv<Number, CFF1Subrs>
bool processed_width;
bool has_width;
unsigned int arg_start;
Number width;
number_t width;
bool in_seac;
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> >
struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH>
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM> >
struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
{
/* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
/* 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 (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
{
switch (op) {
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 (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
{
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);
env.clear_args (); /* pop off width */
}
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>
struct CFF1CSInterpreter : CSInterpreter<CFF1CSInterpEnv, OPSET, PARAM> {};
struct cff1_cs_interpreter_t : cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM> {};
} /* namespace CFF */

View File

@ -33,26 +33,26 @@ namespace CFF {
using namespace OT;
struct BlendArg : Number
struct blend_arg_t : number_t
{
void init ()
{
Number::init ();
number_t::init ();
deltas.init ();
}
void fini ()
{
Number::fini ();
number_t::fini ();
deltas.fini_deep ();
}
void set_int (int v) { reset_blends (); Number::set_int (v); }
void set_fixed (int32_t v) { reset_blends (); Number::set_fixed (v); }
void set_real (double v) { reset_blends (); Number::set_real (v); }
void set_int (int v) { reset_blends (); number_t::set_int (v); }
void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); }
void set_real (double v) { reset_blends (); number_t::set_real (v); }
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_;
valueIndex = valueIndex_;
@ -70,16 +70,16 @@ struct BlendArg : Number
unsigned int numValues;
unsigned int valueIndex;
hb_vector_t<Number> deltas;
hb_vector_t<number_t> deltas;
};
typedef InterpEnv<BlendArg> BlendInterpEnv;
typedef BiasedSubrs<CFF2Subrs> CFF2BiasedSubrs;
typedef interp_env_t<blend_arg_t> BlendInterpEnv;
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>
void init (const ByteStr &str, ACC &acc, unsigned int fd,
void init (const byte_str_t &str, ACC &acc, unsigned int fd,
const int *coords_=nullptr, unsigned int num_coords_=0)
{
SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
@ -100,9 +100,9 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
SUPER::fini ();
}
OpCode fetch_op ()
op_code_t fetch_op ()
{
if (this->substr.avail ())
if (this->str_ref.avail ())
return SUPER::fetch_op ();
/* make up return or endchar op */
@ -112,16 +112,16 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
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);
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);
return arg;
}
@ -163,7 +163,7 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
bool seen_vsindex () const { return seen_vsindex_; }
protected:
void blend_arg (BlendArg &arg)
void blend_arg (blend_arg_t &arg)
{
if (do_blend && arg.blending ())
{
@ -191,12 +191,12 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
bool seen_vsindex_;
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> >
struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff2_cs_interp_env_t, PARAM> >
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 (op_code_t op, cff2_cs_interp_env_t &env, PARAM& param)
{
switch (op) {
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;
@ -245,7 +245,7 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
}
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);
}
@ -253,18 +253,18 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
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.clear_args ();
}
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>
struct CFF2CSInterpreter : CSInterpreter<CFF2CSInterpEnv, OPSET, PARAM> {};
struct cff2_cs_interpreter_t : cs_interpreter_t<cff2_cs_interp_env_t, OPSET, PARAM> {};
} /* namespace CFF */

View File

@ -55,14 +55,14 @@ inline unsigned int calcOffSize(unsigned int dataSize)
return size;
}
struct code_pair
struct code_pair_t
{
hb_codepoint_t code;
hb_codepoint_t glyph;
};
typedef hb_vector_t<char, 1> StrBuff;
struct StrBuffArray : hb_vector_t<StrBuff>
typedef hb_vector_t<unsigned char, 1> str_buff_t;
struct str_buff_vec_t : hb_vector_t<str_buff_t>
{
void fini () { SUPER::fini_deep (); }
@ -75,7 +75,7 @@ struct StrBuffArray : hb_vector_t<StrBuff>
}
private:
typedef hb_vector_t<StrBuff> SUPER;
typedef hb_vector_t<str_buff_t> SUPER;
};
/* CFF INDEX */
@ -117,7 +117,7 @@ struct CFFIndex
bool serialize (hb_serialize_context_t *c,
unsigned int offSize_,
const ByteStrArray &byteArray)
const byte_str_array_t &byteArray)
{
TRACE_SERIALIZE (this);
if (byteArray.length == 0)
@ -148,10 +148,11 @@ struct CFFIndex
/* serialize data */
for (unsigned int i = 0; i < byteArray.length; i++)
{
ByteStr *dest = c->start_embed<ByteStr> ();
if (unlikely (dest == nullptr ||
!dest->serialize (c, byteArray[i])))
const byte_str_t &bs = byteArray[i];
unsigned char *dest = c->allocate_size<unsigned char> (bs.length);
if (unlikely (dest == nullptr))
return_trace (false);
memcpy (dest, &bs[0], bs.length);
}
}
return_trace (true);
@ -159,14 +160,14 @@ struct CFFIndex
bool serialize (hb_serialize_context_t *c,
unsigned int offSize_,
const StrBuffArray &buffArray)
const str_buff_vec_t &buffArray)
{
ByteStrArray byteArray;
byte_str_array_t byteArray;
byteArray.init ();
byteArray.resize (buffArray.length);
for (unsigned int i = 0; i < byteArray.length; i++)
{
byteArray[i] = ByteStr (buffArray[i].arrayZ (), buffArray[i].length);
byteArray[i] = byte_str_t (buffArray[i].arrayZ (), buffArray[i].length);
}
bool result = this->serialize (c, offSize_, byteArray);
byteArray.fini ();
@ -205,17 +206,17 @@ struct CFFIndex
return 0;
}
const char *data_base () const
{ return (const char *)this + min_size + offset_array_size (); }
const unsigned char *data_base () const
{ return (const unsigned char *)this + min_size + offset_array_size (); }
unsigned int data_size () const { return HBINT8::static_size; }
ByteStr operator [] (unsigned int index) const
byte_str_t operator [] (unsigned int index) const
{
if (likely (index < count))
return ByteStr (data_base () + offset_at (index) - 1, length_at (index));
return byte_str_t (data_base () + offset_at (index) - 1, length_at (index));
else
return Null(ByteStr);
return Null(byte_str_t);
}
unsigned int get_size () const
@ -255,11 +256,11 @@ struct CFFIndex
template <typename COUNT, typename TYPE>
struct CFFIndexOf : CFFIndex<COUNT>
{
const ByteStr operator [] (unsigned int index) const
const byte_str_t operator [] (unsigned int index) const
{
if (likely (index < CFFIndex<COUNT>::count))
return ByteStr (CFFIndex<COUNT>::data_base () + CFFIndex<COUNT>::offset_at (index) - 1, CFFIndex<COUNT>::length_at (index));
return Null(ByteStr);
return byte_str_t (CFFIndex<COUNT>::data_base () + CFFIndex<COUNT>::offset_at (index) - 1, CFFIndex<COUNT>::length_at (index));
return Null(byte_str_t);
}
template <typename DATA, typename PARAM1, typename PARAM2>
@ -363,7 +364,7 @@ struct Dict : UnsizedByteStr
}
template <typename INTTYPE, int minVal, int maxVal>
static bool serialize_int_op (hb_serialize_context_t *c, OpCode op, int value, OpCode intOp)
static bool serialize_int_op (hb_serialize_context_t *c, op_code_t op, int value, op_code_t intOp)
{
// XXX: not sure why but LLVM fails to compile the following 'unlikely' macro invocation
if (/*unlikely*/ (!serialize_int<INTTYPE, minVal, maxVal> (c, intOp, value)))
@ -383,18 +384,18 @@ struct Dict : UnsizedByteStr
return_trace (true);
}
static bool serialize_uint4_op (hb_serialize_context_t *c, OpCode op, int value)
static bool serialize_uint4_op (hb_serialize_context_t *c, op_code_t op, int value)
{ return serialize_int_op<HBUINT32, 0, 0x7FFFFFFF> (c, op, value, OpCode_longintdict); }
static bool serialize_uint2_op (hb_serialize_context_t *c, OpCode op, int value)
static bool serialize_uint2_op (hb_serialize_context_t *c, op_code_t op, int value)
{ return serialize_int_op<HBUINT16, 0, 0x7FFF> (c, op, value, OpCode_shortint); }
static bool serialize_offset4_op (hb_serialize_context_t *c, OpCode op, int value)
static bool serialize_offset4_op (hb_serialize_context_t *c, op_code_t op, int value)
{
return serialize_uint4_op (c, op, value);
}
static bool serialize_offset2_op (hb_serialize_context_t *c, OpCode op, int value)
static bool serialize_offset2_op (hb_serialize_context_t *c, op_code_t op, int value)
{
return serialize_uint2_op (c, op, value);
}
@ -404,7 +405,7 @@ struct TopDict : Dict {};
struct FontDict : Dict {};
struct PrivateDict : Dict {};
struct TableInfo
struct table_info_t
{
void init () { offSize = offset = size = 0; }
@ -415,7 +416,7 @@ struct TableInfo
/* used to remap font index or SID from fullset to 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 (); }
@ -507,9 +508,9 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
unsigned int offSize_,
const hb_vector_t<DICTVAL> &fontDicts,
unsigned int fdCount,
const Remap &fdmap,
const remap_t &fdmap,
OP_SERIALIZER& opszr,
const hb_vector_t<TableInfo> &privateInfos)
const hb_vector_t<table_info_t> &privateInfos)
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
@ -545,7 +546,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */,
const hb_vector_t<DICTVAL> &fontDicts,
unsigned int fdCount,
const Remap &fdmap,
const remap_t &fdmap,
OP_SERIALIZER& opszr)
{
unsigned int dictsSize = 0;

View File

@ -161,7 +161,7 @@ hb_codepoint_t OT::cff1::lookup_standard_encoding_for_sid (hb_codepoint_t code)
return CFF_UNDEF_SID;
}
struct Bounds
struct bounds_t
{
void init ()
{
@ -169,7 +169,7 @@ struct Bounds
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 > max.x) max.x = pt.x;
@ -177,7 +177,7 @@ struct Bounds
if (pt.y > max.y) max.y = pt.y;
}
void merge (const Bounds &b)
void merge (const bounds_t &b)
{
if (empty ())
*this = b;
@ -190,7 +190,7 @@ struct Bounds
}
}
void offset (const Point &delta)
void offset (const point_t &delta)
{
if (!empty ())
{
@ -202,11 +202,11 @@ struct Bounds
bool empty () const
{ return (min.x >= max.x) || (min.y >= max.y); }
Point min;
Point max;
point_t min;
point_t max;
};
struct ExtentsParam
struct extents_param_t
{
void init (const OT::cff1::accelerator_t *_cff)
{
@ -220,20 +220,20 @@ struct ExtentsParam
bool is_path_open () const { return path_open; }
bool path_open;
Bounds bounds;
bounds_t bounds;
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 ();
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 ())
{
@ -244,7 +244,7 @@ struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv,
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 ())
{
@ -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 ();
Point delta;
point_t delta;
delta.x = env.argStack[n-4];
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 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
&& _get_bounds (param.cff, base, base_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 ();
if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false;
unsigned int fd = cff->fdSelect->get_fd (glyph);
CFF1CSInterpreter<CFF1CSOpSet_Extents, ExtentsParam> interp;
const ByteStr str = (*cff->charStrings)[glyph];
cff1_cs_interpreter_t<cff1_cs_opset_extents_t, extents_param_t> interp;
const byte_str_t str = (*cff->charStrings)[glyph];
interp.env.init (str, *cff, fd);
interp.env.set_in_seac (in_seac);
ExtentsParam param;
extents_param_t param;
param.init (cff);
if (unlikely (!interp.interpret (param))) return false;
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
{
Bounds bounds;
bounds_t bounds;
if (!_get_bounds (this, glyph, bounds))
return false;
@ -334,7 +334,7 @@ bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extent
return true;
}
struct GetSeacParam
struct get_seac_param_t
{
void init (const OT::cff1::accelerator_t *_cff)
{
@ -350,9 +350,9 @@ struct GetSeacParam
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 ();
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;
unsigned int fd = fdSelect->get_fd (glyph);
CFF1CSInterpreter<CFF1CSOpSet_Seac, GetSeacParam> interp;
const ByteStr str = (*charStrings)[glyph];
cff1_cs_interpreter_t<cff1_cs_opset_seac_t, get_seac_param_t> interp;
const byte_str_t str = (*charStrings)[glyph];
interp.env.init (str, *this, fd);
GetSeacParam param;
get_seac_param_t param;
param.init (this);
if (unlikely (!interp.interpret (param))) return false;

View File

@ -193,8 +193,8 @@ struct Encoding {
bool serialize (hb_serialize_context_t *c,
uint8_t format,
unsigned int enc_count,
const hb_vector_t<code_pair>& code_ranges,
const hb_vector_t<code_pair>& supp_codes)
const hb_vector_t<code_pair_t>& code_ranges,
const hb_vector_t<code_pair_t>& supp_codes)
{
TRACE_SERIALIZE (this);
Encoding *dest = c->extend_min (*this);
@ -467,7 +467,7 @@ struct Charset {
bool serialize (hb_serialize_context_t *c,
uint8_t format,
unsigned int num_glyphs,
const hb_vector_t<code_pair>& sid_ranges)
const hb_vector_t<code_pair_t>& sid_ranges)
{
TRACE_SERIALIZE (this);
Charset *dest = c->extend_min (*this);
@ -573,7 +573,7 @@ struct Charset {
struct CFF1StringIndex : CFF1Index
{
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);
if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0)))
@ -584,7 +584,7 @@ struct CFF1StringIndex : CFF1Index
return_trace (true);
}
ByteStrArray bytesArray;
byte_str_array_t bytesArray;
bytesArray.init ();
if (!bytesArray.resize (sidmap.get_count ()))
return_trace (false);
@ -601,7 +601,7 @@ struct CFF1StringIndex : CFF1Index
}
/* 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;
if ((count == 0) || (sidmap.get_count () == 0))
@ -617,18 +617,18 @@ struct CFF1StringIndex : CFF1Index
}
};
struct CFF1TopDictInterpEnv : NumInterpEnv
struct cff1_top_dict_interp_env_t : num_interp_env_t
{
CFF1TopDictInterpEnv ()
: NumInterpEnv(), prev_offset(0), last_offset(0) {}
cff1_top_dict_interp_env_t ()
: num_interp_env_t(), prev_offset(0), last_offset(0) {}
unsigned int prev_offset;
unsigned int last_offset;
};
struct NameDictValues
struct name_dict_values_t
{
enum NameDictValIndex
enum name_dict_val_index_t
{
version,
notice,
@ -657,7 +657,7 @@ struct NameDictValues
unsigned int operator[] (unsigned int i) const
{ assert (i < ValCount); return values[i]; }
static enum NameDictValIndex name_op_to_index (OpCode op)
static enum name_dict_val_index_t name_op_to_index (op_code_t op)
{
switch (op) {
default: // can't happen - just make some compiler happy
@ -685,16 +685,16 @@ struct NameDictValues
unsigned int values[ValCount];
};
struct CFF1TopDictVal : OpStr
struct cff1_top_dict_val_t : op_str_t
{
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 ()
{
TopDictValues<CFF1TopDictVal>::init ();
top_dict_values_t<cff1_top_dict_val_t>::init ();
nameSIDs.init ();
ros_supplement = 0;
@ -704,12 +704,12 @@ struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal>
FDSelectOffset = 0;
privateDictInfo.init ();
}
void fini () { TopDictValues<CFF1TopDictVal>::fini (); }
void fini () { top_dict_values_t<cff1_top_dict_val_t>::fini (); }
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;
unsigned int cidCount;
@ -717,14 +717,14 @@ struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal>
unsigned int EncodingOffset;
unsigned int CharsetOffset;
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 (op_code_t 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 */
switch (op) {
@ -736,7 +736,7 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
case OpCode_Weight:
case OpCode_PostScript:
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 ();
break;
case OpCode_isFixedPitch:
@ -765,8 +765,8 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
case OpCode_ROS:
dictval.ros_supplement = env.argStack.pop_uint ();
dictval.nameSIDs[NameDictValues::ordering] = env.argStack.pop_uint ();
dictval.nameSIDs[NameDictValues::registry] = env.argStack.pop_uint ();
dictval.nameSIDs[name_dict_values_t::ordering] = env.argStack.pop_uint ();
dictval.nameSIDs[name_dict_values_t::registry] = env.argStack.pop_uint ();
env.clear_args ();
break;
@ -794,8 +794,8 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
break;
default:
env.last_offset = env.substr.offset;
TopDictOpSet<CFF1TopDictVal>::process_op (op, env, dictval);
env.last_offset = env.str_ref.offset;
top_dict_opset_t<cff1_top_dict_val_t>::process_op (op, env, dictval);
/* Record this operand below if stack is empty, otherwise done */
if (!env.argStack.is_empty ()) return;
break;
@ -803,27 +803,27 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr, val);
dictval.add_op (op, env.str_ref, val);
}
};
struct CFF1FontDictValues : DictValues<OpStr>
struct cff1_font_dict_values_t : dict_values_t<op_str_t>
{
void init ()
{
DictValues<OpStr>::init ();
dict_values_t<op_str_t>::init ();
privateDictInfo.init ();
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;
};
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 (op_code_t op, num_interp_env_t& env, cff1_font_dict_values_t& dictval)
{
switch (op) {
case OpCode_FontName:
@ -841,36 +841,36 @@ struct CFF1FontDictOpSet : DictOpSet
break;
default:
DictOpSet::process_op (op, env);
dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return;
break;
}
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr);
dictval.add_op (op, env.str_ref);
}
};
template <typename VAL>
struct CFF1PrivateDictValues_Base : DictValues<VAL>
struct cff1_private_dict_values_base_t : dict_values_t<VAL>
{
void init ()
{
DictValues<VAL>::init ();
dict_values_t<VAL>::init ();
subrsOffset = 0;
localSubrs = &Null(CFF1Subrs);
}
void fini () { DictValues<VAL>::fini (); }
void fini () { dict_values_t<VAL>::fini (); }
unsigned int calculate_serialized_size () const
{
unsigned int size = 0;
for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++)
if (DictValues<VAL>::get_value (i).op == OpCode_Subrs)
for (unsigned int i = 0; i < dict_values_t<VAL>::get_count; i++)
if (dict_values_t<VAL>::get_value (i).op == OpCode_Subrs)
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
else
size += DictValues<VAL>::get_value (i).str.len;
size += dict_values_t<VAL>::get_value (i).str.length;
return size;
}
@ -878,14 +878,14 @@ struct CFF1PrivateDictValues_Base : DictValues<VAL>
const CFF1Subrs *localSubrs;
};
typedef CFF1PrivateDictValues_Base<OpStr> CFF1PrivateDictValues_Subset;
typedef CFF1PrivateDictValues_Base<NumDictVal> CFF1PrivateDictValues;
typedef cff1_private_dict_values_base_t<op_str_t> cff1_private_dict_values_subset_t;
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 (op_code_t op, num_interp_env_t& env, cff1_private_dict_values_t& dictval)
{
NumDictVal val;
num_dict_val_t val;
val.init ();
switch (op) {
@ -917,20 +917,20 @@ struct CFF1PrivateDictOpSet : DictOpSet
break;
default:
DictOpSet::process_op (op, env);
dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return;
break;
}
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr, val);
dictval.add_op (op, env.str_ref, val);
}
};
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 (op_code_t op, num_interp_env_t& env, cff1_private_dict_values_subset_t& dictval)
{
switch (op) {
case OpCode_BlueValues:
@ -959,20 +959,19 @@ struct CFF1PrivateDictOpSet_Subset : DictOpSet
break;
default:
DictOpSet::process_op (op, env);
dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return;
break;
}
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr);
dictval.add_op (op, env.str_ref);
}
};
typedef DictInterpreter<CFF1TopDictOpSet, CFF1TopDictValues, CFF1TopDictInterpEnv> CFF1TopDict_Interpreter;
typedef DictInterpreter<CFF1FontDictOpSet, CFF1FontDictValues> CFF1FontDict_Interpreter;
typedef DictInterpreter<CFF1PrivateDictOpSet, CFF1PrivateDictValues> CFF1PrivateDict_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 dict_interpreter_t<cff1_font_dict_opset_t, cff1_font_dict_values_t> cff1_font_dict_interpreter_t;
typedef CFF1Index CFF1NameIndex;
typedef CFF1IndexOf<TopDict> CFF1TopDictIndex;
@ -1023,9 +1022,9 @@ struct cff1
{ fini (); return; }
{ /* parse top dict */
const ByteStr topDictStr = (*topDictIndex)[0];
const byte_str_t topDictStr = (*topDictIndex)[0];
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
CFF1TopDict_Interpreter top_interp;
cff1_top_dict_interpreter_t top_interp;
top_interp.env.init (topDictStr);
topDict.init ();
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
@ -1082,24 +1081,24 @@ struct cff1
{
for (unsigned int i = 0; i < fdCount; i++)
{
ByteStr fontDictStr = (*fdArray)[i];
byte_str_t fontDictStr = (*fdArray)[i];
if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
CFF1FontDictValues *font;
CFF1FontDict_Interpreter font_interp;
cff1_font_dict_values_t *font;
cff1_font_dict_interpreter_t font_interp;
font_interp.env.init (fontDictStr);
font = fontDicts.push ();
if (unlikely (font == &Crap(CFF1FontDictValues))) { fini (); return; }
if (unlikely (font == &Crap(cff1_font_dict_values_t))) { fini (); return; }
font->init ();
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
PRIVDICTVAL *priv = &privateDicts[i];
const ByteStr 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; }
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
priv_interp.env.init (privDictStr);
priv->init ();
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset);
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (&privDictStr, priv->subrsOffset);
if (priv->localSubrs != &Null(CFF1Subrs) &&
unlikely (!priv->localSubrs->sanitize (&sc)))
{ fini (); return; }
@ -1107,17 +1106,17 @@ struct cff1
}
else /* non-CID */
{
CFF1TopDictValues *font = &topDict;
cff1_top_dict_values_t *font = &topDict;
PRIVDICTVAL *priv = &privateDicts[0];
const ByteStr 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; }
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
priv_interp.env.init (privDictStr);
priv->init ();
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset);
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (&privDictStr, priv->subrsOffset);
if (priv->localSubrs != &Null(CFF1Subrs) &&
unlikely (!priv->localSubrs->sanitize (&sc)))
{ fini (); return; }
@ -1167,20 +1166,20 @@ struct cff1
const CFF1FDSelect *fdSelect;
unsigned int fdCount;
CFF1TopDictValues topDict;
hb_vector_t<CFF1FontDictValues> fontDicts;
cff1_top_dict_values_t topDict;
hb_vector_t<cff1_font_dict_values_t> fontDicts;
hb_vector_t<PRIVDICTVAL> privateDicts;
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_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)
{
@ -1257,7 +1256,7 @@ struct cff1
const Encoding *encoding;
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

View File

@ -29,7 +29,7 @@
using namespace CFF;
struct ExtentsParam
struct extents_param_t
{
void init ()
{
@ -44,7 +44,7 @@ struct ExtentsParam
void end_path () { path_open = false; }
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 > max_x) max_x = pt.x;
@ -53,21 +53,21 @@ struct ExtentsParam
}
bool path_open;
Number min_x;
Number min_y;
Number max_x;
Number max_y;
number_t min_x;
number_t min_y;
number_t max_x;
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 ();
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 ())
{
@ -78,7 +78,7 @@ struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv,
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 ())
{
@ -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,
hb_codepoint_t glyph,
@ -104,10 +104,10 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
unsigned int num_coords;
const int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
unsigned int fd = fdSelect->get_fd (glyph);
CFF2CSInterpreter<CFF2CSOpSet_Extents, ExtentsParam> interp;
const ByteStr str = (*charStrings)[glyph];
cff2_cs_interpreter_t<cff2_cs_opset_extents_t, extents_param_t> interp;
const byte_str_t str = (*charStrings)[glyph];
interp.env.init (str, *this, fd, coords, num_coords);
ExtentsParam param;
extents_param_t param;
param.init ();
if (unlikely (!interp.interpret (param))) return false;

View File

@ -136,22 +136,22 @@ struct CFF2VariationStore
DEFINE_SIZE_MIN (2 + VariationStore::min_size);
};
struct CFF2TopDictValues : TopDictValues<>
struct cff2_top_dict_values_t : top_dict_values_t<>
{
void init ()
{
TopDictValues<>::init ();
top_dict_values_t<>::init ();
vstoreOffset = 0;
FDSelectOffset = 0;
}
void fini () { TopDictValues<>::fini (); }
void fini () { top_dict_values_t<>::fini (); }
unsigned int calculate_serialized_size () const
{
unsigned int size = 0;
for (unsigned int i = 0; i < get_count (); i++)
{
OpCode op = get_value (i).op;
op_code_t op = get_value (i).op;
switch (op)
{
case OpCode_vstore:
@ -159,7 +159,7 @@ struct CFF2TopDictValues : TopDictValues<>
size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op);
break;
default:
size += TopDictValues<>::calculate_serialized_op_size (get_value (i));
size += top_dict_values_t<>::calculate_serialized_op_size (get_value (i));
break;
}
}
@ -170,16 +170,16 @@ struct CFF2TopDictValues : TopDictValues<>
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 (op_code_t op, num_interp_env_t& env, cff2_top_dict_values_t& dictval)
{
switch (op) {
case OpCode_FontMatrix:
{
DictVal val;
dict_val_t val;
val.init ();
dictval.add_op (op, env.substr);
dictval.add_op (op, env.str_ref);
env.clear_args ();
}
break;
@ -201,27 +201,27 @@ struct CFF2TopDictOpSet : TopDictOpSet<>
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr);
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 ()
{
DictValues<OpStr>::init ();
dict_values_t<op_str_t>::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 (op_code_t op, num_interp_env_t& env, cff2_font_dict_values_t& dictval)
{
switch (op) {
case OpCode_Private:
@ -238,33 +238,33 @@ struct CFF2FontDictOpSet : DictOpSet
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr);
dictval.add_op (op, env.str_ref);
}
private:
typedef DictOpSet SUPER;
typedef dict_opset_t SUPER;
};
template <typename VAL>
struct CFF2PrivateDictValues_Base : DictValues<VAL>
struct cff2_private_dict_values_base_t : dict_values_t<VAL>
{
void init ()
{
DictValues<VAL>::init ();
dict_values_t<VAL>::init ();
subrsOffset = 0;
localSubrs = &Null(CFF2Subrs);
ivs = 0;
}
void fini () { DictValues<VAL>::fini (); }
void fini () { dict_values_t<VAL>::fini (); }
unsigned int calculate_serialized_size () const
{
unsigned int size = 0;
for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++)
if (DictValues<VAL>::get_value (i).op == OpCode_Subrs)
for (unsigned int i = 0; i < dict_values_t<VAL>::get_count; i++)
if (dict_values_t<VAL>::get_value (i).op == OpCode_Subrs)
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
else
size += DictValues<VAL>::get_value (i).str.len;
size += dict_values_t<VAL>::get_value (i).str.length;
return size;
}
@ -273,14 +273,14 @@ struct CFF2PrivateDictValues_Base : DictValues<VAL>
unsigned int ivs;
};
typedef CFF2PrivateDictValues_Base<OpStr> CFF2PrivateDictValues_Subset;
typedef CFF2PrivateDictValues_Base<NumDictVal> CFF2PrivateDictValues;
typedef cff2_private_dict_values_base_t<op_str_t> cff2_private_dict_values_subset_t;
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 ByteStr &str)
void init (const byte_str_t &str)
{
NumInterpEnv::init (str);
num_interp_env_t::init (str);
ivs = 0;
seen_vsindex = false;
}
@ -302,11 +302,11 @@ struct CFF2PrivDictInterpEnv : NumInterpEnv
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 (op_code_t op, cff2_priv_dict_interp_env_t& env, cff2_private_dict_values_t& dictval)
{
NumDictVal val;
num_dict_val_t val;
val.init ();
switch (op) {
@ -341,20 +341,20 @@ struct CFF2PrivateDictOpSet : DictOpSet
break;
default:
DictOpSet::process_op (op, env);
dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return;
break;
}
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr, val);
dictval.add_op (op, env.str_ref, val);
}
};
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 (op_code_t op, cff2_priv_dict_interp_env_t& env, cff2_private_dict_values_subset_t& dictval)
{
switch (op) {
case OpCode_BlueValues:
@ -390,15 +390,15 @@ struct CFF2PrivateDictOpSet_Subset : DictOpSet
if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr);
dictval.add_op (op, env.str_ref);
}
private:
typedef DictOpSet SUPER;
typedef dict_opset_t SUPER;
};
typedef DictInterpreter<CFF2TopDictOpSet, CFF2TopDictValues> CFF2TopDict_Interpreter;
typedef DictInterpreter<CFF2FontDictOpSet, CFF2FontDictValues> CFF2FontDict_Interpreter;
typedef dict_interpreter_t<cff2_top_dict_opset_t, cff2_top_dict_values_t> cff2_top_dict_interpreter_t;
typedef dict_interpreter_t<cff2_font_dict_opset_t, cff2_font_dict_values_t> cff2_font_dict_interpreter_t;
}; /* namespace CFF */
@ -438,9 +438,9 @@ struct cff2
{ fini (); return; }
{ /* parse top dict */
ByteStr topDictStr (cff2 + cff2->topDict, cff2->topDictSize);
byte_str_t topDictStr (cff2 + cff2->topDict, cff2->topDictSize);
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
CFF2TopDict_Interpreter top_interp;
cff2_top_dict_interpreter_t top_interp;
top_interp.env.init (topDictStr);
topDict.init ();
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
@ -469,24 +469,24 @@ struct cff2
/* parse font dicts and gather private dicts */
for (unsigned int i = 0; i < fdCount; i++)
{
const ByteStr fontDictStr = (*fdArray)[i];
const byte_str_t fontDictStr = (*fdArray)[i];
if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
CFF2FontDictValues *font;
CFF2FontDict_Interpreter font_interp;
cff2_font_dict_values_t *font;
cff2_font_dict_interpreter_t font_interp;
font_interp.env.init (fontDictStr);
font = fontDicts.push ();
if (unlikely (font == &Crap(CFF2FontDictValues))) { fini (); return; }
if (unlikely (font == &Crap(cff2_font_dict_values_t))) { fini (); return; }
font->init ();
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
const ByteStr 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; }
DictInterpreter<PRIVOPSET, PRIVDICTVAL, CFF2PrivDictInterpEnv> priv_interp;
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL, cff2_priv_dict_interp_env_t> priv_interp;
priv_interp.env.init(privDictStr);
privateDicts[i].init ();
if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; }
privateDicts[i].localSubrs = &StructAtOffsetOrNull<CFF2Subrs> (privDictStr.str, privateDicts[i].subrsOffset);
privateDicts[i].localSubrs = &StructAtOffsetOrNull<CFF2Subrs> (&privDictStr[0], privateDicts[i].subrsOffset);
if (privateDicts[i].localSubrs != &Null(CFF2Subrs) &&
unlikely (!privateDicts[i].localSubrs->sanitize (&sc)))
{ fini (); return; }
@ -505,32 +505,32 @@ struct cff2
bool is_valid () const { return blob != nullptr; }
protected:
hb_blob_t *blob;
hb_sanitize_context_t sc;
hb_blob_t *blob;
hb_sanitize_context_t sc;
public:
CFF2TopDictValues topDict;
const CFF2Subrs *globalSubrs;
const CFF2VariationStore *varStore;
const CFF2CharStrings *charStrings;
const CFF2FDArray *fdArray;
const CFF2FDSelect *fdSelect;
unsigned int fdCount;
cff2_top_dict_values_t topDict;
const CFF2Subrs *globalSubrs;
const CFF2VariationStore *varStore;
const CFF2CharStrings *charStrings;
const CFF2FDArray *fdArray;
const CFF2FDSelect *fdSelect;
unsigned int fdCount;
hb_vector_t<CFF2FontDictValues> fontDicts;
hb_vector_t<cff2_font_dict_values_t> fontDicts;
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_codepoint_t glyph,
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
{

View File

@ -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_fdselect_size /* OUT */,
unsigned int &subset_fdselect_format /* OUT */,
hb_vector_t<code_pair> &fdselect_ranges /* OUT */,
Remap &fdmap /* OUT */)
hb_vector_t<code_pair_t> &fdselect_ranges /* OUT */,
remap_t &fdmap /* OUT */)
{
subset_fd_count = 0;
subset_fdselect_size = 0;
@ -76,7 +76,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
{
num_ranges++;
prev_fd = fd;
code_pair pair = { fd, i };
code_pair_t pair = { fd, i };
fdselect_ranges.push (pair);
}
}
@ -148,7 +148,7 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c,
const unsigned int num_glyphs,
const FDSelect &src,
unsigned int size,
const hb_vector_t<code_pair> &fdselect_ranges)
const hb_vector_t<code_pair_t> &fdselect_ranges)
{
TRACE_SERIALIZE (this);
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 fdselect_format,
unsigned int size,
const hb_vector_t<code_pair> &fdselect_ranges)
const hb_vector_t<code_pair_t> &fdselect_ranges)
{
TRACE_SERIALIZE (this);
FDSelect *p = c->allocate_min<FDSelect> ();

View File

@ -35,16 +35,16 @@
namespace CFF {
/* 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) {}
void reset () { buff.resize (0); }
void encode_byte (unsigned char b)
{
if (unlikely (buff.push ((const char)b) == &Crap(char)))
if (unlikely (buff.push (b) == &Crap(unsigned char)))
set_error ();
}
@ -79,7 +79,7 @@ struct StrEncoder
}
}
void encode_num (const Number& n)
void encode_num (const number_t& n)
{
if (n.in_int_range ())
{
@ -96,7 +96,7 @@ struct StrEncoder
}
}
void encode_op (OpCode op)
void encode_op (op_code_t op)
{
if (Is_OpCode_ESC (op))
{
@ -107,16 +107,16 @@ struct StrEncoder
encode_byte (op);
}
void copy_str (const ByteStr &str)
void copy_str (const byte_str_t &str)
{
unsigned int offset = buff.length;
buff.resize (offset + str.len);
if (unlikely (buff.length < offset + str.len))
buff.resize (offset + str.length);
if (unlikely (buff.length < offset + str.length))
{
set_error ();
return;
}
memcpy (&buff[offset], &str.str[0], str.len);
memcpy (&buff[offset], &str[0], str.length);
}
bool is_error () const { return error; }
@ -124,12 +124,12 @@ struct StrEncoder
protected:
void set_error () { error = true; }
StrBuff &buff;
str_buff_t &buff;
bool error;
};
struct CFFSubTableOffsets {
CFFSubTableOffsets () : privateDictsOffset (0)
struct cff_sub_table_offsets_t {
cff_sub_table_offsets_t () : privateDictsOffset (0)
{
topDictInfo.init ();
FDSelectInfo.init ();
@ -139,23 +139,23 @@ struct CFFSubTableOffsets {
localSubrsInfos.init ();
}
~CFFSubTableOffsets () { localSubrsInfos.fini (); }
~cff_sub_table_offsets_t () { localSubrsInfos.fini (); }
TableInfo topDictInfo;
TableInfo FDSelectInfo;
TableInfo FDArrayInfo;
TableInfo charStringsInfo;
table_info_t topDictInfo;
table_info_t FDSelectInfo;
table_info_t FDArrayInfo;
table_info_t charStringsInfo;
unsigned int privateDictsOffset;
TableInfo globalSubrsInfo;
hb_vector_t<TableInfo> localSubrsInfos;
table_info_t globalSubrsInfo;
hb_vector_t<table_info_t> localSubrsInfos;
};
template <typename OPSTR=OpStr>
struct CFFTopDict_OpSerializer : OpSerializer
template <typename OPSTR=op_str_t>
struct cff_top_dict_op_serializer_t : op_serializer_t
{
bool serialize (hb_serialize_context_t *c,
const OPSTR &opstr,
const CFFSubTableOffsets &offsets) const
const cff_sub_table_offsets_t &offsets) const
{
TRACE_SERIALIZE (this);
@ -186,16 +186,16 @@ struct CFFTopDict_OpSerializer : OpSerializer
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
default:
return opstr.str.len;
return opstr.str.length;
}
}
};
struct CFFFontDict_OpSerializer : OpSerializer
struct cff_font_dict_op_serializer_t : op_serializer_t
{
bool serialize (hb_serialize_context_t *c,
const OpStr &opstr,
const TableInfo &privateDictInfo) const
const op_str_t &opstr,
const table_info_t &privateDictInfo) const
{
TRACE_SERIALIZE (this);
@ -215,34 +215,34 @@ struct CFFFontDict_OpSerializer : OpSerializer
}
else
{
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.len);
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
if (unlikely (d == nullptr)) return_trace (false);
memcpy (d, &opstr.str.str[0], opstr.str.len);
memcpy (d, &opstr.str[0], opstr.str.length);
}
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)
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private);
else
return opstr.str.len;
return opstr.str.length;
}
};
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_) {}
bool serialize (hb_serialize_context_t *c,
const OpStr &opstr,
const op_str_t &opstr,
const unsigned int subrsOffset) const
{
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;
if (opstr.op == OpCode_Subrs)
{
@ -255,10 +255,10 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
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
{
if (drop_hints && DictOpSet::is_hint_op (opstr.op))
if (drop_hints && dict_opset_t::is_hint_op (opstr.op))
return 0;
if (opstr.op == OpCode_Subrs)
{
@ -268,7 +268,7 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op);
}
else
return opstr.str.len;
return opstr.str.length;
}
protected:
@ -276,16 +276,16 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
const bool drop_hints;
};
struct FlattenParam
struct flatten_param_t
{
StrBuff &flatStr;
str_buff_t &flatStr;
bool drop_hints;
};
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_,
bool drop_hints_)
: acc (acc_),
@ -293,7 +293,7 @@ struct SubrFlattener
drop_hints (drop_hints_)
{}
bool flatten (StrBuffArray &flat_charstrings)
bool flatten (str_buff_vec_t &flat_charstrings)
{
if (!flat_charstrings.resize (glyphs.length))
return false;
@ -302,13 +302,13 @@ struct SubrFlattener
for (unsigned int i = 0; i < glyphs.length; i++)
{
hb_codepoint_t glyph = glyphs[i];
const ByteStr str = (*acc.charStrings)[glyph];
const byte_str_t str = (*acc.charStrings)[glyph];
unsigned int fd = acc.fdSelect->get_fd (glyph);
if (unlikely (fd >= acc.fdCount))
return false;
CSInterpreter<ENV, OPSET, FlattenParam> interp;
cs_interpreter_t<ENV, OPSET, flatten_param_t> interp;
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)))
return false;
}
@ -320,9 +320,9 @@ struct SubrFlattener
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 (); }
void init (unsigned int fd_count)
@ -363,18 +363,18 @@ struct SubrClosures
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)
{
OpStr::init ();
op_str_t::init ();
subr_num = subr_num_;
drop_flag = false;
keep_flag = false;
skip_flag = false;
}
void fini () { OpStr::fini (); }
void fini () { op_str_t::fini (); }
bool for_drop () const { return drop_flag; }
void set_drop () { if (!for_keep ()) drop_flag = true; }
@ -393,7 +393,7 @@ struct ParsedCSOp : OpStr
bool skip_flag : 1;
};
struct ParsedCStr : ParsedValues<ParsedCSOp>
struct parsed_cs_str_t : parsed_values_t<parsed_cs_op_t>
{
void init ()
{
@ -403,13 +403,13 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
has_prefix_ = false;
}
void add_op (OpCode op, const SubByteStr& substr)
void add_op (op_code_t op, const byte_str_ref_t& str_ref)
{
if (!is_parsed ())
SUPER::add_op (op, substr);
SUPER::add_op (op, str_ref);
}
void add_call_op (OpCode op, const SubByteStr& substr, unsigned int subr_num)
void add_call_op (op_code_t op, const byte_str_ref_t& str_ref, unsigned int subr_num)
{
if (!is_parsed ())
{
@ -417,13 +417,13 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
if (likely (parsed_len > 0))
values[parsed_len-1].set_skip ();
ParsedCSOp val;
parsed_cs_op_t val;
val.init (subr_num);
SUPER::add_op (op, substr, 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, op_code_t op = OpCode_Invalid)
{
has_prefix_ = true;
prefix_op_ = op;
@ -446,22 +446,22 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
void set_vsindex_dropped () { vsindex_dropped = true; }
bool has_prefix () const { return has_prefix_; }
OpCode prefix_op () const { return prefix_op_; }
const Number &prefix_num () const { return prefix_num_; }
op_code_t prefix_op () const { return prefix_op_; }
const number_t &prefix_num () const { return prefix_num_; }
protected:
bool parsed;
bool hint_dropped;
bool vsindex_dropped;
bool has_prefix_;
OpCode prefix_op_;
Number prefix_num_;
op_code_t prefix_op_;
number_t prefix_num_;
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)
{
@ -473,13 +473,13 @@ struct ParsedCStrs : hb_vector_t<ParsedCStr>
void fini () { SUPER::fini_deep (); }
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_,
ParsedCStrs *parsed_global_subrs_, ParsedCStrs *parsed_local_subrs_,
void init (parsed_cs_str_t *parsed_charstring_,
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_,
bool drop_hints_)
{
@ -492,7 +492,7 @@ struct SubrSubsetParam
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)
{
@ -515,7 +515,7 @@ struct SubrSubsetParam
template <typename ENV>
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 the called subroutine is parsed partially but not completely yet,
@ -530,17 +530,17 @@ struct SubrSubsetParam
env.set_error ();
}
ParsedCStr *current_parsed_str;
parsed_cs_str_t *current_parsed_str;
ParsedCStr *parsed_charstring;
ParsedCStrs *parsed_global_subrs;
ParsedCStrs *parsed_local_subrs;
parsed_cs_str_t *parsed_charstring;
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;
bool drop_hints;
};
struct SubrRemap : Remap
struct subr_remap_t : remap_t
{
void create (hb_set_t *closure)
{
@ -567,7 +567,7 @@ struct SubrRemap : Remap
if (old_num >= length)
return CFF_UNDEF_CODE;
else
return Remap::operator[] (old_num);
return remap_t::operator[] (old_num);
}
int biased_num (unsigned int old_num) const
@ -580,15 +580,15 @@ struct SubrRemap : Remap
int bias;
};
struct SubrRemaps
struct subr_remap_ts
{
SubrRemaps ()
subr_remap_ts ()
{
global_remap.init ();
local_remaps.init ();
}
~SubrRemaps () { fini (); }
~subr_remap_ts () { fini (); }
void init (unsigned int fdCount)
{
@ -597,7 +597,7 @@ struct SubrRemaps
local_remaps[i].init ();
}
void create (SubrClosures& closures)
void create (subr_closures_t& closures)
{
global_remap.create (closures.global_closure);
for (unsigned int i = 0; i < local_remaps.length; i++)
@ -610,21 +610,21 @@ struct SubrRemaps
local_remaps.fini_deep ();
}
SubrRemap global_remap;
hb_vector_t<SubrRemap> local_remaps;
subr_remap_t global_remap;
hb_vector_t<subr_remap_t> local_remaps;
};
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_global_subrs.init ();
parsed_local_subrs.init ();
}
~SubrSubsetter ()
~subr_subsetter_t ()
{
closures.fini ();
remaps.fini ();
@ -666,15 +666,15 @@ struct SubrSubsetter
for (unsigned int i = 0; i < glyphs.length; i++)
{
hb_codepoint_t glyph = glyphs[i];
const ByteStr str = (*acc.charStrings)[glyph];
const byte_str_t str = (*acc.charStrings)[glyph];
unsigned int fd = acc.fdSelect->get_fd (glyph);
if (unlikely (fd >= acc.fdCount))
return false;
CSInterpreter<ENV, OPSET, SubrSubsetParam> interp;
cs_interpreter_t<ENV, OPSET, subr_subset_param_t> interp;
interp.env.init (str, acc, fd);
SubrSubsetParam param;
subr_subset_param_t param;
param.init (&parsed_charstrings[i],
&parsed_global_subrs, &parsed_local_subrs[fd],
closures.global_closure, closures.local_closures[fd],
@ -695,13 +695,13 @@ struct SubrSubsetter
unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
if (unlikely (fd >= acc.fdCount))
return false;
SubrSubsetParam param;
subr_subset_param_t param;
param.init (&parsed_charstrings[i],
&parsed_global_subrs, &parsed_local_subrs[fd],
closures.global_closure, closures.local_closures[fd],
drop_hints);
DropHintsParam drop;
drop_hints_param_t drop;
if (drop_hints_in_str (parsed_charstrings[i], param, drop))
{
parsed_charstrings[i].set_hint_dropped ();
@ -717,7 +717,7 @@ struct SubrSubsetter
unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
if (unlikely (fd >= acc.fdCount))
return false;
SubrSubsetParam param;
subr_subset_param_t param;
param.init (&parsed_charstrings[i],
&parsed_global_subrs, &parsed_local_subrs[fd],
closures.global_closure, closures.local_closures[fd],
@ -731,7 +731,7 @@ struct SubrSubsetter
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.length)))
return false;
@ -746,7 +746,7 @@ struct SubrSubsetter
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 ();
@ -764,20 +764,20 @@ struct SubrSubsetter
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);
}
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);
}
protected:
struct DropHintsParam
struct drop_hints_param_t
{
DropHintsParam ()
drop_hints_param_t ()
: seen_moveto (false),
ends_in_hint (false),
vsindex_dropped (false) {}
@ -787,9 +787,9 @@ struct SubrSubsetter
bool vsindex_dropped;
};
bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos,
ParsedCStrs &subrs, unsigned int subr_num,
const SubrSubsetParam &param, DropHintsParam &drop)
bool drop_hints_in_subr (parsed_cs_str_t &str, unsigned int pos,
parsed_cs_str_vec_t &subrs, unsigned int subr_num,
const subr_subset_param_t &param, drop_hints_param_t &drop)
{
drop.ends_in_hint = false;
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 */
bool drop_hints_in_str (ParsedCStr &str, const SubrSubsetParam &param, DropHintsParam &drop)
bool drop_hints_in_str (parsed_cs_str_t &str, const subr_subset_param_t &param, drop_hints_param_t &drop)
{
bool seen_hint = false;
@ -868,7 +868,7 @@ struct SubrSubsetter
{
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 ())
break;
csop.set_drop ();
@ -882,16 +882,16 @@ struct SubrSubsetter
return seen_hint;
}
void collect_subr_refs_in_subr (ParsedCStr &str, unsigned int pos,
unsigned int subr_num, ParsedCStrs &subrs,
void collect_subr_refs_in_subr (parsed_cs_str_t &str, unsigned int pos,
unsigned int subr_num, parsed_cs_str_vec_t &subrs,
hb_set_t *closure,
const SubrSubsetParam &param)
const subr_subset_param_t &param)
{
hb_set_add (closure, subr_num);
collect_subr_refs_in_str (subrs[subr_num], param);
}
void collect_subr_refs_in_str (ParsedCStr &str, const SubrSubsetParam &param)
void collect_subr_refs_in_str (parsed_cs_str_t &str, const subr_subset_param_t &param)
{
for (unsigned int pos = 0; pos < str.values.length; 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 ();
StrEncoder encoder (buff);
str_encoder_t encoder (buff);
encoder.reset ();
/* if a prefix (CFF1 width or CFF2 vsindex) has been removed along with hints,
* re-insert it at the beginning of charstreing */
@ -932,7 +932,7 @@ struct SubrSubsetter
}
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 ())
{
switch (opstr.op)
@ -957,13 +957,13 @@ struct SubrSubsetter
}
protected:
SubrClosures closures;
subr_closures_t closures;
ParsedCStrs parsed_charstrings;
ParsedCStrs parsed_global_subrs;
hb_vector_t<ParsedCStrs> parsed_local_subrs;
parsed_cs_str_vec_t parsed_charstrings;
parsed_cs_str_vec_t parsed_global_subrs;
hb_vector_t<parsed_cs_str_vec_t> parsed_local_subrs;
SubrRemaps remaps;
subr_remap_ts remaps;
private:
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_fdselect_size /* OUT */,
unsigned int &subset_fdselect_format /* OUT */,
hb_vector_t<CFF::code_pair> &fdselect_ranges /* OUT */,
CFF::Remap &fdmap /* OUT */);
hb_vector_t<CFF::code_pair_t> &fdselect_ranges /* OUT */,
CFF::remap_t &fdmap /* OUT */);
HB_INTERNAL bool
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 fdselect_format,
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 */

View File

@ -34,12 +34,12 @@
using namespace CFF;
struct RemapSID : Remap
struct remap_sid_t : remap_t
{
unsigned int add (unsigned int 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
return sid;
}
@ -49,7 +49,7 @@ struct RemapSID : Remap
if (is_std_std (sid) || (sid == CFF_UNDEF_SID))
return sid;
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;
@ -59,10 +59,10 @@ struct RemapSID : Remap
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 ()
: CFFSubTableOffsets (),
cff1_sub_table_offsets_t ()
: cff_sub_table_offsets_t (),
nameIndexOffset (0),
encodingOffset (0)
{
@ -72,16 +72,16 @@ struct CFF1SubTableOffsets : CFFSubTableOffsets
}
unsigned int nameIndexOffset;
TableInfo stringIndexInfo;
table_info_t stringIndexInfo;
unsigned int encodingOffset;
TableInfo charsetInfo;
TableInfo privateDictInfo;
table_info_t charsetInfo;
table_info_t privateDictInfo;
};
/* a copy of a parsed out CFF1TopDictValues augmented with additional operators */
struct CFF1TopDictValuesMod : CFF1TopDictValues
/* a copy of a parsed out cff1_top_dict_values_t augmented with additional operators */
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 ();
base = base_;
@ -90,47 +90,47 @@ struct CFF1TopDictValuesMod : CFF1TopDictValues
void fini () { SUPER::fini (); }
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 ())
return (*base)[i];
else
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]];
}
protected:
typedef CFF1TopDictValues SUPER;
const CFF1TopDictValues *base;
typedef cff1_top_dict_values_t SUPER;
const cff1_top_dict_values_t *base;
};
struct TopDictModifiers
struct top_dict_modifiers_t
{
TopDictModifiers (const CFF1SubTableOffsets &offsets_,
const unsigned int (&nameSIDs_)[NameDictValues::ValCount])
top_dict_modifiers_t (const cff1_sub_table_offsets_t &offsets_,
const unsigned int (&nameSIDs_)[name_dict_values_t::ValCount])
: offsets (offsets_),
nameSIDs (nameSIDs_)
{}
const CFF1SubTableOffsets &offsets;
const unsigned int (&nameSIDs)[NameDictValues::ValCount];
const cff1_sub_table_offsets_t &offsets;
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,
const CFF1TopDictVal &opstr,
const TopDictModifiers &mod) const
const cff1_top_dict_val_t &opstr,
const top_dict_modifiers_t &mod) const
{
TRACE_SERIALIZE (this);
OpCode op = opstr.op;
op_code_t op = opstr.op;
switch (op)
{
case OpCode_charset:
@ -160,31 +160,30 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
case OpCode_PostScript:
case OpCode_BaseFontName:
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:
{
/* for registry & ordering, reassigned SIDs are serialized
* 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.str.str = opstr.str.str + opstr.last_arg_offset;
if ( unlikely (!(opstr.str.len >= opstr.last_arg_offset + 3)))
if ( unlikely (!(opstr.str.length >= opstr.last_arg_offset + 3)))
return_trace (false);
supp_op.str.len = opstr.str.len - opstr.last_arg_offset;
return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::registry]) &&
UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::ordering]) &&
supp_op.str = byte_str_t (&opstr.str + opstr.last_arg_offset, opstr.str.length - opstr.last_arg_offset);
return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::registry]) &&
UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::ordering]) &&
copy_opstr (c, supp_op));
}
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);
}
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;
op_code_t op = opstr.op;
switch (op)
{
case OpCode_charset:
@ -206,19 +205,19 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (op);
case OpCode_ROS:
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.length - opstr.last_arg_offset)/* supplement + op */;
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_,
const TableInfo &privateDictInfo_)
const table_info_t &privateDictInfo_)
{
base = base_;
fontName = fontName_;
@ -227,18 +226,18 @@ struct FontDictValuesMod
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;
TableInfo privateDictInfo;
const cff1_font_dict_values_t *base;
table_info_t privateDictInfo;
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,
const OpStr &opstr,
const FontDictValuesMod &mod) const
const op_str_t &opstr,
const font_dict_values_mod_t &mod) const
{
TRACE_SERIALIZE (this);
@ -248,7 +247,7 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer
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)
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_FontName);
@ -257,12 +256,12 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer
}
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 (op_code_t op, cff1_cs_interp_env_t &env, flatten_param_t& param)
{
if (env.arg_start > 0)
flush_width (env, param);
@ -288,43 +287,43 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam>
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++)
encoder.encode_num (env.eval_arg (i));
SUPER::flush_args (env, param);
}
static void flush_op (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param)
static void flush_op (op_code_t 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);
}
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);
StrEncoder encoder (param.flatStr);
str_encoder_t encoder (param.flatStr);
encoder.encode_num (env.width);
}
static void flush_hintmask (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param)
static void flush_hintmask (op_code_t op, cff1_cs_interp_env_t &env, flatten_param_t& param)
{
SUPER::flush_hintmask (op, env, param);
if (!param.drop_hints)
{
StrEncoder encoder (param.flatStr);
str_encoder_t encoder (param.flatStr);
for (unsigned int i = 0; i < env.hintmask_size; i++)
encoder.encode_byte (env.substr[i]);
encoder.encode_byte (env.str_ref[i]);
}
}
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 */
bool finalize (unsigned int last_glyph)
@ -332,7 +331,7 @@ struct RangeList : hb_vector_t<code_pair>
bool two_byte = false;
for (unsigned int i = (*this).length; i > 0; i--)
{
code_pair &pair = (*this)[i - 1];
code_pair_t &pair = (*this)[i - 1];
unsigned int nLeft = last_glyph - pair.glyph - 1;
if (nLeft >= 0x100)
two_byte = true;
@ -343,21 +342,21 @@ 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 (op_code_t op, cff1_cs_interp_env_t &env, subr_subset_param_t& param)
{
switch (op) {
case OpCode_return:
param.current_parsed_str->add_op (op, env.substr);
param.current_parsed_str->add_op (op, env.str_ref);
param.current_parsed_str->set_parsed ();
env.returnFromSubr ();
param.set_current_str (env, false);
break;
case OpCode_endchar:
param.current_parsed_str->add_op (op, env.substr);
param.current_parsed_str->add_op (op, env.str_ref);
param.current_parsed_str->set_parsed ();
SUPER::process_op (op, env, param);
break;
@ -372,30 +371,30 @@ struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetPa
default:
SUPER::process_op (op, env, param);
param.current_parsed_str->add_op (op, env.substr);
param.current_parsed_str->add_op (op, env.str_ref);
break;
}
}
protected:
static void process_call_subr (OpCode op, CSType type,
CFF1CSInterpEnv &env, SubrSubsetParam& param,
CFF1BiasedSubrs& subrs, hb_set_t *closure)
static void process_call_subr (op_code_t op, cs_type_t type,
cff1_cs_interp_env_t &env, subr_subset_param_t& param,
cff1_biased_subrs_t& subrs, hb_set_t *closure)
{
SubByteStr substr = env.substr;
byte_str_ref_t str_ref = env.str_ref;
env.callSubr (subrs, type);
param.current_parsed_str->add_call_op (op, substr, env.context.subr_num);
param.current_parsed_str->add_call_op (op, str_ref, env.context.subr_num);
hb_set_add (closure, env.context.subr_num);
param.set_current_str (env, true);
}
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 */
if (env.has_width)
@ -407,7 +406,7 @@ struct CFF1SubrSubsetter : SubrSubsetter<CFF1SubrSubsetter, CFF1Subrs, const OT:
param.current_parsed_str->set_parsed ();
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))
parsed_str->set_parsed ();
else
@ -439,7 +438,7 @@ struct cff_subset_plan {
subset_enc_supp_codes.init ();
subset_charset_ranges.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;
}
@ -485,7 +484,7 @@ struct cff_subset_plan {
if (code != last_code + 1)
{
code_pair pair = { code, glyph };
code_pair_t pair = { code, glyph };
subset_enc_code_ranges.push (pair);
}
last_code = code;
@ -496,7 +495,7 @@ struct cff_subset_plan {
encoding->get_supplement_codes (sid, supp_codes);
for (unsigned int i = 0; i < supp_codes.length; i++)
{
code_pair pair = { supp_codes[i], sid };
code_pair_t pair = { supp_codes[i], sid };
subset_enc_supp_codes.push (pair);
}
supp_size += SuppEncoding::static_size * supp_codes.length;
@ -538,7 +537,7 @@ struct cff_subset_plan {
if (sid != last_sid + 1)
{
code_pair pair = { sid, glyph };
code_pair_t pair = { sid, glyph };
subset_charset_ranges.push (pair);
}
last_sid = sid;
@ -569,7 +568,7 @@ struct cff_subset_plan {
if (unlikely (!sidmap.reset (acc.stringIndex->count)))
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];
if (sid != CFF_UNDEF_SID)
@ -633,12 +632,12 @@ struct cff_subset_plan {
topdict_mod.add_op (OpCode_charset);
}
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);
offsets.topDictInfo.offSize = calcOffSize(topDictSize);
if (unlikely (offsets.topDictInfo.offSize > 4))
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,
&topdict_mod, 1, topdict_sizes, topSzr);
}
@ -682,7 +681,7 @@ struct cff_subset_plan {
if (desubroutinize)
{
/* 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);
if (!flattener.flatten (subset_charstrings))
return false;
@ -767,7 +766,7 @@ struct cff_subset_plan {
/* FDArray (FDIndex) */
if (acc.fdArray != &Null(CFF1FDArray)) {
offsets.FDArrayInfo.offset = final_size;
CFF1FontDict_OpSerializer fontSzr;
cff1_font_dict_op_serializer_t fontSzr;
unsigned int dictsSize = 0;
for (unsigned int i = 0; i < acc.fontDicts.length; i++)
if (fdmap.includes (i))
@ -796,12 +795,12 @@ struct cff_subset_plan {
if (fdmap.includes (i))
{
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);
TableInfo privInfo = { final_size, priv_size, 0 };
FontDictValuesMod fontdict_mod;
table_info_t privInfo = { final_size, priv_size, 0 };
font_dict_values_mod_t fontdict_mod;
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
fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo );
fontdicts_mod.push (fontdict_mod);
@ -825,43 +824,43 @@ struct cff_subset_plan {
unsigned int get_final_size () const { return final_size; }
unsigned int final_size;
hb_vector_t<unsigned int> topdict_sizes;
CFF1TopDictValuesMod topdict_mod;
CFF1SubTableOffsets offsets;
hb_vector_t<unsigned int> topdict_sizes;
cff1_top_dict_values_mod_t topdict_mod;
cff1_sub_table_offsets_t offsets;
unsigned int num_glyphs;
unsigned int orig_fdcount;
unsigned int subset_fdcount;
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.
* set to CFF_UNDEF_CODE if excluded from subset */
Remap fdmap;
remap_t fdmap;
StrBuffArray subset_charstrings;
StrBuffArray subset_globalsubrs;
hb_vector_t<StrBuffArray> subset_localsubrs;
hb_vector_t<FontDictValuesMod> fontdicts_mod;
str_buff_vec_t subset_charstrings;
str_buff_vec_t subset_globalsubrs;
hb_vector_t<str_buff_vec_t> subset_localsubrs;
hb_vector_t<font_dict_values_mod_t> fontdicts_mod;
bool drop_hints;
bool drop_hints;
bool gid_renum;
bool subset_encoding;
uint8_t subset_enc_format;
unsigned int subset_enc_num_codes;
RangeList subset_enc_code_ranges;
hb_vector_t<code_pair> subset_enc_supp_codes;
bool gid_renum;
bool subset_encoding;
uint8_t subset_enc_format;
unsigned int subset_enc_num_codes;
range_list_t subset_enc_code_ranges;
hb_vector_t<code_pair_t> subset_enc_supp_codes;
uint8_t subset_charset_format;
RangeList subset_charset_ranges;
bool subset_charset;
uint8_t subset_charset_format;
range_list_t subset_charset_ranges;
bool subset_charset;
RemapSID sidmap;
unsigned int topDictModSIDs[NameDictValues::ValCount];
remap_sid_t sidmap;
unsigned int topDictModSIDs[name_dict_values_t::ValCount];
bool desubroutinize;
CFF1SubrSubsetter subr_subsetter;
bool desubroutinize;
cff1_subr_subsetter_t subr_subsetter;
};
static inline bool _write_cff1 (const cff_subset_plan &plan,
@ -872,9 +871,6 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
{
hb_serialize_context_t c (dest, dest_sz);
char RETURN_OP[1] = { OpCode_return };
const ByteStr NULL_SUBR (RETURN_OP, 1);
OT::cff1 *cff = c.start_serialize<OT::cff1> ();
if (unlikely (!c.extend_min (*cff)))
return false;
@ -902,8 +898,8 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
assert (plan.offsets.topDictInfo.offset == c.head - c.start);
CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > ();
if (dest == nullptr) return false;
CFF1TopDict_OpSerializer topSzr;
TopDictModifiers modifier (plan.offsets, plan.topDictModSIDs);
cff1_top_dict_op_serializer_t topSzr;
top_dict_modifiers_t modifier (plan.offsets, plan.topDictModSIDs);
if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize,
&plan.topdict_mod, 1,
plan.topdict_sizes, topSzr, modifier)))
@ -992,7 +988,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
assert (plan.offsets.FDArrayInfo.offset == c.head - c.start);
CFF1FDArray *fda = c.start_embed<CFF1FDArray> ();
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,
plan.fontdicts_mod,
fontSzr)))
@ -1024,7 +1020,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
if (unlikely (pd == nullptr)) return false;
unsigned int priv_size = plan.fontdicts_mod[plan.fdmap[i]].privateDictInfo.size;
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 */
unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset);
@ -1054,9 +1050,9 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
static bool
_hb_subset_cff1 (const OT::cff1::accelerator_subset_t &acc,
const char *data,
hb_subset_plan_t *plan,
hb_blob_t **prime /* OUT */)
const char *data,
hb_subset_plan_t *plan,
hb_blob_t **prime /* OUT */)
{
cff_subset_plan cff_plan;

View File

@ -34,21 +34,21 @@
using namespace CFF;
struct CFF2SubTableOffsets : CFFSubTableOffsets
struct cff2_sub_table_offsets_t : cff_sub_table_offsets_t
{
CFF2SubTableOffsets ()
: CFFSubTableOffsets (),
cff2_sub_table_offsets_t ()
: cff_sub_table_offsets_t (),
varStoreOffset (0)
{}
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,
const OpStr &opstr,
const CFF2SubTableOffsets &offsets) const
const op_str_t &opstr,
const cff2_sub_table_offsets_t &offsets) const
{
TRACE_SERIALIZE (this);
@ -58,11 +58,11 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset));
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)
{
@ -70,14 +70,14 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
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 (op_code_t op, cff2_cs_interp_env_t &env, flatten_param_t& param)
{
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 ();)
{
const BlendArg &arg = env.argStack[i];
const blend_arg_t &arg = env.argStack[i];
if (arg.blending ())
{
if (unlikely (!((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues))))
@ -122,7 +122,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
}
else
{
StrEncoder encoder (param.flatStr);
str_encoder_t encoder (param.flatStr);
encoder.encode_num (arg);
i++;
}
@ -130,13 +130,13 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
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 */
StrEncoder encoder (param.flatStr);
str_encoder_t encoder (param.flatStr);
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) &&
(arg1.deltas.length == env.get_region_count ())))))
{
@ -148,7 +148,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
/* flatten deltas for each value */
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.length; k++)
encoder.encode_num (arg1.deltas[k]);
}
@ -157,7 +157,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
encoder.encode_op (OpCode_blendcs);
}
static void flush_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param)
static void flush_op (op_code_t op, cff2_cs_interp_env_t &env, flatten_param_t& param)
{
switch (op)
{
@ -165,19 +165,19 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
case OpCode_endchar:
return;
default:
StrEncoder encoder (param.flatStr);
str_encoder_t encoder (param.flatStr);
encoder.encode_op (op);
}
}
private:
typedef CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam> SUPER;
typedef CSOpSet<BlendArg, CFF2CSOpSet_Flatten, CFF2CSOpSet_Flatten, CFF2CSInterpEnv, FlattenParam> CSOPSET;
typedef cff2_cs_opset_t<cff2_cs_opset_flatten_t, flatten_param_t> SUPER;
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 (op_code_t op, cff2_cs_interp_env_t &env, subr_subset_param_t& param)
{
switch (op) {
@ -202,35 +202,35 @@ struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetPa
default:
SUPER::process_op (op, env, param);
param.current_parsed_str->add_op (op, env.substr);
param.current_parsed_str->add_op (op, env.str_ref);
break;
}
}
protected:
static void process_call_subr (OpCode op, CSType type,
CFF2CSInterpEnv &env, SubrSubsetParam& param,
CFF2BiasedSubrs& subrs, hb_set_t *closure)
static void process_call_subr (op_code_t op, cs_type_t type,
cff2_cs_interp_env_t &env, subr_subset_param_t& param,
cff2_biased_subrs_t& subrs, hb_set_t *closure)
{
SubByteStr substr = env.substr;
byte_str_ref_t str_ref = env.str_ref;
env.callSubr (subrs, type);
param.current_parsed_str->add_call_op (op, substr, env.context.subr_num);
param.current_parsed_str->add_call_op (op, str_ref, env.context.subr_num);
hb_set_add (closure, env.context.subr_num);
param.set_current_str (env, true);
}
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 */
if (env.seen_vsindex ())
{
Number ivs;
number_t ivs;
ivs.set_int ((int)env.get_ivs ());
charstring.set_prefix (ivs, OpCode_vsindexcs);
}
@ -278,7 +278,7 @@ struct cff2_subset_plan {
/* top dict */
{
CFF2TopDict_OpSerializer topSzr;
cff2_top_dict_op_serializer_t topSzr;
offsets.topDictInfo.size = TopDict::calculate_serialized_size (acc.topDict, topSzr);
final_size += offsets.topDictInfo.size;
}
@ -286,7 +286,7 @@ struct cff2_subset_plan {
if (desubroutinize)
{
/* 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);
if (!flattener.flatten (subset_charstrings))
return false;
@ -370,7 +370,7 @@ struct cff2_subset_plan {
/* FDArray (FDIndex) */
{
offsets.FDArrayInfo.offset = final_size;
CFFFontDict_OpSerializer fontSzr;
cff_font_dict_op_serializer_t fontSzr;
unsigned int dictsSize = 0;
for (unsigned int i = 0; i < acc.fontDicts.length; i++)
if (fdmap.includes (i))
@ -395,9 +395,9 @@ struct cff2_subset_plan {
if (fdmap.includes (i))
{
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);
TableInfo privInfo = { final_size, priv_size, 0 };
table_info_t privInfo = { final_size, priv_size, 0 };
privateDictInfos.push (privInfo);
final_size += privInfo.size;
@ -415,23 +415,23 @@ struct cff2_subset_plan {
unsigned int get_final_size () const { return final_size; }
unsigned int final_size;
CFF2SubTableOffsets offsets;
cff2_sub_table_offsets_t offsets;
unsigned int orig_fdcount;
unsigned int subset_fdcount;
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;
StrBuffArray subset_globalsubrs;
hb_vector_t<StrBuffArray> subset_localsubrs;
hb_vector_t<TableInfo> privateDictInfos;
str_buff_vec_t subset_charstrings;
str_buff_vec_t subset_globalsubrs;
hb_vector_t<str_buff_vec_t> subset_localsubrs;
hb_vector_t<table_info_t> privateDictInfos;
bool drop_hints;
bool desubroutinize;
CFF2SubrSubsetter subr_subsetter;
cff2_subr_subsetter_t subr_subsetter;
};
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);
cff2->topDictSize.set (plan.offsets.topDictInfo.size);
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)))
{
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);
CFF2FDArray *fda = c.start_embed<CFF2FDArray> ();
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,
acc.fontDicts, plan.subset_fdcount, plan.fdmap,
fontSzr, plan.privateDictInfos)))
@ -539,7 +539,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
if (unlikely (pd == nullptr)) return false;
unsigned int priv_size = plan.privateDictInfos[plan.fdmap[i]].size;
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 */
unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset);