emojichooser: Avoid extraneous variation selectors
authorMatthias Clasen <mclasen@redhat.com>
Sun, 30 Apr 2023 15:55:17 +0000 (11:55 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 30 Apr 2023 15:56:43 +0000 (11:56 -0400)
Only add a variation selector if there isn't one already.

gtk/gtkemojichooser.c

index 9288e7342d8799f1f3235e2713485e1b4f67a7f5..d25c4f6c65a86f012aa964bb88dc90eb7adab470 100644 (file)
@@ -563,12 +563,11 @@ add_emoji (GtkWidget    *box,
   int i;
   PangoLayout *layout;
   PangoRectangle rect;
+  gunichar code = 0;
 
   codes = g_variant_get_child_value (item, 0);
   for (i = 0; i < g_variant_n_children (codes); i++)
     {
-      gunichar code;
-
       g_variant_get_child (codes, i, "u", &code);
       if (code == 0)
         code = modifier;
@@ -576,7 +575,10 @@ add_emoji (GtkWidget    *box,
         p += g_unichar_to_utf8 (code, p);
     }
   g_variant_unref (codes);
-  p += g_unichar_to_utf8 (0xFE0F, p); /* U+FE0F is the Emoji variation selector */
+
+  if (code != 0xFE0F && code != 0xFE0E)
+    p += g_unichar_to_utf8 (0xFE0F, p); /* Append a variation selector, if there isn't one already */
+
   p[0] = 0;
 
   label = gtk_label_new (text);