From 734e442a30dc6f2e1c90c278d4bd1bcfcaf72f7c Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 5 Apr 2017 15:12:50 +0800 Subject: pango: Support emoji sequence in Unicode Checked several emoji sequences, the sequence pattern is like follows: 1. Use zero width joiner to combine two characters with any width 2. Ignore the width of variation selector, tag and emoji modifier for the purposes of finding a run or uniform-width characters. https://bugzilla.gnome.org/show_bug.cgi?id=780669 --- pango/pango-context.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pango/pango-context.c b/pango/pango-context.c index f9551a06..0ba2a0cd 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -865,6 +865,7 @@ width_iter_iswide (gunichar ch) static void width_iter_next(PangoWidthIter* iter) { + gboolean met_joiner = FALSE; iter->start = iter->end; if (iter->end < iter->text_end) @@ -876,6 +877,32 @@ width_iter_next(PangoWidthIter* iter) while (iter->end < iter->text_end) { gunichar ch = g_utf8_get_char (iter->end); + + /* for zero width joiner */ + if (ch == 0x200D) + { + iter->end = g_utf8_next_char (iter->end); + met_joiner = TRUE; + continue; + } + + /* ignore the wide check if met joiner */ + if (met_joiner) + { + iter->end = g_utf8_next_char (iter->end); + met_joiner = FALSE; + continue; + } + + /* for variation selector, tag and emoji modifier. */ + if (G_UNLIKELY(ch == 0xFE0EU || ch == 0xFE0FU + || (ch >= 0xE0020 && ch <= 0xE007F) + || (ch >= 0x1F3FB && ch <= 0x1F3FF))) + { + iter->end = g_utf8_next_char (iter->end); + continue; + } + if (width_iter_iswide (ch) != iter->wide) break; iter->end = g_utf8_next_char (iter->end); -- cgit v1.2.1