diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index ab5aa7f6f..bacd56ef3 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -213,7 +213,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, /* Sort features and merge duplicates */ if (feature_infos.length) { - feature_infos.qsort (); + if (!is_simple) + feature_infos.qsort (); auto *f = feature_infos.arrayZ; unsigned int j = 0; unsigned count = feature_infos.length; @@ -314,7 +315,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, map->needs_fallback = !found; } //feature_infos.shrink (0); /* Done with these */ - + if (is_simple) + m.features.qsort (); add_gsub_pause (nullptr); add_gpos_pause (nullptr); diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index efc8cae96..8af8129ce 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -60,6 +60,13 @@ struct hb_ot_map_t int cmp (const hb_tag_t tag_) const { return tag_ < tag ? -1 : tag_ > tag ? 1 : 0; } + + HB_INTERNAL static int cmp (const void *pa, const void *pb) + { + const feature_map_t *a = (const feature_map_t *) pa; + const feature_map_t *b = (const feature_map_t *) pb; + return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; + } }; struct lookup_map_t { @@ -273,6 +280,7 @@ struct hb_ot_map_builder_t hb_face_t *face; hb_segment_properties_t props; + bool is_simple; hb_tag_t chosen_script[2]; bool found_script[2]; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 3d207e068..d84313f19 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -313,6 +313,8 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, { hb_ot_map_builder_t *map = &planner->map; + map->is_simple = true; + map->enable_feature (HB_TAG('r','v','r','n')); map->add_gsub_pause (nullptr); @@ -354,7 +356,10 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, map->enable_feature (HB_TAG ('H','A','R','F')); /* Considered discretionary. */ if (planner->shaper->collect_features) + { + map->is_simple = false; planner->shaper->collect_features (planner); + } map->enable_feature (HB_TAG ('B','u','z','z')); /* Considered required. */ map->enable_feature (HB_TAG ('B','U','Z','Z')); /* Considered discretionary. */ @@ -378,6 +383,8 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, map->enable_feature (HB_TAG ('v','e','r','t'), F_GLOBAL_SEARCH); } + if (num_user_features) + map->is_simple = false; for (unsigned int i = 0; i < num_user_features; i++) { const hb_feature_t *feature = &user_features[i];