summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2015-09-01 16:13:32 +0100
committerBehdad Esfahbod <behdad@behdad.org>2015-09-01 16:13:32 +0100
commite995d33c10a4bd9404699d01bddb2b69d811e9ed (patch)
tree722f7b1d14db85737a08131805c47f61947f0e61
parentb6d7d161a87b5dde710924e5c557d39c302f5630 (diff)
downloadharfbuzz-e995d33c10a4bd9404699d01bddb2b69d811e9ed.tar.gz
[OT] Merge clusters when reordering marks for normalization
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=541608 and cluster test.
-rw-r--r--src/hb-buffer-private.hh2
-rw-r--r--src/hb-buffer.cc21
-rw-r--r--src/hb-ot-shape-normalize.cc2
3 files changed, 24 insertions, 1 deletions
diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 9aa5e7d7..7fed7386 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -201,6 +201,8 @@ struct hb_buffer_t {
HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size);
inline void clear_context (unsigned int side) { context_len[side] = 0; }
+
+ HB_INTERNAL void sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *));
};
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 17093052..420da820 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -1678,3 +1678,24 @@ hb_buffer_normalize_glyphs (hb_buffer_t *buffer)
}
normalize_glyphs_cluster (buffer, start, end, backward);
}
+
+void
+hb_buffer_t::sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *))
+{
+ assert (!have_positions);
+ for (unsigned int i = start + 1; i < end; i++)
+ {
+ unsigned int j = i;
+ while (j > start && compar (&info[j - 1], &info[i]) > 0)
+ j--;
+ if (i == j)
+ continue;
+ /* Move item i to occupy place for item j, shift what's in between. */
+ merge_clusters (j, i + 1);
+ {
+ hb_glyph_info_t t = info[i];
+ memmove (&info[j + 1], &info[j], (i - j) * sizeof (hb_glyph_info_t));
+ info[j] = t;
+ }
+ }
+}
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index dff7a746..a7064613 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -350,7 +350,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
continue;
}
- hb_stable_sort (buffer->info + i, end - i, compare_combining_class);
+ buffer->sort (i, end, compare_combining_class);
i = end;
}