[cff] Remove custom byte_str_t impl
This commit is contained in:
parent
c8a5f1e3c0
commit
fe1d85a55a
|
@ -248,6 +248,9 @@ struct number_t
|
|||
/* byte string */
|
||||
struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
|
||||
{
|
||||
hb_ubytes_t as_ubytes (unsigned l) const
|
||||
{ return hb_ubytes_t ((const unsigned char *) this, l); }
|
||||
|
||||
// encode 2-byte int (Dict/CharString) or 4-byte int (Dict)
|
||||
template <typename T, typename V>
|
||||
static bool serialize_int (hb_serialize_context_t *c, op_code_t intOp, V value)
|
||||
|
@ -281,25 +284,7 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
|
|||
DEFINE_SIZE_MIN(0);
|
||||
};
|
||||
|
||||
/* Holder of a section of byte string within a CFFIndex entry */
|
||||
struct byte_str_t : hb_ubytes_t
|
||||
{
|
||||
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 */
|
||||
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 <= length); }
|
||||
};
|
||||
using byte_str_t = hb_ubytes_t;
|
||||
|
||||
/* A byte string associated with the current offset and an error condition */
|
||||
struct byte_str_ref_t
|
||||
|
@ -335,13 +320,13 @@ struct byte_str_ref_t
|
|||
}
|
||||
|
||||
/* Conversion to byte_str_t */
|
||||
operator byte_str_t () const { return str.sub_str (offset, str.length - offset); }
|
||||
operator byte_str_t () const { return str.sub_array (offset, str.length - offset); }
|
||||
|
||||
byte_str_t sub_str (unsigned int offset_, unsigned int len_) const
|
||||
{ return str.sub_str (offset_, len_); }
|
||||
byte_str_t sub_array (unsigned int offset_, unsigned int len_) const
|
||||
{ return str.sub_array (offset_, len_); }
|
||||
|
||||
bool avail (unsigned int count=1) const
|
||||
{ return (!in_error () && str.check_limit (offset, count)); }
|
||||
{ return (!in_error () && offset + count <= str.length); }
|
||||
void inc (unsigned int count=1)
|
||||
{
|
||||
if (likely (!in_error () && (offset <= str.length) && (offset + count <= str.length)))
|
||||
|
@ -551,7 +536,7 @@ struct parsed_values_t
|
|||
{
|
||||
VAL *val = values.push ();
|
||||
val->op = op;
|
||||
val->str = str_ref.str.sub_str (opStart, str_ref.offset - opStart);
|
||||
val->str = str_ref.str.sub_array (opStart, str_ref.offset - opStart);
|
||||
opStart = str_ref.offset;
|
||||
}
|
||||
|
||||
|
@ -559,7 +544,7 @@ struct parsed_values_t
|
|||
{
|
||||
VAL *val = values.push (v);
|
||||
val->op = op;
|
||||
val->str = str_ref.sub_str ( opStart, str_ref.offset - opStart);
|
||||
val->str = str_ref.sub_array ( opStart, str_ref.offset - opStart);
|
||||
opStart = str_ref.offset;
|
||||
}
|
||||
|
||||
|
|
|
@ -1108,7 +1108,7 @@ struct cff1
|
|||
font->init ();
|
||||
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
|
||||
PRIVDICTVAL *priv = &privateDicts[i];
|
||||
const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||
const byte_str_t privDictStr = StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset).as_ubytes (font->privateDictInfo.size);
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||
priv_interp.env.init (privDictStr);
|
||||
|
@ -1126,7 +1126,7 @@ struct cff1
|
|||
cff1_top_dict_values_t *font = &topDict;
|
||||
PRIVDICTVAL *priv = &privateDicts[0];
|
||||
|
||||
const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||
const byte_str_t privDictStr = StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset).as_ubytes (font->privateDictInfo.size);
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||
priv_interp.env.init (privDictStr);
|
||||
|
|
|
@ -415,7 +415,7 @@ struct cff2
|
|||
goto fail;
|
||||
|
||||
{ /* parse top dict */
|
||||
byte_str_t topDictStr (cff2 + cff2->topDict, cff2->topDictSize);
|
||||
byte_str_t topDictStr = (cff2 + cff2->topDict).as_ubytes (cff2->topDictSize);
|
||||
if (unlikely (!topDictStr.sanitize (&sc))) goto fail;
|
||||
cff2_top_dict_interpreter_t top_interp;
|
||||
top_interp.env.init (topDictStr);
|
||||
|
@ -457,7 +457,7 @@ struct cff2
|
|||
font->init ();
|
||||
if (unlikely (!font_interp.interpret (*font))) goto fail;
|
||||
|
||||
const byte_str_t privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size);
|
||||
const byte_str_t privDictStr = StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset).as_ubytes (font->privateDictInfo.size);
|
||||
if (unlikely (!privDictStr.sanitize (&sc))) goto fail;
|
||||
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL, cff2_priv_dict_interp_env_t> priv_interp;
|
||||
priv_interp.env.init(privDictStr);
|
||||
|
|
Loading…
Reference in New Issue