summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2017-04-05 15:12:50 +0800
committerMatthias Clasen <mclasen@redhat.com>2017-07-29 18:22:48 +0100
commit734e442a30dc6f2e1c90c278d4bd1bcfcaf72f7c (patch)
tree70c16d788fd4a755ef292ec712ce823eed4edf3c
parent3d763a2b6455f7ad7cd39a099a6995329b38d4e7 (diff)
downloadpango-734e442a30dc6f2e1c90c278d4bd1bcfcaf72f7c.tar.gz
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
-rw-r--r--pango/pango-context.c27
1 files changed, 27 insertions, 0 deletions
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);