diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc index 73a292d0655..bf76a3edec4 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc @@ -225,6 +225,9 @@ struct cff2_cs_opset_subr_subset_t : cff2_cs_opset_t<cff2_cs_opset_subr_subset_t 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> { + cff2_subr_subsetter_t (const OT::cff2::accelerator_subset_t &acc, const hb_subset_plan_t *plan) + : subr_subsetter_t (acc, plan) {} + 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 */ @@ -287,7 +290,7 @@ struct cff2_subset_plan { { /* Flatten global & local subrs */ 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); + flattener(acc, plan); if (!flattener.flatten (subset_charstrings)) return false; @@ -296,12 +299,14 @@ struct cff2_subset_plan { } else { + cff2_subr_subsetter_t subr_subsetter (acc, plan); + /* Subset subrs: collect used subroutines, leaving all unused ones behind */ - if (!subr_subsetter.subset (acc, plan->glyphs, plan->drop_hints)) + if (!subr_subsetter.subset ()) return false; /* encode charstrings, global subrs, local subrs with new subroutine numbers */ - if (!subr_subsetter.encode_charstrings (acc, plan->glyphs, subset_charstrings)) + if (!subr_subsetter.encode_charstrings (subset_charstrings)) return false; if (!subr_subsetter.encode_globalsubrs (subset_globalsubrs)) @@ -352,7 +357,7 @@ struct cff2_subset_plan { if (acc.fdSelect != &Null(CFF2FDSelect)) { offsets.FDSelectInfo.offset = final_size; - if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, + if (unlikely (!hb_plan_subset_cff_fdselect (plan, orig_fdcount, *(const FDSelect *)acc.fdSelect, subset_fdcount, @@ -385,7 +390,7 @@ struct cff2_subset_plan { offsets.charStringsInfo.offset = final_size; unsigned int dataSize = subset_charstrings.total_size (); offsets.charStringsInfo.offSize = calcOffSize (dataSize); - final_size += CFF2CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.length, dataSize); + final_size += CFF2CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->num_output_glyphs (), dataSize); } /* private dicts & local subrs */ @@ -431,12 +436,11 @@ struct cff2_subset_plan { bool drop_hints; bool desubroutinize; - cff2_subr_subsetter_t subr_subsetter; }; static inline bool _write_cff2 (const cff2_subset_plan &plan, const OT::cff2::accelerator_subset_t &acc, - const hb_vector_t<hb_codepoint_t>& glyphs, + unsigned int num_glyphs, unsigned int dest_sz, void *dest) { @@ -493,7 +497,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, { assert (plan.offsets.FDSelectInfo.offset == (unsigned) (c.head - c.start)); - if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.length, *(const FDSelect *)acc.fdSelect, acc.fdArray->count, + if (unlikely (!hb_serialize_cff_fdselect (&c, num_glyphs, *(const FDSelect *)acc.fdSelect, acc.fdArray->count, plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, plan.subset_fdselect_ranges))) { @@ -584,7 +588,7 @@ _hb_subset_cff2 (const OT::cff2::accelerator_subset_t &acc, unsigned int cff2_prime_size = cff2_plan.get_final_size (); char *cff2_prime_data = (char *) calloc (1, cff2_prime_size); - if (unlikely (!_write_cff2 (cff2_plan, acc, plan->glyphs, + if (unlikely (!_write_cff2 (cff2_plan, acc, plan->num_output_glyphs (), cff2_prime_size, cff2_prime_data))) { DEBUG_MSG(SUBSET, nullptr, "Failed to write a subset cff2."); free (cff2_prime_data); @@ -592,10 +596,10 @@ _hb_subset_cff2 (const OT::cff2::accelerator_subset_t &acc, } *prime = hb_blob_create (cff2_prime_data, - cff2_prime_size, - HB_MEMORY_MODE_READONLY, - cff2_prime_data, - free); + cff2_prime_size, + HB_MEMORY_MODE_READONLY, + cff2_prime_data, + free); return true; } |