From dc6d67df1395faf38d7587b1dd3c6661ee7cd6f0 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 16 Feb 2018 15:20:14 -0700 Subject: [PATCH] [subset] Use gids_to_retain_sorted to produce old gid -> new gid mapping since it now has the more complete set. --- src/hb-subset-plan.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 58b9f1ebb..fca65c5a2 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -63,10 +63,11 @@ hb_subset_plan_new_gid_for_old_id (hb_subset_plan_t *plan, hb_codepoint_t *new_gid) { // the index in old_gids is the new gid; only up to codepoints.len are valid - for (unsigned int i = 0; i < plan->gids_to_retain.len; i++) { - if (plan->gids_to_retain[i] == old_gid) { - // +1: assign new gids from 1..N; 0 is special - *new_gid = i + 1; + for (unsigned int i = 0; i < plan->gids_to_retain_sorted.len; i++) + { + if (plan->gids_to_retain_sorted[i] == old_gid) + { + *new_gid = i; return true; } } @@ -158,6 +159,7 @@ _populate_gids_to_retain (hb_face_t *face, } // Transfer to a sorted list. + old_gids_sorted.alloc (hb_set_get_population (all_gids_to_retain)); unsigned int gid = HB_SET_VALUE_INVALID; while (hb_set_next (all_gids_to_retain, &gid)) {