diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 63c1e5cfa..be3161a54 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -395,29 +395,6 @@ hb_buffer_t::set_masks (hb_mask_t value, info[i].mask = (info[i].mask & not_mask) | value; } -void -hb_buffer_t::reverse_clusters () -{ - unsigned int i, start, count, last_cluster; - - if (unlikely (!len)) - return; - - reverse (); - - count = len; - start = 0; - last_cluster = info[0].cluster; - for (i = 1; i < count; i++) { - if (last_cluster != info[i].cluster) { - reverse_range (start, i); - start = i; - last_cluster = info[i].cluster; - } - } - reverse_range (start, i); -} - void hb_buffer_t::merge_clusters_impl (unsigned int start, unsigned int end) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 61c40ec31..06b923f22 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -209,7 +209,31 @@ struct hb_buffer_t } void reverse () { reverse_range (0, len); } - HB_INTERNAL void reverse_clusters (); + template + void reverse_groups (const FuncType& group) + { + if (unlikely (!len)) + return; + + reverse (); + + unsigned count = len; + unsigned start = 0; + unsigned i; + for (i = 1; i < count; i++) + { + if (!group (info[i - 1], info[i])) + { + reverse_range (start, i); + start = i; + } + } + reverse_range (start, i); + } + + void reverse_clusters () + { reverse_groups ([] (const hb_glyph_info_t& a, const hb_glyph_info_t& b) -> bool { return a.cluster == b.cluster; }); } + HB_INTERNAL void guess_segment_properties (); HB_INTERNAL void swap_buffers ();