templatized ArgStack as a prep to store blends
This commit is contained in:
parent
968168bf0e
commit
fcf177885b
|
@ -417,23 +417,24 @@ struct Stack
|
|||
};
|
||||
|
||||
/* argument stack */
|
||||
struct ArgStack : Stack<Number, 513>
|
||||
template <typename ARG=Number>
|
||||
struct ArgStack : Stack<ARG, 513>
|
||||
{
|
||||
inline void push_int (int v)
|
||||
{
|
||||
Number n;
|
||||
ARG n;
|
||||
n.set_int (v);
|
||||
push (n);
|
||||
S::push (n);
|
||||
}
|
||||
|
||||
inline void push_real (float v)
|
||||
{
|
||||
Number n;
|
||||
ARG n;
|
||||
n.set_real (v);
|
||||
push (n);
|
||||
S::push (n);
|
||||
}
|
||||
|
||||
inline bool check_pop_num (Number& n)
|
||||
inline bool check_pop_num (ARG& n)
|
||||
{
|
||||
if (unlikely (!this->check_underflow ()))
|
||||
return false;
|
||||
|
@ -441,7 +442,7 @@ struct ArgStack : Stack<Number, 513>
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool check_pop_num2 (Number& n1, Number& n2)
|
||||
inline bool check_pop_num2 (ARG& n1, ARG& n2)
|
||||
{
|
||||
if (unlikely (!this->check_underflow (2)))
|
||||
return false;
|
||||
|
@ -467,15 +468,15 @@ struct ArgStack : Stack<Number, 513>
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool check_pop_delta (hb_vector_t<Number>& vec, bool even=false)
|
||||
inline bool check_pop_delta (hb_vector_t<ARG>& vec, bool even=false)
|
||||
{
|
||||
if (even && unlikely ((this->count & 1) != 0))
|
||||
return false;
|
||||
|
||||
float val = 0.0f;
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
val += elements[i].to_real ();
|
||||
Number *n = vec.push ();
|
||||
for (unsigned int i = 0; i < S::count; i++) {
|
||||
val += S::elements[i].to_real ();
|
||||
ARG *n = vec.push ();
|
||||
n->set_real (val);
|
||||
}
|
||||
return true;
|
||||
|
@ -483,7 +484,7 @@ struct ArgStack : Stack<Number, 513>
|
|||
|
||||
inline bool push_longint_from_substr (SubByteStr& substr)
|
||||
{
|
||||
if (unlikely (!substr.avail (4) || !check_overflow (1)))
|
||||
if (unlikely (!substr.avail (4) || !S::check_overflow (1)))
|
||||
return false;
|
||||
push_int ((int32_t)*(const HBUINT32*)&substr[0]);
|
||||
substr.inc (4);
|
||||
|
@ -492,7 +493,7 @@ struct ArgStack : Stack<Number, 513>
|
|||
|
||||
inline bool push_fixed_from_substr (SubByteStr& substr)
|
||||
{
|
||||
if (unlikely (!substr.avail (4) || !check_overflow (1)))
|
||||
if (unlikely (!substr.avail (4) || !S::check_overflow (1)))
|
||||
return false;
|
||||
push_real ((int32_t)*(const HBUINT32*)&substr[0] / 65536.0);
|
||||
substr.inc (4);
|
||||
|
@ -502,14 +503,17 @@ struct ArgStack : Stack<Number, 513>
|
|||
inline void reverse_range (int i, int j)
|
||||
{
|
||||
assert (i >= 0 && i < j);
|
||||
Number tmp;
|
||||
ARG tmp;
|
||||
while (i < j)
|
||||
{
|
||||
tmp = elements[i];
|
||||
elements[i++] = elements[j];
|
||||
elements[j++] = tmp;
|
||||
tmp = S::elements[i];
|
||||
S::elements[i++] = S::elements[j];
|
||||
S::elements[j++] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typedef Stack<ARG, 513> S;
|
||||
};
|
||||
|
||||
/* an operator prefixed by its operands in a byte string */
|
||||
|
@ -536,6 +540,7 @@ struct OpSerializer
|
|||
}
|
||||
};
|
||||
|
||||
template <typename ARG=Number>
|
||||
struct InterpEnv
|
||||
{
|
||||
inline void init (const ByteStr &str_)
|
||||
|
@ -576,12 +581,15 @@ struct InterpEnv
|
|||
}
|
||||
|
||||
SubByteStr substr;
|
||||
ArgStack argStack;
|
||||
ArgStack<ARG> argStack;
|
||||
};
|
||||
|
||||
typedef InterpEnv<> NumInterpEnv;
|
||||
|
||||
template <typename ARG=Number>
|
||||
struct OpSet
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env)
|
||||
static inline bool process_op (OpCode op, InterpEnv<ARG>& env)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_shortint:
|
||||
|
|
|
@ -57,12 +57,12 @@ struct BiasedSubrs
|
|||
unsigned int bias;
|
||||
};
|
||||
|
||||
template <typename SUBRS>
|
||||
struct CSInterpEnv : InterpEnv
|
||||
template <typename ARG, typename SUBRS>
|
||||
struct CSInterpEnv : InterpEnv<ARG>
|
||||
{
|
||||
inline void init (const ByteStr &str, const SUBRS &globalSubrs_, const SUBRS &localSubrs_)
|
||||
{
|
||||
InterpEnv::init (str);
|
||||
InterpEnv<ARG>::init (str);
|
||||
|
||||
seen_moveto = true;
|
||||
seen_hintmask = false;
|
||||
|
@ -74,7 +74,7 @@ struct CSInterpEnv : InterpEnv
|
|||
}
|
||||
inline void fini (void)
|
||||
{
|
||||
InterpEnv::fini ();
|
||||
InterpEnv<ARG>::fini ();
|
||||
|
||||
callStack.fini ();
|
||||
globalSubrs.fini ();
|
||||
|
@ -85,7 +85,7 @@ struct CSInterpEnv : InterpEnv
|
|||
{
|
||||
int n;
|
||||
if (unlikely ((!callStack.check_overflow (1) ||
|
||||
!argStack.check_pop_int (n))))
|
||||
!SUPER::argStack.check_pop_int (n))))
|
||||
return false;
|
||||
n += biasedSubrs.bias;
|
||||
if (unlikely ((n < 0) || (n >= biasedSubrs.subrs->count)))
|
||||
|
@ -101,8 +101,8 @@ struct CSInterpEnv : InterpEnv
|
|||
|
||||
if (unlikely (!popSubrNum (biasedSubrs, subr_num)))
|
||||
return false;
|
||||
callStack.push (substr);
|
||||
substr = (*biasedSubrs.subrs)[subr_num];
|
||||
callStack.push (SUPER::substr);
|
||||
SUPER::substr = (*biasedSubrs.subrs)[subr_num];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ struct CSInterpEnv : InterpEnv
|
|||
if (unlikely (!callStack.check_underflow ()))
|
||||
return false;
|
||||
|
||||
substr = callStack.pop ();
|
||||
SUPER::substr = callStack.pop ();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ struct CSInterpEnv : InterpEnv
|
|||
{
|
||||
if (!seen_hintmask)
|
||||
{
|
||||
vstem_count += argStack.get_count() / 2;
|
||||
vstem_count += SUPER::argStack.get_count() / 2;
|
||||
hintmask_size = (hstem_count + vstem_count + 7) >> 3;
|
||||
seen_hintmask = true;
|
||||
}
|
||||
|
@ -140,10 +140,13 @@ struct CSInterpEnv : InterpEnv
|
|||
CallStack callStack;
|
||||
BiasedSubrs<SUBRS> globalSubrs;
|
||||
BiasedSubrs<SUBRS> localSubrs;
|
||||
|
||||
private:
|
||||
typedef InterpEnv<ARG> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename ENV, typename PARAM>
|
||||
struct CSOpSet : OpSet
|
||||
template <typename ARG, typename OPSET, typename ENV, typename PARAM>
|
||||
struct CSOpSet : OpSet<ARG>
|
||||
{
|
||||
static inline bool process_op (OpCode op, ENV &env, PARAM& param)
|
||||
{
|
||||
|
@ -204,7 +207,7 @@ struct CSOpSet : OpSet
|
|||
break;
|
||||
|
||||
default:
|
||||
return OpSet::process_op (op, env);
|
||||
return SUPER::process_op (op, env);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -293,6 +296,8 @@ struct CSOpSet : OpSet
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
typedef OpSet<ARG> SUPER;
|
||||
};
|
||||
|
||||
template <typename ENV, typename OPSET, typename PARAM>
|
||||
|
@ -300,20 +305,22 @@ struct CSInterpreter : Interpreter<ENV>
|
|||
{
|
||||
inline bool interpret (PARAM& param)
|
||||
{
|
||||
Interpreter<ENV> &super = *this;
|
||||
super.env.set_endchar (false);
|
||||
SUPER::env.set_endchar (false);
|
||||
|
||||
for (;;) {
|
||||
OpCode op;
|
||||
if (unlikely (!super.env.fetch_op (op) ||
|
||||
!OPSET::process_op (op, super.env, param)))
|
||||
if (unlikely (!SUPER::env.fetch_op (op) ||
|
||||
!OPSET::process_op (op, SUPER::env, param)))
|
||||
return false;
|
||||
if (super.env.is_endchar ())
|
||||
if (SUPER::env.is_endchar ())
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef Interpreter<ENV> SUPER;
|
||||
};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace CFF {
|
|||
using namespace OT;
|
||||
|
||||
/* an opstr and the parsed out dict value(s) */
|
||||
template <typename ARG=Number>
|
||||
struct DictVal : OpStr
|
||||
{
|
||||
inline void init (void)
|
||||
|
@ -46,10 +47,12 @@ struct DictVal : OpStr
|
|||
multi_val.fini ();
|
||||
}
|
||||
|
||||
Number single_val;
|
||||
hb_vector_t<Number> multi_val;
|
||||
ARG single_val;
|
||||
hb_vector_t<ARG> multi_val;
|
||||
};
|
||||
|
||||
typedef DictVal<> NumDictVal;
|
||||
|
||||
template <typename VAL>
|
||||
struct DictValues
|
||||
{
|
||||
|
@ -115,9 +118,10 @@ struct TopDictValues : DictValues<OpStr>
|
|||
unsigned int FDArrayOffset;
|
||||
};
|
||||
|
||||
struct DictOpSet : OpSet
|
||||
template <typename ARG=Number>
|
||||
struct DictOpSet : OpSet<ARG>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env)
|
||||
static inline bool process_op (OpCode op, InterpEnv<ARG>& env)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_longintdict: /* 5-byte integer */
|
||||
|
@ -130,7 +134,7 @@ struct DictOpSet : OpSet
|
|||
return true;
|
||||
|
||||
default:
|
||||
return OpSet::process_op (op, env);
|
||||
return OpSet<ARG>::process_op (op, env);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -161,9 +165,10 @@ struct DictOpSet : OpSet
|
|||
}
|
||||
};
|
||||
|
||||
struct TopDictOpSet : DictOpSet
|
||||
template <typename ARG=Number>
|
||||
struct TopDictOpSet : DictOpSet<ARG>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, TopDictValues& dictval)
|
||||
static inline bool process_op (OpCode op, InterpEnv<ARG>& env, TopDictValues& dictval)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_CharStrings:
|
||||
|
@ -177,30 +182,32 @@ struct TopDictOpSet : DictOpSet
|
|||
env.clear_args ();
|
||||
break;
|
||||
default:
|
||||
return DictOpSet::process_op (op, env);
|
||||
return DictOpSet<ARG>::process_op (op, env);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
struct DictInterpreter : Interpreter<InterpEnv>
|
||||
template <typename OPSET, typename PARAM, typename ENV=NumInterpEnv>
|
||||
struct DictInterpreter : Interpreter<ENV>
|
||||
{
|
||||
inline bool interpret (PARAM& param)
|
||||
{
|
||||
param.init ();
|
||||
Interpreter<InterpEnv> &super = *this;
|
||||
do
|
||||
{
|
||||
OpCode op;
|
||||
if (unlikely (!super.env.fetch_op (op) ||
|
||||
!OPSET::process_op (op, super.env, param)))
|
||||
if (unlikely (!SUPER::env.fetch_op (op) ||
|
||||
!OPSET::process_op (op, SUPER::env, param)))
|
||||
return false;
|
||||
} while (super.env.substr.avail ());
|
||||
} while (SUPER::env.substr.avail ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef Interpreter<ENV> SUPER;
|
||||
};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
|
|
@ -33,11 +33,11 @@ namespace CFF {
|
|||
|
||||
using namespace OT;
|
||||
|
||||
struct CFF1CSInterpEnv : CSInterpEnv<CFF1Subrs>
|
||||
struct CFF1CSInterpEnv : CSInterpEnv<Number, CFF1Subrs>
|
||||
{
|
||||
inline void init (const ByteStr &str, const CFF1Subrs &globalSubrs, const CFF1Subrs &localSubrs)
|
||||
{
|
||||
CSInterpEnv<CFF1Subrs>::init (str, globalSubrs, localSubrs);
|
||||
SUPER::init (str, globalSubrs, localSubrs);
|
||||
processed_width = false;
|
||||
has_width = false;
|
||||
for (unsigned int i = 0; i < kTransientArraySize; i++)
|
||||
|
@ -51,9 +51,9 @@ struct CFF1CSInterpEnv : CSInterpEnv<CFF1Subrs>
|
|||
{
|
||||
if (!processed_width)
|
||||
{
|
||||
if ((this->argStack.count & 1) != 0)
|
||||
if ((SUPER::argStack.count & 1) != 0)
|
||||
{
|
||||
width = this->argStack.elements[0];
|
||||
width = SUPER::argStack.elements[0];
|
||||
has_width = true;
|
||||
}
|
||||
processed_width = true;
|
||||
|
@ -66,10 +66,13 @@ struct CFF1CSInterpEnv : CSInterpEnv<CFF1Subrs>
|
|||
|
||||
static const unsigned int kTransientArraySize = 32;
|
||||
Number transient_array[kTransientArraySize];
|
||||
|
||||
private:
|
||||
typedef CSInterpEnv<Number, CFF1Subrs> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
struct CFF1CSOpSet : CSOpSet<OPSET, CFF1CSInterpEnv, PARAM>
|
||||
struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM>
|
||||
{
|
||||
static inline bool process_op (OpCode op, CFF1CSInterpEnv &env, PARAM& param)
|
||||
{
|
||||
|
@ -201,7 +204,7 @@ struct CFF1CSOpSet : CSOpSet<OPSET, CFF1CSInterpEnv, PARAM>
|
|||
}
|
||||
|
||||
private:
|
||||
typedef CSOpSet<OPSET, CFF1CSInterpEnv, PARAM> SUPER;
|
||||
typedef CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
|
|
|
@ -33,18 +33,18 @@ namespace CFF {
|
|||
|
||||
using namespace OT;
|
||||
|
||||
struct CFF2CSInterpEnv : CSInterpEnv<CFF2Subrs>
|
||||
struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
|
||||
{
|
||||
inline void init (const ByteStr &str, const CFF2Subrs &globalSubrs_, const CFF2Subrs &localSubrs_)
|
||||
{
|
||||
CSInterpEnv<CFF2Subrs>::init (str, globalSubrs_, localSubrs_);
|
||||
SUPER::init (str, globalSubrs_, localSubrs_);
|
||||
ivs = 0;
|
||||
}
|
||||
|
||||
inline bool fetch_op (OpCode &op)
|
||||
{
|
||||
if (unlikely (this->substr.avail ()))
|
||||
return CSInterpEnv<CFF2Subrs>::fetch_op (op);
|
||||
return SUPER::fetch_op (op);
|
||||
|
||||
/* make up return or endchar op */
|
||||
if (this->callStack.check_underflow ())
|
||||
|
@ -66,10 +66,12 @@ struct CFF2CSInterpEnv : CSInterpEnv<CFF2Subrs>
|
|||
|
||||
protected:
|
||||
unsigned int ivs;
|
||||
|
||||
typedef CSInterpEnv<BlendArg, CFF2Subrs> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
struct CFF2CSOpSet : CSOpSet<OPSET, CFF2CSInterpEnv, PARAM>
|
||||
struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM>
|
||||
{
|
||||
static inline bool process_op (OpCode op, CFF2CSInterpEnv &env, PARAM& param)
|
||||
{
|
||||
|
@ -83,7 +85,6 @@ struct CFF2CSOpSet : CSOpSet<OPSET, CFF2CSInterpEnv, PARAM>
|
|||
break;
|
||||
|
||||
default:
|
||||
typedef CSOpSet<OPSET, CFF2CSInterpEnv, PARAM> SUPER;
|
||||
if (unlikely (!SUPER::process_op (op, env, param)))
|
||||
return false;
|
||||
break;
|
||||
|
@ -103,6 +104,9 @@ struct CFF2CSOpSet : CSOpSet<OPSET, CFF2CSInterpEnv, PARAM>
|
|||
env.process_vsindex ();
|
||||
OPSET::flush_n_args_and_op (OpCode_vsindexcs, 1, env, param);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
|
|
|
@ -407,9 +407,9 @@ struct CFF1TopDictValues : TopDictValues
|
|||
TableInfo privateDictInfo;
|
||||
};
|
||||
|
||||
struct CFF1TopDictOpSet : TopDictOpSet
|
||||
struct CFF1TopDictOpSet : TopDictOpSet<>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF1TopDictValues& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF1TopDictValues& dictval)
|
||||
{
|
||||
|
||||
switch (op) {
|
||||
|
@ -509,9 +509,9 @@ struct CFF1FontDictValues : DictValues<OpStr>
|
|||
TableInfo privateDictInfo;
|
||||
};
|
||||
|
||||
struct CFF1FontDictOpSet : DictOpSet
|
||||
struct CFF1FontDictOpSet : DictOpSet<>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF1FontDictValues& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF1FontDictValues& dictval)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_FontName:
|
||||
|
@ -570,13 +570,13 @@ struct CFF1PrivateDictValues_Base : DictValues<VAL>
|
|||
};
|
||||
|
||||
typedef CFF1PrivateDictValues_Base<OpStr> CFF1PrivateDictValues_Subset;
|
||||
typedef CFF1PrivateDictValues_Base<DictVal> CFF1PrivateDictValues;
|
||||
typedef CFF1PrivateDictValues_Base<NumDictVal> CFF1PrivateDictValues;
|
||||
|
||||
struct CFF1PrivateDictOpSet : DictOpSet
|
||||
struct CFF1PrivateDictOpSet : DictOpSet<>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF1PrivateDictValues& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues& dictval)
|
||||
{
|
||||
DictVal val;
|
||||
NumDictVal val;
|
||||
val.init ();
|
||||
|
||||
switch (op) {
|
||||
|
@ -622,9 +622,9 @@ struct CFF1PrivateDictOpSet : DictOpSet
|
|||
}
|
||||
};
|
||||
|
||||
struct CFF1PrivateDictOpSet_Subset : DictOpSet
|
||||
struct CFF1PrivateDictOpSet_Subset : DictOpSet<>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF1PrivateDictValues_Subset& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues_Subset& dictval)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_BlueValues:
|
||||
|
@ -690,7 +690,7 @@ struct cff1
|
|||
likely (version.major == 1));
|
||||
}
|
||||
|
||||
template <typename PrivOpSet, typename PrivDictVal>
|
||||
template <typename PRIVOPSET, typename PRIVDICTVAL>
|
||||
struct accelerator_templ_t
|
||||
{
|
||||
inline void init (hb_face_t *face)
|
||||
|
@ -788,10 +788,10 @@ struct cff1
|
|||
font_interp.env.init (fontDictStr);
|
||||
font = fontDicts.push ();
|
||||
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
|
||||
PrivDictVal *priv = &privateDicts[i];
|
||||
PRIVDICTVAL *priv = &privateDicts[i];
|
||||
const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||
DictInterpreter<PrivOpSet, PrivDictVal> priv_interp;
|
||||
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||
priv_interp.env.init (privDictStr);
|
||||
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
|
||||
|
||||
|
@ -804,11 +804,11 @@ struct cff1
|
|||
else /* non-CID */
|
||||
{
|
||||
CFF1TopDictValues *font = &topDicts[0];
|
||||
PrivDictVal *priv = &privateDicts[0];
|
||||
PRIVDICTVAL *priv = &privateDicts[0];
|
||||
|
||||
const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||
DictInterpreter<PrivOpSet, PrivDictVal> priv_interp;
|
||||
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||
priv_interp.env.init (privDictStr);
|
||||
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
|
||||
|
||||
|
@ -861,7 +861,7 @@ struct cff1
|
|||
|
||||
hb_vector_t<CFF1TopDictValues> topDicts;
|
||||
hb_vector_t<CFF1FontDictValues> fontDicts;
|
||||
hb_vector_t<PrivDictVal> privateDicts;
|
||||
hb_vector_t<PRIVDICTVAL> privateDicts;
|
||||
|
||||
unsigned int num_glyphs;
|
||||
};
|
||||
|
|
|
@ -48,6 +48,13 @@ typedef Subrs<HBUINT32> CFF2Subrs;
|
|||
typedef FDSelect3_4<HBUINT32, HBUINT16> FDSelect4;
|
||||
typedef FDSelect3_4_Range<HBUINT32, HBUINT16> FDSelect4_Range;
|
||||
|
||||
struct BlendArg : Number
|
||||
{
|
||||
// XXX: TODO
|
||||
};
|
||||
|
||||
typedef InterpEnv<BlendArg> BlendInterpEnv;
|
||||
|
||||
struct CFF2FDSelect
|
||||
{
|
||||
inline bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const
|
||||
|
@ -173,14 +180,14 @@ struct CFF2TopDictValues : TopDictValues
|
|||
unsigned int FDSelectOffset;
|
||||
};
|
||||
|
||||
struct CFF2TopDictOpSet : TopDictOpSet
|
||||
struct CFF2TopDictOpSet : TopDictOpSet<>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF2TopDictValues& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF2TopDictValues& dictval)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_FontMatrix:
|
||||
{
|
||||
DictVal val;
|
||||
DictVal<> val;
|
||||
val.init ();
|
||||
dictval.pushVal (op, env.substr);
|
||||
env.clear_args ();
|
||||
|
@ -199,7 +206,7 @@ struct CFF2TopDictOpSet : TopDictOpSet
|
|||
break;
|
||||
|
||||
default:
|
||||
if (unlikely (!TopDictOpSet::process_op (op, env, dictval)))
|
||||
if (unlikely (!SUPER::process_op (op, env, dictval)))
|
||||
return false;
|
||||
/* Record this operand below if stack is empty, otherwise done */
|
||||
if (!env.argStack.is_empty ()) return true;
|
||||
|
@ -208,6 +215,8 @@ struct CFF2TopDictOpSet : TopDictOpSet
|
|||
dictval.pushVal (op, env.substr);
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef TopDictOpSet<> SUPER;
|
||||
};
|
||||
|
||||
struct CFF2FontDictValues : DictValues<OpStr>
|
||||
|
@ -226,9 +235,9 @@ struct CFF2FontDictValues : DictValues<OpStr>
|
|||
TableInfo privateDictInfo;
|
||||
};
|
||||
|
||||
struct CFF2FontDictOpSet : DictOpSet
|
||||
struct CFF2FontDictOpSet : DictOpSet<>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF2FontDictValues& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF2FontDictValues& dictval)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_Private:
|
||||
|
@ -240,7 +249,7 @@ struct CFF2FontDictOpSet : DictOpSet
|
|||
break;
|
||||
|
||||
default:
|
||||
if (unlikely (!DictOpSet::process_op (op, env)))
|
||||
if (unlikely (!SUPER::process_op (op, env)))
|
||||
return false;
|
||||
if (!env.argStack.is_empty ())
|
||||
return true;
|
||||
|
@ -249,6 +258,9 @@ struct CFF2FontDictOpSet : DictOpSet
|
|||
dictval.pushVal (op, env.substr);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef DictOpSet<> SUPER;
|
||||
};
|
||||
|
||||
template <typename VAL>
|
||||
|
@ -281,14 +293,15 @@ struct CFF2PrivateDictValues_Base : DictValues<VAL>
|
|||
const CFF2Subrs *localSubrs;
|
||||
};
|
||||
|
||||
typedef DictVal<BlendArg> BlendDictVal;
|
||||
typedef CFF2PrivateDictValues_Base<OpStr> CFF2PrivateDictValues_Subset;
|
||||
typedef CFF2PrivateDictValues_Base<DictVal> CFF2PrivateDictValues;
|
||||
typedef CFF2PrivateDictValues_Base<NumDictVal> CFF2PrivateDictValues;
|
||||
|
||||
struct CFF2PrivateDictOpSet : DictOpSet
|
||||
struct CFF2PrivateDictOpSet : DictOpSet<>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF2PrivateDictValues& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF2PrivateDictValues& dictval)
|
||||
{
|
||||
DictVal val;
|
||||
NumDictVal val;
|
||||
val.init ();
|
||||
|
||||
switch (op) {
|
||||
|
@ -335,9 +348,9 @@ struct CFF2PrivateDictOpSet : DictOpSet
|
|||
}
|
||||
};
|
||||
|
||||
struct CFF2PrivateDictOpSet_Subset : DictOpSet
|
||||
struct CFF2PrivateDictOpSet_Subset : DictOpSet<Number>
|
||||
{
|
||||
static inline bool process_op (OpCode op, InterpEnv& env, CFF2PrivateDictValues_Subset& dictval)
|
||||
static inline bool process_op (OpCode op, NumInterpEnv& env, CFF2PrivateDictValues_Subset& dictval)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_BlueValues:
|
||||
|
@ -367,7 +380,7 @@ struct CFF2PrivateDictOpSet_Subset : DictOpSet
|
|||
break;
|
||||
|
||||
default:
|
||||
if (unlikely (!DictOpSet::process_op (op, env)))
|
||||
if (unlikely (!SUPER::process_op (op, env)))
|
||||
return false;
|
||||
if (!env.argStack.is_empty ()) return true;
|
||||
break;
|
||||
|
@ -376,11 +389,13 @@ struct CFF2PrivateDictOpSet_Subset : DictOpSet
|
|||
dictval.pushVal (op, env.substr);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef DictOpSet<Number> SUPER;
|
||||
};
|
||||
|
||||
typedef DictInterpreter<CFF2TopDictOpSet, CFF2TopDictValues> CFF2TopDict_Interpreter;
|
||||
typedef DictInterpreter<CFF2FontDictOpSet, CFF2FontDictValues> CFF2FontDict_Interpreter;
|
||||
typedef DictInterpreter<CFF2PrivateDictOpSet, CFF2PrivateDictValues> CFF2PrivateDict_Interpreter;
|
||||
|
||||
}; /* namespace CFF */
|
||||
|
||||
|
@ -399,7 +414,7 @@ struct cff2
|
|||
likely (version.major == 2));
|
||||
}
|
||||
|
||||
template <typename PrivOpSet, typename PrivDictVal>
|
||||
template <typename PRIVOPSET, typename PRIVDICTVAL>
|
||||
struct accelerator_templ_t
|
||||
{
|
||||
inline void init (hb_face_t *face)
|
||||
|
@ -459,7 +474,7 @@ struct cff2
|
|||
|
||||
const ByteStr privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||
DictInterpreter<PrivOpSet, PrivDictVal> priv_interp;
|
||||
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||
priv_interp.env.init(privDictStr);
|
||||
if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; }
|
||||
|
||||
|
@ -505,7 +520,7 @@ struct cff2
|
|||
unsigned int fdCount;
|
||||
|
||||
hb_vector_t<CFF2FontDictValues> fontDicts;
|
||||
hb_vector_t<PrivDictVal> privateDicts;
|
||||
hb_vector_t<PRIVDICTVAL> privateDicts;
|
||||
|
||||
unsigned int num_glyphs;
|
||||
};
|
||||
|
|
|
@ -219,7 +219,7 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
|
|||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
|
||||
if (drop_hints && DictOpSet::is_hint_op (opstr.op))
|
||||
if (drop_hints && DictOpSet<>::is_hint_op (opstr.op))
|
||||
return true;
|
||||
if (opstr.op == OpCode_Subrs)
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
|
|||
|
||||
inline unsigned int calculate_serialized_size (const OpStr &opstr) const
|
||||
{
|
||||
if (drop_hints && DictOpSet::is_hint_op (opstr.op))
|
||||
if (drop_hints && DictOpSet<>::is_hint_op (opstr.op))
|
||||
return 0;
|
||||
if (opstr.op == OpCode_Subrs)
|
||||
{
|
||||
|
|
|
@ -154,7 +154,6 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam>
|
|||
|
||||
private:
|
||||
typedef CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam> SUPER;
|
||||
typedef CSOpSet<CFF1CSOpSet_Flatten, CFF1CSInterpEnv, FlattenParam> CSOPSET;
|
||||
};
|
||||
|
||||
struct CFF1CSOpSet_SubsetSubrs : CFF1CSOpSet<CFF1CSOpSet_SubsetSubrs, SubrRefMapPair>
|
||||
|
|
|
@ -129,7 +129,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
|||
|
||||
private:
|
||||
typedef CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam> SUPER;
|
||||
typedef CSOpSet<CFF2CSOpSet_Flatten, CFF2CSInterpEnv, FlattenParam> CSOPSET;
|
||||
typedef CSOpSet<BlendArg, CFF2CSOpSet_Flatten, CFF2CSInterpEnv, FlattenParam> CSOPSET;
|
||||
};
|
||||
|
||||
struct CFF2CSOpSet_SubsetSubrs : CFF2CSOpSet<CFF2CSOpSet_SubsetSubrs, SubrRefMapPair>
|
||||
|
|
Loading…
Reference in New Issue