removed unused code & data; rename

This commit is contained in:
ariza 2020-03-04 16:54:27 -08:00 committed by Ebrahim Byagowi
parent 14a7b6f1ab
commit e8f010d793
6 changed files with 31 additions and 223 deletions

View File

@ -58,19 +58,6 @@ struct top_dict_values_t : dict_values_t<OPSTR>
}
void fini () { dict_values_t<OPSTR>::fini (); }
unsigned int calculate_serialized_op_size (const OPSTR& opstr) const
{
switch (opstr.op)
{
case OpCode_CharStrings:
case OpCode_FDArray:
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
default:
return opstr.str.length;
}
}
unsigned int charStringsOffset;
unsigned int FDArrayOffset;
};

View File

@ -102,13 +102,6 @@ struct CFFIndex
return_trace (out);
}
static unsigned int calculate_serialized_size (unsigned int offSize_, unsigned int count,
unsigned int dataSize)
{
if (count == 0) return COUNT::static_size;
return min_size + calculate_offset_array_size (offSize_, count) + dataSize;
}
bool serialize (hb_serialize_context_t *c, const CFFIndex &src)
{
TRACE_SERIALIZE (this);
@ -369,27 +362,6 @@ struct CFFIndexOf : CFFIndex<COUNT>
}
return_trace (true);
}
/* in parallel to above */
template <typename DATA, typename PARAM>
static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */,
const DATA *dataArray,
unsigned int dataArrayLen,
hb_vector_t<unsigned int> &dataSizeArray, /* OUT */
const PARAM &param)
{
/* determine offset size */
unsigned int totalDataSize = 0;
for (unsigned int i = 0; i < dataArrayLen; i++)
{
unsigned int dataSize = TYPE::calculate_serialized_size (dataArray[i], param);
dataSizeArray[i] = dataSize;
totalDataSize += dataSize;
}
offSize_ = calcOffSize (totalDataSize);
return CFFIndex<COUNT>::calculate_serialized_size (offSize_, dataArrayLen, totalDataSize);
}
};
/* Top Dict, Font Dict, Private Dict */
@ -409,28 +381,6 @@ struct Dict : UnsizedByteStr
return_trace (true);
}
/* in parallel to above */
template <typename DICTVAL, typename OP_SERIALIZER, typename PARAM>
static unsigned int calculate_serialized_size (const DICTVAL &dictval,
OP_SERIALIZER& opszr,
PARAM& param)
{
unsigned int size = 0;
for (unsigned int i = 0; i < dictval.get_count (); i++)
size += opszr.calculate_serialized_size (dictval[i], param);
return size;
}
template <typename DICTVAL, typename OP_SERIALIZER>
static unsigned int calculate_serialized_size (const DICTVAL &dictval,
OP_SERIALIZER& opszr)
{
unsigned int size = 0;
for (unsigned int i = 0; i < dictval.get_count (); i++)
size += opszr.calculate_serialized_size (dictval[i]);
return size;
}
template <typename T, typename V>
static bool serialize_int_op (hb_serialize_context_t *c, op_code_t op, V value, op_code_t intOp)
{
@ -460,12 +410,6 @@ struct Dict : UnsizedByteStr
static bool serialize_int2_op (hb_serialize_context_t *c, op_code_t op, V value)
{ return serialize_int_op<HBINT16> (c, op, value, OpCode_shortint); }
static bool serialize_offset4_op (hb_serialize_context_t *c, op_code_t op, unsigned value)
{ return serialize_int4_op (c, op, value); }
static bool serialize_offset2_op (hb_serialize_context_t *c, op_code_t op, unsigned value)
{ return serialize_int2_op (c, op, value); }
template <typename T, int int_op>
static bool serialize_link_op (hb_serialize_context_t *c, op_code_t op, objidx_t link, whence_t whence)
{
@ -488,11 +432,10 @@ struct PrivateDict : Dict {};
struct table_info_t
{
void init () { offSize = offset = size = 0; link = 0; }
void init () { offset = size = 0; link = 0; }
unsigned int offset;
unsigned int size;
unsigned int offSize;
objidx_t link;
};
@ -624,9 +567,6 @@ struct FDSelect
return_trace (true);
}
unsigned int calculate_serialized_size (unsigned int num_glyphs) const
{ return get_size (num_glyphs); }
unsigned int get_size (unsigned int num_glyphs) const
{
switch (format)

View File

@ -240,23 +240,6 @@ struct Encoding
return_trace (true);
}
/* parallel to above: calculate the size of a subset Encoding */
static unsigned int calculate_serialized_size (uint8_t format,
unsigned int enc_count,
unsigned int supp_count)
{
unsigned int size = min_size;
switch (format)
{
case 0: size += Encoding0::min_size + HBUINT8::static_size * enc_count; break;
case 1: size += Encoding1::min_size + Encoding1_Range::static_size * enc_count; break;
default:return 0;
}
if (supp_count > 0)
size += CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_count;
return size;
}
unsigned int get_size () const
{
unsigned int size = min_size;
@ -525,19 +508,6 @@ struct Charset
return_trace (true);
}
/* parallel to above: calculate the size of a subset Charset */
static unsigned int calculate_serialized_size (uint8_t format,
unsigned int count)
{
switch (format)
{
case 0: return min_size + Charset0::min_size + HBUINT16::static_size * (count - 1);
case 1: return min_size + Charset1::min_size + Charset1_Range::static_size * count;
case 2: return min_size + Charset2::min_size + Charset2_Range::static_size * count;
default:return 0;
}
}
unsigned int get_size (unsigned int num_glyphs) const
{
switch (format)
@ -713,7 +683,7 @@ struct cff1_top_dict_values_t : top_dict_values_t<cff1_top_dict_val_t>
EncodingOffset = 0;
CharsetOffset = 0;
FDSelectOffset = 0;
privateDictInfo.init ();
private_dict_info.init ();
}
void fini () { top_dict_values_t<cff1_top_dict_val_t>::fini (); }
@ -728,7 +698,7 @@ struct cff1_top_dict_values_t : top_dict_values_t<cff1_top_dict_val_t>
unsigned int EncodingOffset;
unsigned int CharsetOffset;
unsigned int FDSelectOffset;
table_info_t privateDictInfo;
table_info_t private_dict_info;
};
struct cff1_top_dict_opset_t : top_dict_opset_t<cff1_top_dict_val_t>
@ -799,8 +769,8 @@ struct cff1_top_dict_opset_t : top_dict_opset_t<cff1_top_dict_val_t>
break;
case OpCode_Private:
dictval.privateDictInfo.offset = env.argStack.pop_uint ();
dictval.privateDictInfo.size = env.argStack.pop_uint ();
dictval.private_dict_info.offset = env.argStack.pop_uint ();
dictval.private_dict_info.size = env.argStack.pop_uint ();
env.clear_args ();
break;
@ -823,12 +793,12 @@ struct cff1_font_dict_values_t : dict_values_t<op_str_t>
void init ()
{
dict_values_t<op_str_t>::init ();
privateDictInfo.init ();
private_dict_info.init ();
fontName = CFF_UNDEF_SID;
}
void fini () { dict_values_t<op_str_t>::fini (); }
table_info_t privateDictInfo;
table_info_t private_dict_info;
unsigned int fontName;
};
@ -846,8 +816,8 @@ struct cff1_font_dict_opset_t : dict_opset_t
env.clear_args ();
break;
case OpCode_Private:
dictval.privateDictInfo.offset = env.argStack.pop_uint ();
dictval.privateDictInfo.size = env.argStack.pop_uint ();
dictval.private_dict_info.offset = env.argStack.pop_uint ();
dictval.private_dict_info.size = env.argStack.pop_uint ();
env.clear_args ();
break;
@ -874,17 +844,6 @@ struct cff1_private_dict_values_base_t : dict_values_t<VAL>
}
void fini () { dict_values_t<VAL>::fini (); }
unsigned int calculate_serialized_size () const
{
unsigned int size = 0;
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 += dict_values_t<VAL>::get_value (i).str.length;
return size;
}
unsigned int subrsOffset;
const CFF1Subrs *localSubrs;
};
@ -998,7 +957,7 @@ struct cff1_font_dict_values_mod_t
{
base = base_;
fontName = fontName_;
privateDictInfo.init ();
private_dict_info.init ();
}
unsigned get_count () const { return base->get_count (); }
@ -1006,7 +965,7 @@ struct cff1_font_dict_values_mod_t
const op_str_t &operator [] (unsigned int i) const { return (*base)[i]; }
const cff1_font_dict_values_t *base;
table_info_t privateDictInfo;
table_info_t private_dict_info;
unsigned int fontName;
};
@ -1147,7 +1106,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->private_dict_info.offset), font->private_dict_info.size);
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
priv_interp.env.init (privDictStr);
@ -1165,7 +1124,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->private_dict_info.offset), font->private_dict_info.size);
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
priv_interp.env.init (privDictStr);

View File

@ -60,9 +60,6 @@ struct CFF2FDSelect
return_trace (true);
}
unsigned int calculate_serialized_size (unsigned int num_glyphs) const
{ return get_size (num_glyphs); }
unsigned int get_size (unsigned int num_glyphs) const
{
switch (format)
@ -149,26 +146,6 @@ struct cff2_top_dict_values_t : top_dict_values_t<>
}
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++)
{
op_code_t op = get_value (i).op;
switch (op)
{
case OpCode_vstore:
case OpCode_FDSelect:
size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op);
break;
default:
size += top_dict_values_t<>::calculate_serialized_op_size (get_value (i));
break;
}
}
return size;
}
unsigned int vstoreOffset;
unsigned int FDSelectOffset;
};
@ -215,11 +192,11 @@ struct cff2_font_dict_values_t : dict_values_t<op_str_t>
void init ()
{
dict_values_t<op_str_t>::init ();
privateDictInfo.init ();
private_dict_info.init ();
}
void fini () { dict_values_t<op_str_t>::fini (); }
table_info_t privateDictInfo;
table_info_t private_dict_info;
};
struct cff2_font_dict_opset_t : dict_opset_t
@ -228,8 +205,8 @@ struct cff2_font_dict_opset_t : dict_opset_t
{
switch (op) {
case OpCode_Private:
dictval.privateDictInfo.offset = env.argStack.pop_uint ();
dictval.privateDictInfo.size = env.argStack.pop_uint ();
dictval.private_dict_info.offset = env.argStack.pop_uint ();
dictval.private_dict_info.size = env.argStack.pop_uint ();
env.clear_args ();
break;
@ -260,17 +237,6 @@ struct cff2_private_dict_values_base_t : dict_values_t<VAL>
}
void fini () { dict_values_t<VAL>::fini (); }
unsigned int calculate_serialized_size () const
{
unsigned int size = 0;
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 += dict_values_t<VAL>::get_value (i).str.length;
return size;
}
unsigned int subrsOffset;
const CFF2Subrs *localSubrs;
unsigned int ivs;
@ -490,7 +456,7 @@ struct cff2
font->init ();
if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
const byte_str_t privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size);
const byte_str_t privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->private_dict_info.offset), font->private_dict_info.size);
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
dict_interpreter_t<PRIVOPSET, PRIVDICTVAL, cff2_priv_dict_interp_env_t> priv_interp;
priv_interp.env.init(privDictStr);

View File

@ -131,20 +131,14 @@ struct str_encoder_t
struct cff_sub_table_info_t {
cff_sub_table_info_t ()
: fd_array_link (0),
char_strings_link (0),
private_dicts_offset (0)
char_strings_link (0)
{
top_dict.init ();
fd_select.init ();
global_subrs.init ();
}
table_info_t top_dict;
table_info_t fd_select;
objidx_t fd_array_link;
objidx_t char_strings_link;
unsigned int private_dicts_offset;
table_info_t global_subrs;
};
template <typename OPSTR=op_str_t>
@ -172,35 +166,21 @@ struct cff_top_dict_op_serializer_t : op_serializer_t
}
return_trace (true);
}
unsigned int calculate_serialized_size (const OPSTR &opstr) const
{
switch (opstr.op)
{
case OpCode_CharStrings:
case OpCode_FDArray:
case OpCode_FDSelect:
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
default:
return opstr.str.length;
}
}
};
struct cff_font_dict_op_serializer_t : op_serializer_t
{
bool serialize (hb_serialize_context_t *c,
const op_str_t &opstr,
const table_info_t &privateDictInfo) const
const table_info_t &private_dict_info) const
{
TRACE_SERIALIZE (this);
if (opstr.op == OpCode_Private)
{
/* serialize the private dict size & offset as 2-byte & 4-byte integers */
return_trace (UnsizedByteStr::serialize_int2 (c, privateDictInfo.size) &&
Dict::serialize_link4_op (c, opstr.op, privateDictInfo.link, whence_t::Absolute));
return_trace (UnsizedByteStr::serialize_int2 (c, private_dict_info.size) &&
Dict::serialize_link4_op (c, opstr.op, private_dict_info.link, whence_t::Absolute));
}
else
{
@ -210,14 +190,6 @@ struct cff_font_dict_op_serializer_t : op_serializer_t
}
return_trace (true);
}
unsigned int calculate_serialized_size (const op_str_t &opstr) const
{
if (opstr.op == OpCode_Private)
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private);
else
return opstr.str.length;
}
};
struct cff_private_dict_op_serializer_t : op_serializer_t
@ -244,22 +216,6 @@ struct cff_private_dict_op_serializer_t : op_serializer_t
return_trace (copy_opstr (c, opstr));
}
unsigned int calculate_serialized_size (const op_str_t &opstr,
bool has_localsubr=true) const
{
if (drop_hints && dict_opset_t::is_hint_op (opstr.op))
return 0;
if (opstr.op == OpCode_Subrs)
{
if (desubroutinize || !has_localsubr)
return 0;
else
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op);
}
else
return opstr.str.length;
}
protected:
const bool desubroutinize;
const bool drop_hints;

View File

@ -71,12 +71,12 @@ struct cff1_sub_table_info_t : cff_sub_table_info_t
encoding_link (0),
charset_link (0)
{
privateDictInfo.init ();
private_dict_info.init ();
}
objidx_t encoding_link;
objidx_t charset_link;
table_info_t privateDictInfo;
table_info_t private_dict_info;
};
/* a copy of a parsed out cff1_top_dict_values_t augmented with additional operators */
@ -147,8 +147,8 @@ struct cff1_top_dict_op_serializer_t : cff_top_dict_op_serializer_t<cff1_top_dic
goto fall_back;
case OpCode_Private:
return_trace (UnsizedByteStr::serialize_int2 (c, mod.info.privateDictInfo.size) &&
Dict::serialize_link4_op (c, op, mod.info.privateDictInfo.link, whence_t::Absolute));
return_trace (UnsizedByteStr::serialize_int2 (c, mod.info.private_dict_info.size) &&
Dict::serialize_link4_op (c, op, mod.info.private_dict_info.link, whence_t::Absolute));
case OpCode_version:
case OpCode_Notice:
@ -159,7 +159,7 @@ struct cff1_top_dict_op_serializer_t : cff_top_dict_op_serializer_t<cff1_top_dic
case OpCode_PostScript:
case OpCode_BaseFontName:
case OpCode_FontName:
return_trace (FontDict::serialize_offset2_op(c, op, mod.nameSIDs[name_dict_values_t::name_op_to_index (op)]));
return_trace (FontDict::serialize_int2_op (c, op, mod.nameSIDs[name_dict_values_t::name_op_to_index (op)]));
case OpCode_ROS:
{
@ -194,7 +194,7 @@ struct cff1_font_dict_op_serializer_t : cff_font_dict_op_serializer_t
if (opstr.op == OpCode_FontName)
return_trace (FontDict::serialize_int2_op (c, opstr.op, mod.fontName));
else
return_trace (SUPER::serialize (c, opstr, mod.privateDictInfo));
return_trace (SUPER::serialize (c, opstr, mod.private_dict_info));
}
private:
@ -734,8 +734,8 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
if (likely (pd->serialize (c, acc.privateDicts[i], privSzr, subrs_link)))
{
unsigned fd = plan.fdmap[i];
plan.fontdicts_mod[fd].privateDictInfo.size = c->length ();
plan.fontdicts_mod[fd].privateDictInfo.link = c->pop_pack ();
plan.fontdicts_mod[fd].private_dict_info.size = c->length ();
plan.fontdicts_mod[fd].private_dict_info.link = c->pop_pack ();
}
else
{
@ -746,7 +746,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
}
if (!acc.is_CID ())
plan.info.privateDictInfo = plan.fontdicts_mod[0].privateDictInfo;
plan.info.private_dict_info = plan.fontdicts_mod[0].private_dict_info;
/* CharStrings */
{