From 3c7792ca326abfb989285f794d6ee71ad9f6bf89 Mon Sep 17 00:00:00 2001 From: David Corbett Date: Sat, 20 Oct 2018 15:02:26 -0400 Subject: [PATCH] [use] Fix reordering Fixes #1235. --- src/hb-ot-shape-complex-use.cc | 48 ++++++++++++------ src/hb.hh | 2 + ...fb0e8b9a86bb9bd73a1247de4e33fbe3c1fd93.ttf | Bin 0 -> 1824 bytes test/shaping/data/in-house/tests/use.tests | 3 ++ 4 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 test/shaping/data/in-house/fonts/4afb0e8b9a86bb9bd73a1247de4e33fbe3c1fd93.ttf diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index af25b07f8..4daa27875 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -432,7 +432,8 @@ record_pref (const hb_ot_shape_plan_t *plan HB_UNUSED, static inline bool is_halant (const hb_glyph_info_t &info) { - return info.use_category() == USE_H && !_hb_glyph_info_ligated (&info); + return (info.use_category() == USE_H || info.use_category() == USE_HVM) && + !_hb_glyph_info_ligated (&info); } static void @@ -449,19 +450,38 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int start, unsigned int end) hb_glyph_info_t *info = buffer->info; -#define BASE_FLAGS (FLAG (USE_B) | FLAG (USE_GB)) +#define POST_BASE_FLAGS (FLAG64 (USE_FM) | \ + FLAG64 (USE_FAbv) | \ + FLAG64 (USE_FBlw) | \ + FLAG64 (USE_FPst) | \ + FLAG64 (USE_MAbv) | \ + FLAG64 (USE_MBlw) | \ + FLAG64 (USE_MPst) | \ + FLAG64 (USE_MPre) | \ + FLAG64 (USE_VAbv) | \ + FLAG64 (USE_VBlw) | \ + FLAG64 (USE_VPst) | \ + FLAG64 (USE_VPre) | \ + FLAG64 (USE_VMAbv) | \ + FLAG64 (USE_VMBlw) | \ + FLAG64 (USE_VMPst) | \ + FLAG64 (USE_VMPre)) /* Move things forward. */ if (info[start].use_category() == USE_R && end - start > 1) { - /* Got a repha. Reorder it to after first base, before first halant. */ + /* Got a repha. Reorder it towards the end, but before the first post-base + * glyph. */ for (unsigned int i = start + 1; i < end; i++) - if ((FLAG_UNSAFE (info[i].use_category()) & (BASE_FLAGS)) || is_halant (info[i])) + { + bool is_post_base_glyph = (FLAG64_UNSAFE (info[i].use_category()) & POST_BASE_FLAGS) || + is_halant (info[i]); + if (is_post_base_glyph || i == end - 1) { - /* If we hit a halant, move before it; otherwise it's a base: move to it's - * place, and shift things in between backward. */ + /* If we hit a post-base glyph, move before it; otherwise move to the + * end. Shift things in between backward. */ - if (is_halant (info[i])) + if (is_post_base_glyph) i--; buffer->merge_clusters (start, i + 1); @@ -471,21 +491,19 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int start, unsigned int end) break; } + } } /* Move things back. */ - unsigned int j = end; + unsigned int j = start; for (unsigned int i = start; i < end; i++) { uint32_t flag = FLAG_UNSAFE (info[i].use_category()); - if ((flag & (BASE_FLAGS)) || is_halant (info[i])) + if (is_halant (info[i])) { - /* If we hit a halant, move after it; otherwise it's a base: move to it's - * place, and shift things in between backward. */ - if (is_halant (info[i])) - j = i + 1; - else - j = i; + /* If we hit a halant, move after it; otherwise move to the beginning, and + * shift things in between forward. */ + j = i + 1; } else if (((flag) & (FLAG (USE_VPre) | FLAG (USE_VMPre))) && /* Only move the first component of a MultipleSubst. */ diff --git a/src/hb.hh b/src/hb.hh index 16ccf87ce..ba857edac 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -446,6 +446,8 @@ typedef uint64_t hb_vector_size_impl_t; #define FLAG(x) (ASSERT_STATIC_EXPR_ZERO ((unsigned int)(x) < 32) + (1U << (unsigned int)(x))) #define FLAG_UNSAFE(x) ((unsigned int)(x) < 32 ? (1U << (unsigned int)(x)) : 0) #define FLAG_RANGE(x,y) (ASSERT_STATIC_EXPR_ZERO ((x) < (y)) + FLAG(y+1) - FLAG(x)) +#define FLAG64(x) (ASSERT_STATIC_EXPR_ZERO ((unsigned long long)(x) < 64) + (1ULL << (unsigned long long)(x))) +#define FLAG64_UNSAFE(x) ((unsigned long long)(x) < 64 ? (1ULL << (unsigned long long)(x)) : 0) /* Size signifying variable-sized array */ diff --git a/test/shaping/data/in-house/fonts/4afb0e8b9a86bb9bd73a1247de4e33fbe3c1fd93.ttf b/test/shaping/data/in-house/fonts/4afb0e8b9a86bb9bd73a1247de4e33fbe3c1fd93.ttf new file mode 100644 index 0000000000000000000000000000000000000000..274fc0817ccdfb0d72dd58d382af15f7f63d46f3 GIT binary patch literal 1824 zcmeHI&udgy6#mY8ZzezAWU2a8YUmp|t-%i_p?V5tJ-Nx+u5_2rhJ?3qcnWQx{4dzjNOUShU-&ypMCg^PPL{ zdFR}B?hFJ#46Cp)HIf_7V=q1dqJy-0BV#AW@iE%TC&=R?lpeQZH|d>_u2DFRqnpJ{XM!E zc+I*-y8RxozAk>{|9%+L?3kn{hpfGmo4}DR+9UM*(fW%{mjje1$cT0#BAm@wRTd5^ zW3$5rth$|zhMj3-FlpZO@9Gm~gBHX7L^q|CQYOLv!=XID8=)(6M4t0w)9tm|D zS&W6c^OjG9$$T5yqsD#|3+$H_)NmeiD4~u7dNG6j#59sfv8xiu!N&!96sYTt8oR7W z-#U)t6ty`l@#KBl^IV;$U9m=ckvl%891k(gczukTyu!m zJW(BuuaO~$A#YFo1r#9X_97XkydGwc5x*p9ZgH~=aacqe}LJ65OX08E2fSn zlL4kb3vn>OOg6;+=u#?`Ol1tDa|W^lt{T(1a|$8L4j7iwWI2RgW|^#m{?U4rw^Lkx zv0$y0JQi#)zO6i^FJMpC{1SGRi`5x)RmznNZ=|`rCZ?XnHq$<^r^^>-v8z@s&0>$4 y6Z(Fx=&a|aVzc8s427KCr`^a|V`((ej^zJDfDUuCOs>L?eBZiOz`o_f`rZHmoHow@ literal 0 HcmV?d00001 diff --git a/test/shaping/data/in-house/tests/use.tests b/test/shaping/data/in-house/tests/use.tests index 18d1991e2..dd2a3a27f 100644 --- a/test/shaping/data/in-house/tests/use.tests +++ b/test/shaping/data/in-house/tests/use.tests @@ -9,3 +9,6 @@ ../fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf::U+11124,U+11131,U+11134:[u11124=0+514|u11131=0+0|uni25CC=0+547|u11134=0+0] ../fonts/573d3a3177c9a8646e94c8a0d7b224334340946a.ttf:--font-funcs=ft:U+11410,U+11442,U+11411,U+11440,U+11443,U+11410,U+11442,U+11411,U+11441,U+11443:[E_dv.alt=0+275|Ga.icd=0+367|Gha.diag=0@100,0+386|AA_dv.alt=0+208|Candrabindu=0@17,-8+0|E_dv.alt=5+275|Ga.icd=5+367|Gha.diag=5@100,0+386|AU_dv_part.alt=5+213|Candrabindu.sm=5@-52,179+0] ../fonts/dcf774ca21062e7439f98658b18974ea8b956d0c.ttf::U+11328,U+1134D,U+1CF4:[gid1=0+793|gid2=0+0|gid3=0+0] +../fonts/4afb0e8b9a86bb9bd73a1247de4e33fbe3c1fd93.ttf::U+1C00,U+1C27,U+1C28,U+1C34,U+1C35:[uni1C35=0+500|uni1C34=0+500|uni1C28=0+500|uni1C27=0+500|uni1C00=0+500] +../fonts/4afb0e8b9a86bb9bd73a1247de4e33fbe3c1fd93.ttf::U+0D4E,U+0D15,U+0D4D,U+0D15,U+0D46:[uni0D15=0+500|uni0D4E=0+500|uni0D4D=0+500|uni0D46=3+500|uni0D15=3+500] +../fonts/4afb0e8b9a86bb9bd73a1247de4e33fbe3c1fd93.ttf::U+1102D,U+11046,U+11013,U+11046,U+11013,U+11046:[u11013=0+500|u11046_u11013=0+500|u1102D_u11046=0+500|u11046=0+500]