提交 29f0b6bc 编写于 作者: M Michiharu Ariza 提交者: Behdad Esfahbod

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 21163c30e9d18759414f7fe2518628241599f039.

* fix tabs
上级 89d04129
......@@ -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 (); }
......
此差异已折叠。
......@@ -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 */
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
hb_vector_t<CFF2FontDictValues> fontDicts;
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<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
{
......
......@@ -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> ();
......
此差异已折叠。
此差异已折叠。
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册