[ot] Don't rely on cluster numbers for ensure_native_direction()

This commit is contained in:
Behdad Esfahbod 2015-07-22 15:49:08 +01:00
parent 701112dad9
commit a60e2cfa39
1 changed files with 18 additions and 1 deletions

View File

@ -264,6 +264,7 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font)
static void static void
hb_form_clusters (hb_buffer_t *buffer) hb_form_clusters (hb_buffer_t *buffer)
{ {
/* Loop duplicated in hb_ensure_native_direction(). */
unsigned int base = 0; unsigned int base = 0;
unsigned int count = buffer->len; unsigned int count = buffer->len;
hb_glyph_info_t *info = buffer->info; 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)) || 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_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); buffer->props.direction = HB_DIRECTION_REVERSE (buffer->props.direction);
} }
} }