From e8f010d7938b9f8c6065ca455c6b24968fcfd898 Mon Sep 17 00:00:00 2001 From: ariza Date: Wed, 4 Mar 2020 16:54:27 -0800 Subject: [PATCH] removed unused code & data; rename --- src/hb-cff-interp-dict-common.hh | 13 ------- src/hb-ot-cff-common.hh | 62 +----------------------------- src/hb-ot-cff1-table.hh | 65 ++++++-------------------------- src/hb-ot-cff2-table.hh | 44 +++------------------ src/hb-subset-cff-common.hh | 52 ++----------------------- src/hb-subset-cff1.cc | 18 ++++----- 6 files changed, 31 insertions(+), 223 deletions(-) diff --git a/src/hb-cff-interp-dict-common.hh b/src/hb-cff-interp-dict-common.hh index 1f03d8239..2487fed6c 100644 --- a/src/hb-cff-interp-dict-common.hh +++ b/src/hb-cff-interp-dict-common.hh @@ -58,19 +58,6 @@ struct top_dict_values_t : dict_values_t } void fini () { dict_values_t::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; }; diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index a79ad9ff5..809a29fc8 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -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 } return_trace (true); } - - /* in parallel to above */ - template - static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, - const DATA *dataArray, - unsigned int dataArrayLen, - hb_vector_t &dataSizeArray, /* OUT */ - const PARAM ¶m) - { - /* 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::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 - 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 - 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 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 (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 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) diff --git a/src/hb-ot-cff1-table.hh b/src/hb-ot-cff1-table.hh index 9b8de95df..8cdfbdb66 100644 --- a/src/hb-ot-cff1-table.hh +++ b/src/hb-ot-cff1-table.hh @@ -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 EncodingOffset = 0; CharsetOffset = 0; FDSelectOffset = 0; - privateDictInfo.init (); + private_dict_info.init (); } void fini () { top_dict_values_t::fini (); } @@ -728,7 +698,7 @@ struct cff1_top_dict_values_t : top_dict_values_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 @@ -799,8 +769,8 @@ struct cff1_top_dict_opset_t : top_dict_opset_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 void init () { dict_values_t::init (); - privateDictInfo.init (); + private_dict_info.init (); fontName = CFF_UNDEF_SID; } void fini () { dict_values_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 } void fini () { dict_values_t::fini (); } - unsigned int calculate_serialized_size () const - { - unsigned int size = 0; - for (unsigned int i = 0; i < dict_values_t::get_count; i++) - if (dict_values_t::get_value (i).op == OpCode_Subrs) - size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); - else - size += dict_values_t::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 (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + const byte_str_t privDictStr (StructAtOffset (cff, font->private_dict_info.offset), font->private_dict_info.size); if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } dict_interpreter_t 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 (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + const byte_str_t privDictStr (StructAtOffset (cff, font->private_dict_info.offset), font->private_dict_info.size); if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } dict_interpreter_t priv_interp; priv_interp.env.init (privDictStr); diff --git a/src/hb-ot-cff2-table.hh b/src/hb-ot-cff2-table.hh index 7d12aa3da..7ad631589 100644 --- a/src/hb-ot-cff2-table.hh +++ b/src/hb-ot-cff2-table.hh @@ -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 void init () { dict_values_t::init (); - privateDictInfo.init (); + private_dict_info.init (); } void fini () { dict_values_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 } void fini () { dict_values_t::fini (); } - unsigned int calculate_serialized_size () const - { - unsigned int size = 0; - for (unsigned int i = 0; i < dict_values_t::get_count; i++) - if (dict_values_t::get_value (i).op == OpCode_Subrs) - size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); - else - size += dict_values_t::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 (cff2, font->privateDictInfo.offset), font->privateDictInfo.size); + const byte_str_t privDictStr (StructAtOffsetOrNull (cff2, font->private_dict_info.offset), font->private_dict_info.size); if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } dict_interpreter_t priv_interp; priv_interp.env.init(privDictStr); diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 44e352728..ad2a3d68f 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -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 @@ -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; diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index 8cfb20216..4c78ad08d 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -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_tserialize (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 */ {