From f39934983f459c992e27075cd2c45ac0025183d0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 May 2019 00:13:21 -0700 Subject: [PATCH] [ucdn] Fix Hangul composition https://github.com/grigorig/ucdn/issues/23 --- src/hb-ucdn/ucdn.c | 3 ++- test/api/test-unicode.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hb-ucdn/ucdn.c b/src/hb-ucdn/ucdn.c index 30747fea2..f7b33d645 100644 --- a/src/hb-ucdn/ucdn.c +++ b/src/hb-ucdn/ucdn.c @@ -163,7 +163,8 @@ static int hangul_pair_decompose(uint32_t code, uint32_t *a, uint32_t *b) static int hangul_pair_compose(uint32_t *code, uint32_t a, uint32_t b) { - if (a >= SBASE && a < (SBASE + SCOUNT) && b >= TBASE && b < (TBASE + TCOUNT)) { + if (a >= SBASE && a < (SBASE + SCOUNT) && b > TBASE && b < (TBASE + TCOUNT) && + !((a - SBASE) % TCOUNT)) { /* LV,T */ *code = a + (b - TBASE); return 3; diff --git a/test/api/test-unicode.c b/test/api/test-unicode.c index 6195bb286..0587c6e7f 100644 --- a/test/api/test-unicode.c +++ b/test/api/test-unicode.c @@ -755,6 +755,10 @@ test_unicode_normalization (gconstpointer user_data) g_assert (hb_unicode_compose (uf, 0xCE20, 0x11B8, &ab) && ab == 0xCE31); g_assert (hb_unicode_compose (uf, 0x110E, 0x1173, &ab) && ab == 0xCE20); + g_assert (!hb_unicode_compose (uf, 0xAC00, 0x11A7, &ab)); + g_assert (hb_unicode_compose (uf, 0xAC00, 0x11A8, &ab) && ab == 0xAC01); + g_assert (!hb_unicode_compose (uf, 0xAC01, 0x11A8, &ab)); + /* Test decompose() */