From 7ce03ebe7c525919ce22d9094480847ff1b3c2b2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 21 Jul 2015 16:55:26 +0100 Subject: [PATCH] [USE] Move pref --- src/hb-ot-shape-complex-use-machine.rl | 9 +++++---- src/hb-ot-shape-complex-use-private.hh | 9 +++++---- src/hb-ot-shape-complex-use.cc | 24 ++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-shape-complex-use-machine.rl b/src/hb-ot-shape-complex-use-machine.rl index 77068bdff..9cc9a23a9 100644 --- a/src/hb-ot-shape-complex-use-machine.rl +++ b/src/hb-ot-shape-complex-use-machine.rl @@ -55,6 +55,7 @@ FM = 8; # CONS_FINAL_MOD #CM = 10; # CONS_MOD SUB = 11; # CONS_SUB H = 12; # HALANT + HN = 13; # HALANT_NUM ZWNJ = 14; # Zero width non-joiner ZWJ = 15; # Zero width joiner @@ -64,8 +65,8 @@ R = 18; # REPHA S = 19; # SYM #SM = 20; # SYM_MOD VS = 21; # VARIATION_SELECTOR -#V = 22; # VOWEL -#VM = 23; # VOWEL_MOD +#V = 36; # VOWEL +#VM = 40; # VOWEL_MOD FAbv = 24; # CONS_FINAL_ABOVE FBlw = 25; # CONS_FINAL_BELOW @@ -79,11 +80,11 @@ CMBlw = 32; # CONS_MOD_BELOW VAbv = 33; # VOWEL_ABOVE / VOWEL_ABOVE_BELOW / VOWEL_ABOVE_BELOW_POST / VOWEL_ABOVE_POST VBlw = 34; # VOWEL_BELOW / VOWEL_BELOW_POST VPst = 35; # VOWEL_POST UIPC = Right -VPre = 36; # VOWEL_PRE / VOWEL_PRE_ABOVE / VOWEL_PRE_ABOVE_POST / VOWEL_PRE_POST +VPre = 22; # VOWEL_PRE / VOWEL_PRE_ABOVE / VOWEL_PRE_ABOVE_POST / VOWEL_PRE_POST VMAbv = 37; # VOWEL_MOD_ABOVE VMBlw = 38; # VOWEL_MOD_BELOW VMPst = 39; # VOWEL_MOD_POST -VMPre = 40; # VOWEL_MOD_PRE +VMPre = 23; # VOWEL_MOD_PRE SMAbv = 41; # SYM_MOD_ABOVE SMBlw = 42; # SYM_MOD_BELOW diff --git a/src/hb-ot-shape-complex-use-private.hh b/src/hb-ot-shape-complex-use-private.hh index fc0cfc50b..a14373621 100644 --- a/src/hb-ot-shape-complex-use-private.hh +++ b/src/hb-ot-shape-complex-use-private.hh @@ -57,6 +57,7 @@ enum use_category_t { // USE_CM = 10, /* CONS_MOD */ USE_SUB = 11, /* CONS_SUB */ USE_H = 12, /* HALANT */ + USE_HN = 13, /* HALANT_NUM */ USE_ZWNJ = 14, /* Zero width non-joiner */ USE_ZWJ = 15, /* Zero width joiner */ @@ -66,8 +67,8 @@ enum use_category_t { USE_S = 19, /* SYM */ // USE_SM = 20, /* SYM_MOD */ USE_VS = 21, /* VARIATION_SELECTOR */ -// USE_V = 22, /* VOWEL */ -// USE_VM = 23, /* VOWEL_MOD */ +// USE_V = 36, /* VOWEL */ +// USE_VM = 40, /* VOWEL_MOD */ USE_FAbv = 24, /* CONS_FINAL_ABOVE */ USE_FBlw = 25, /* CONS_FINAL_BELOW */ @@ -81,11 +82,11 @@ enum use_category_t { USE_VAbv = 33, /* VOWEL_ABOVE / VOWEL_ABOVE_BELOW / VOWEL_ABOVE_BELOW_POST / VOWEL_ABOVE_POST */ USE_VBlw = 34, /* VOWEL_BELOW / VOWEL_BELOW_POST */ USE_VPst = 35, /* VOWEL_POST UIPC = Right */ - USE_VPre = 36, /* VOWEL_PRE / VOWEL_PRE_ABOVE / VOWEL_PRE_ABOVE_POST / VOWEL_PRE_POST */ + USE_VPre = 22, /* VOWEL_PRE / VOWEL_PRE_ABOVE / VOWEL_PRE_ABOVE_POST / VOWEL_PRE_POST */ USE_VMAbv = 37, /* VOWEL_MOD_ABOVE */ USE_VMBlw = 38, /* VOWEL_MOD_BELOW */ USE_VMPst = 39, /* VOWEL_MOD_POST */ - USE_VMPre = 40, /* VOWEL_MOD_PRE */ + USE_VMPre = 23, /* VOWEL_MOD_PRE */ USE_SMAbv = 41, /* SYM_MOD_ABOVE */ USE_SMBlw = 42 /* SYM_MOD_BELOW */ }; diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 71d2ee15a..b2c65437b 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -347,8 +347,28 @@ reorder_syllable (const hb_ot_shape_plan_t *plan, } } - /* TODO move things back. */ - + /* Move things back. */ + unsigned int j = end; + for (unsigned int i = start; i < end; i++) + { + uint32_t flag = FLAG_UNSAFE (info[i].use_category()); + if (flag & (HALANT_FLAGS | BASE_FLAGS)) + { + /* 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 (info[i].use_category() == USE_H) + j = i + 1; + else + j = i; + } + else if (((flag) & (FLAG (USE_VPre) | FLAG (USE_VMPre))) && j < i) + { + hb_glyph_info_t t = info[i]; + memmove (&info[j + 1], &info[j], (i - j) * sizeof (info[0])); + info[j] = t; + buffer->merge_clusters (j, i + 1); + } + } } static inline void