diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 794bdd077..dcb6c068a 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2333,6 +2333,11 @@ struct delta_row_encoding_t * needed for this region */ struct chars_t : hb_vector_t { + int cmp (const chars_t& other) const + { + return as_array ().cmp (other.as_array ()); + } + hb_pair_t get_width () { unsigned width = 0; @@ -2486,6 +2491,17 @@ struct delta_row_encoding_t bool add_row (const hb_vector_t* row) { return items.push (row); } + + static int cmp (const void *pa, const void *pb) + { + const delta_row_encoding_t *a = (const delta_row_encoding_t *)pa; + const delta_row_encoding_t *b = (const delta_row_encoding_t *)pb; + + if (a->width != b->width) + return (int) a->width - (int) b->width; + + return b->chars.cmp (a->chars); + } }; struct VarRegionAxis diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index aed317bee..bd9c8941d 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -1877,6 +1877,8 @@ struct item_variations_t * is a compromise between optimization and performance and practically * works very well. */ + // This produces slightly smaller results in some cases. + encoding_objs.qsort (); /* main algorithm: repeatedly pick 2 best encodings to combine, and combine them */ using item_t = hb_priority_queue_t::item_t;