[subset] Reuse num_glyphs in various places

pull/4264/head
Behdad Esfahbod 1 year ago
parent 7e4311a868
commit b5792f117a
  1. 3
      src/OT/Color/CBDT/CBDT.hh
  2. 3
      src/hb-ot-var-hvar-table.hh
  3. 6
      src/hb-subset-cff-common.hh
  4. 5
      src/hb-subset-cff1.cc

@ -545,7 +545,8 @@ struct IndexSubtableArray
const IndexSubtableRecord*>> *lookup /* OUT */) const const IndexSubtableRecord*>> *lookup /* OUT */) const
{ {
bool start_glyph_is_set = false; bool start_glyph_is_set = false;
for (hb_codepoint_t new_gid = 0; new_gid < c->plan->num_output_glyphs (); new_gid++) unsigned num_glyphs = c->plan->num_output_glyphs ();
for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++)
{ {
hb_codepoint_t old_gid; hb_codepoint_t old_gid;
if (unlikely (!c->plan->old_gid_for_new_gid (new_gid, &old_gid))) continue; if (unlikely (!c->plan->old_gid_for_new_gid (new_gid, &old_gid))) continue;

@ -201,7 +201,8 @@ struct hvarvvar_subset_plan_t
if (retain_adv_map) if (retain_adv_map)
{ {
for (hb_codepoint_t gid = 0; gid < plan->num_output_glyphs (); gid++) unsigned num_glyphs = plan->num_output_glyphs ();
for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++)
{ {
if (inner_sets[0]->has (gid)) if (inner_sets[0]->has (gid))
inner_maps[0].add (gid); inner_maps[0].add (gid);

@ -709,7 +709,8 @@ struct subr_subsetter_t
} }
/* phase 1 & 2 */ /* phase 1 & 2 */
for (unsigned int i = 0; i < plan->num_output_glyphs (); i++) unsigned num_glyphs = plan->num_output_glyphs ();
for (unsigned int i = 0; i < num_glyphs; i++)
{ {
hb_codepoint_t glyph; hb_codepoint_t glyph;
if (!plan->old_gid_for_new_gid (i, &glyph)) if (!plan->old_gid_for_new_gid (i, &glyph))
@ -987,7 +988,8 @@ struct subr_subsetter_t
const hb_vector_t<parsed_cs_str_vec_t>& local_subrs) const hb_vector_t<parsed_cs_str_vec_t>& local_subrs)
{ {
closures.reset (); closures.reset ();
for (unsigned int i = 0; i < plan->num_output_glyphs (); i++) unsigned num_glyphs = plan->num_output_glyphs ();
for (unsigned int i = 0; i < num_glyphs; i++)
{ {
hb_codepoint_t glyph; hb_codepoint_t glyph;
if (!plan->old_gid_for_new_gid (i, &glyph)) if (!plan->old_gid_for_new_gid (i, &glyph))

@ -415,7 +415,8 @@ struct cff_subset_plan {
subset_enc_num_codes = plan->num_output_glyphs () - 1; subset_enc_num_codes = plan->num_output_glyphs () - 1;
unsigned int glyph; unsigned int glyph;
for (glyph = 1; glyph < plan->num_output_glyphs (); glyph++) unsigned num_glyphs = plan->num_output_glyphs ();
for (glyph = 1; glyph < num_glyphs; glyph++)
{ {
hb_codepoint_t old_glyph; hb_codepoint_t old_glyph;
if (!plan->old_gid_for_new_gid (glyph, &old_glyph)) if (!plan->old_gid_for_new_gid (glyph, &old_glyph))
@ -574,7 +575,7 @@ struct cff_subset_plan {
/* check whether the subset renumbers any glyph IDs */ /* check whether the subset renumbers any glyph IDs */
gid_renum = false; gid_renum = false;
for (hb_codepoint_t new_glyph = 0; new_glyph < plan->num_output_glyphs (); new_glyph++) for (hb_codepoint_t new_glyph = 0; new_glyph < num_glyphs; new_glyph++)
{ {
if (!plan->old_gid_for_new_gid(new_glyph, &old_glyph)) if (!plan->old_gid_for_new_gid(new_glyph, &old_glyph))
continue; continue;

Loading…
Cancel
Save