Another try to fix Mongolian free variation selectors
This reverts bf029281 and fixes it properly. That commit
was not enough as it was only inheriting the shaping_action
for prev_action, but not curr_action.
Micro-test added.
https://code.google.com/p/chromium/issues/detail?id=393896
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index b7aa694..5dd60a5 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -225,8 +225,6 @@
unsigned int count = buffer->len;
unsigned int prev = (unsigned int) -1, state = 0;
- HB_BUFFER_ALLOCATE_VAR (buffer, arabic_shaping_action);
-
/* Check pre-context */
if (!(buffer->flags & HB_BUFFER_FLAG_BOT))
for (unsigned int i = 0; i < buffer->context_len[0]; i++)
@@ -253,8 +251,7 @@
const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
if (entry->prev_action != NONE && prev != (unsigned int) -1)
- for (; prev < i; prev++)
- buffer->info[prev].arabic_shaping_action() = entry->prev_action;
+ buffer->info[prev].arabic_shaping_action() = entry->prev_action;
buffer->info[i].arabic_shaping_action() = entry->curr_action;
@@ -275,9 +272,17 @@
buffer->info[prev].arabic_shaping_action() = entry->prev_action;
break;
}
+}
-
- HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
+static void
+mongolian_variation_selectors (hb_buffer_t *buffer)
+{
+ /* Copy arabic_shaping_action() from base to Mongolian variation selectors. */
+ unsigned int count = buffer->len;
+ hb_glyph_info_t *info = buffer->info;
+ for (unsigned int i = 1; i < count; i++)
+ if (unlikely (hb_in_range (info[i].codepoint, 0x180Bu, 0x180Du)))
+ info[i].arabic_shaping_action() = info[i - 1].arabic_shaping_action();
}
static void
@@ -285,12 +290,19 @@
hb_buffer_t *buffer,
hb_font_t *font HB_UNUSED)
{
+ HB_BUFFER_ALLOCATE_VAR (buffer, arabic_shaping_action);
+
const arabic_shape_plan_t *arabic_plan = (const arabic_shape_plan_t *) plan->data;
arabic_joining (buffer);
+ if (plan->props.script == HB_SCRIPT_MONGOLIAN)
+ mongolian_variation_selectors (buffer);
+
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
buffer->info[i].mask |= arabic_plan->mask_array[buffer->info[i].arabic_shaping_action()];
+
+ HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
}
diff --git a/src/hb-unicode-private.hh b/src/hb-unicode-private.hh
index 6652015..a2c59da 100644
--- a/src/hb-unicode-private.hh
+++ b/src/hb-unicode-private.hh
@@ -122,8 +122,9 @@
static inline hb_bool_t
is_variation_selector (hb_codepoint_t unicode)
{
+ /* U+180B..180D MONGOLIAN FREE VARIATION SELECTORs are handled in the
+ * Arabic shaper. No need to match them here. */
return unlikely (hb_in_ranges (unicode,
- 0x180Bu, 0x180Du, /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
0xFE00u, 0xFE0Fu, /* VARIATION SELECTOR-1..16 */
0xE0100u, 0xE01EFu)); /* VARIATION SELECTOR-17..256 */
}
diff --git a/test/shaping/fonts/sha1sum/MANIFEST b/test/shaping/fonts/sha1sum/MANIFEST
index 427f433..d1ff350 100644
--- a/test/shaping/fonts/sha1sum/MANIFEST
+++ b/test/shaping/fonts/sha1sum/MANIFEST
@@ -3,4 +3,5 @@
4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf
d629e7fedc0b350222d7987345fe61613fa3929a.ttf
e207635780b42f898d58654b65098763e340f5c7.ttf
+ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf
f499fbc23865022234775c43503bba2e63978fe1.ttf
diff --git a/test/shaping/fonts/sha1sum/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf b/test/shaping/fonts/sha1sum/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf
new file mode 100644
index 0000000..629c470
--- /dev/null
+++ b/test/shaping/fonts/sha1sum/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf
Binary files differ
diff --git a/test/shaping/tests/mongolian-variation-selector.tests b/test/shaping/tests/mongolian-variation-selector.tests
index 043fa18..86a2fd1 100644
--- a/test/shaping/tests/mongolian-variation-selector.tests
+++ b/test/shaping/tests/mongolian-variation-selector.tests
@@ -1 +1,2 @@
fonts/sha1sum/37033cc5cf37bb223d7355153016b6ccece93b28.ttf:U+1826,U+180B,U+1826:[uni1826.E85E_ue.init1=0+599|uni1826.E856_ue.fina=2+750]
+fonts/sha1sum/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf:U+1820,U+180B:[uni1820.E821_a.isol1=0+1199]