From 164c13d73f67fdddba28e6409d76b4903e8ffab3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 17 Jul 2014 14:16:38 -0400 Subject: [PATCH] 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 --- src/hb-ot-shape-complex-arabic.cc | 24 +++++++++++++----- src/hb-unicode-private.hh | 3 ++- test/shaping/fonts/sha1sum/MANIFEST | 1 + ...86fe710cfea877bbe0dbb6946a1f88d0661031.ttf | Bin 0 -> 2748 bytes .../tests/mongolian-variation-selector.tests | 1 + 5 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 test/shaping/fonts/sha1sum/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index b7aa694cb..5dd60a5c6 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -225,8 +225,6 @@ arabic_joining (hb_buffer_t *buffer) 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 @@ arabic_joining (hb_buffer_t *buffer) 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 @@ arabic_joining (hb_buffer_t *buffer) 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 @@ setup_masks_arabic (const hb_ot_shape_plan_t *plan, 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 66520151b..a2c59da27 100644 --- a/src/hb-unicode-private.hh +++ b/src/hb-unicode-private.hh @@ -122,8 +122,9 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE 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 427f43383..d1ff35067 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 0000000000000000000000000000000000000000..629c470c2c49a50ef01a8f6f47812fb0ef16b596 GIT binary patch literal 2748 zcma)8Z%k8H6hHUA*VliKmOm}61xm|9szX}nqkw>*DAOr26a|+sv5G(y3JM}>B5L^H zqFLsm(Xd2~Tef6z{>e7n+~V8^vVCwM@dGn_nI>Xp%sy;L;-9uVw=K{)H@xY6=bm$a z=iKw}-B%z0Ai^QwVCl-*jTJ}IPGkV64*`(kw`*PQ-ZcF^044IUWm~(q)4bALi~MiM zm$rDjI)Miz;=7R-TiW(De|YuWeO%uHP&{tk?rl2BLMVZ9sDw4J4(h=RJ7G6` z1dt?oWKVP^AWibfMuL-zQpU6OG@agKvT2MIUZI|Blsr-rd&#K|dyWH|(-m6)uY$x4g{DZ`QFk&{jC!YqfAuwRy^pfK4qP!b*2hUvwzv9afu z$13mMy<0UtK2C+w$as3?6JJS*kDnSW-M_zdaDSlV5?xgj>%Qg{aZ+_8R%yU5j0(__u!WLLyapedUHx<8cF9>nk2p2l2hR%=Xdvn>p~R#74+Tt8onFtIu0vG=14#N zIrxl5tj+|sRz#2M zM?DkX3Q-Rw55Bk2^&d0NpmK~UdUodUiCLS>9-QFnl;wE;uwIRH9NrB7*_K@0Ok-vC zzPj}kU9mkgF-Lua6A=U+E_v;2F6@;A~j? z%y67@ypwZuXwh7S4(C;bCwS-g;GMv-JUd8~e+-i_Nw$)kRG=AjH9bym&?$s5G)`kv zb!DTz^a;3BVclDCr`awHU%z7xZ3~37kFaX^aRD0M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