From a60e2cfa395718cde48eb81f43adc27b4a92e117 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 22 Jul 2015 15:49:08 +0100 Subject: [PATCH] [ot] Don't rely on cluster numbers for ensure_native_direction() --- src/hb-ot-shape.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index bbd044fe4..5ead0b75c 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -264,6 +264,7 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font) static void hb_form_clusters (hb_buffer_t *buffer) { + /* Loop duplicated in hb_ensure_native_direction(). */ unsigned int base = 0; unsigned int count = buffer->len; hb_glyph_info_t *info = buffer->info; @@ -290,7 +291,23 @@ hb_ensure_native_direction (hb_buffer_t *buffer) if ((HB_DIRECTION_IS_HORIZONTAL (direction) && direction != hb_script_get_horizontal_direction (buffer->props.script)) || (HB_DIRECTION_IS_VERTICAL (direction) && direction != HB_DIRECTION_TTB)) { - hb_buffer_reverse_clusters (buffer); + /* Same loop as hb_form_clusters(). + * Since form_clusters() merged clusters already, we don't merge. */ + unsigned int base = 0; + unsigned int count = buffer->len; + hb_glyph_info_t *info = buffer->info; + for (unsigned int i = 1; i < count; i++) + { + if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i])))) + { + buffer->reverse_range (base, i); + base = i; + } + } + buffer->reverse_range (base, count); + + buffer->reverse (); + buffer->props.direction = HB_DIRECTION_REVERSE (buffer->props.direction); } }