[subset/loca] Shuffle code around

pull/4264/head
Behdad Esfahbod 1 year ago
parent f014112d16
commit 3cb2b49e61
  1. 15
      src/OT/glyf/glyf-helpers.hh
  2. 21
      src/OT/glyf/glyf.hh

@ -81,14 +81,13 @@ _add_head_and_set_loca_version (hb_subset_plan_t *plan, bool use_short_loca)
template<typename Iterator,
hb_requires (hb_is_source_of (Iterator, unsigned int))>
static bool
_add_loca_and_head (hb_subset_plan_t * plan,
_add_loca_and_head (hb_subset_context_t *c,
Iterator padded_offsets,
const hb_sorted_vector_t<hb_codepoint_pair_t> new_to_old_gid_list,
unsigned num_glyphs,
bool use_short_loca)
{
unsigned num_offsets = num_glyphs + 1;
unsigned num_offsets = c->plan->num_output_glyphs () + 1;
unsigned entry_size = use_short_loca ? 2 : 4;
char *loca_prime_data = (char *) hb_malloc (entry_size * num_offsets);
if (unlikely (!loca_prime_data)) return false;
@ -97,9 +96,9 @@ _add_loca_and_head (hb_subset_plan_t * plan,
entry_size, num_offsets, entry_size * num_offsets);
if (use_short_loca)
_write_loca (padded_offsets, new_to_old_gid_list, true, (HBUINT16 *) loca_prime_data, num_offsets);
_write_loca (padded_offsets, c->plan->new_to_old_gid_list, true, (HBUINT16 *) loca_prime_data, num_offsets);
else
_write_loca (padded_offsets, new_to_old_gid_list, false, (HBUINT32 *) loca_prime_data, num_offsets);
_write_loca (padded_offsets, c->plan->new_to_old_gid_list, false, (HBUINT32 *) loca_prime_data, num_offsets);
hb_blob_t *loca_blob = hb_blob_create (loca_prime_data,
entry_size * num_offsets,
@ -107,8 +106,8 @@ _add_loca_and_head (hb_subset_plan_t * plan,
loca_prime_data,
hb_free);
bool result = plan->add_table (HB_OT_TAG_loca, loca_blob)
&& _add_head_and_set_loca_version (plan, use_short_loca);
bool result = c->plan->add_table (HB_OT_TAG_loca, loca_blob)
&& _add_head_and_set_loca_version (c->plan, use_short_loca);
hb_blob_destroy (loca_blob);
return result;

@ -85,9 +85,6 @@ struct glyf
return_trace (false);
}
glyf *glyf_prime = c->serializer->start_embed <glyf> ();
if (unlikely (!c->serializer->check_success (glyf_prime))) return_trace (false);
hb_font_t *font = nullptr;
if (c->plan->normalized_coords)
{
@ -130,19 +127,19 @@ struct glyf
padded_offsets.push (g.length ());
}
if (unlikely (!c->serializer->check_success (glyf_impl::_add_loca_and_head (c,
padded_offsets.iter (),
use_short_loca))))
return false;
glyf *glyf_prime = c->serializer->start_embed <glyf> ();
if (unlikely (!glyf_prime)) return_trace (false);
bool result = glyf_prime->serialize (c->serializer, glyphs, use_short_loca, c->plan);
if (c->plan->normalized_coords && !c->plan->pinned_at_default)
_free_compiled_subset_glyphs (glyphs);
if (!result) return false;
if (unlikely (c->serializer->in_error ())) return_trace (false);
return_trace (c->serializer->check_success (glyf_impl::_add_loca_and_head (c->plan,
padded_offsets.iter (),
c->plan->new_to_old_gid_list,
c->plan->num_output_glyphs (),
use_short_loca)));
return result;
}
bool

Loading…
Cancel
Save