[pango] pango: Support emoji sequence in Unicode
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] pango: Support emoji sequence in Unicode
- Date: Sat, 29 Jul 2017 17:28:29 +0000 (UTC)
commit 734e442a30dc6f2e1c90c278d4bd1bcfcaf72f7c
Author: Peng Wu <alexepico gmail com>
Date: Wed Apr 5 15:12:50 2017 +0800
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 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/pango/pango-context.c b/pango/pango-context.c
index f9551a0..0ba2a0c 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]