all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rgm@gnu.org, 39799@debbugs.gnu.org, mfabian@redhat.com
Subject: bug#39799: 28.0.50; Most emoji sequences don’t render correctly
Date: Tue, 21 Sep 2021 19:43:05 +0200	[thread overview]
Message-ID: <87wnn9g6za.fsf@gmail.com> (raw)
In-Reply-To: <8335pyyxkx.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 21 Sep 2021 14:31:10 +0300")

>>>>> On Tue, 21 Sep 2021 14:31:10 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> Date: Tue, 21 Sep 2021 13:54:02 +0300
    >> From: Eli Zaretskii <eliz@gnu.org>
    >> Cc: rgm@gnu.org, 39799@debbugs.gnu.org, mfabian@redhat.com
    >> 
    >> > I think this means you'd have to add the Variation Selectors to the
    >> > emoji script
    >> 
    >> Yes, of course.

    Eli> Btw, we could recognize VS-16 explicitly in font_range, and avoid
    Eli> putting them into the 'emoji' script.  But that would be too kludgey,
    Eli> I guess.

FE0F is already in script-representative-chars for emoji :-)

Eli, is this the kind of thing you were thinking of? Seems to work so
far (with a small addition to blocks.awk).

We'll need to find a better name for the new arg than 'trigger'
though.

diff --git a/src/composite.c b/src/composite.c
index e97f8e2b4c..85485e9358 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -882,14 +882,15 @@ fill_gstring_body (Lisp_Object gstring)
 /* Try to compose the characters at CHARPOS according to composition
    rule RULE ([PATTERN PREV-CHARS FUNC]).  LIMIT limits the characters
    to compose.  STRING, if not nil, is a target string.  WIN is a
-   window where the characters are being displayed.  If characters are
+   window where the characters are being displayed.  TRIGGER is the
+   character that triggered the composition check.  If characters are
    successfully composed, return the composition as a glyph-string
    object.  Otherwise return nil.  */
 
 static Lisp_Object
 autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
 	       ptrdiff_t limit, struct window *win, struct face *face,
-	       Lisp_Object string, Lisp_Object direction)
+	       Lisp_Object string, Lisp_Object direction, int trigger)
 {
   ptrdiff_t count = SPECPDL_INDEX ();
   Lisp_Object pos = make_fixnum (charpos);
@@ -920,7 +921,7 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
   struct frame *f = XFRAME (font_object);
   if (FRAME_WINDOW_P (f))
     {
-      font_object = font_range (charpos, bytepos, &to, win, face, string);
+      font_object = font_range (charpos, bytepos, &to, win, face, string, trigger);
       if (! FONT_OBJECT_P (font_object)
 	  || (! NILP (re)
 	      && to < limit
@@ -1269,7 +1270,7 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos,
 	      if (XFIXNAT (AREF (elt, 1)) != cmp_it->lookback)
 		goto no_composition;
 	      lgstring = autocmp_chars (elt, charpos, bytepos, endpos,
-					w, face, string, direction);
+					w, face, string, direction, cmp_it->ch);
 	      if (composition_gstring_p (lgstring))
 		break;
 	      lgstring = Qnil;
@@ -1307,7 +1308,7 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos,
 	  else
 	    direction = QR2L;
 	  lgstring = autocmp_chars (elt, cpos, bpos, charpos + 1, w, face,
-				    string, direction);
+				    string, direction, cmp_it->ch);
 	  if (! composition_gstring_p (lgstring)
 	      || cpos + LGSTRING_CHAR_LEN (lgstring) - 1 != charpos)
 	    /* Composition failed or didn't cover the current
@@ -1676,7 +1677,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t backlim,
 		  for (check = cur; check_pos < check.pos; )
 		    BACKWARD_CHAR (check, stop);
 		  *gstring = autocmp_chars (elt, check.pos, check.pos_byte,
-					    tail, w, NULL, string, Qnil);
+					    tail, w, NULL, string, Qnil, c);
 		  need_adjustment = 1;
 		  if (NILP (*gstring))
 		    {
diff --git a/src/font.c b/src/font.c
index e043ef8d01..74a1214b38 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3866,6 +3866,9 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
    If STRING is not nil, it is the string to check instead of the current
    buffer.  In that case, FACE must be not NULL.
 
+   TRIGGER is the character that actually caused the composition
+   process to start, it may be different from the character at POS.
+
    The return value is the font-object for the character at POS.
    *LIMIT is set to the position where that font can't be used.
 
@@ -3873,15 +3876,16 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
 
 Lisp_Object
 font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
-	    struct window *w, struct face *face, Lisp_Object string)
+	    struct window *w, struct face *face, Lisp_Object string,
+	    int trigger)
 {
   ptrdiff_t ignore;
   int c;
   Lisp_Object font_object = Qnil;
+  struct frame *f = XFRAME (w->frame);
 
   if (!face)
     {
-      struct frame *f = XFRAME (w->frame);
       int face_id;
 
       if (NILP (string))
@@ -3912,6 +3916,23 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
 	continue;
       if (NILP (font_object))
 	{
+	  if (EQ (CHAR_TABLE_REF (Vchar_script_table, trigger),
+		  Qemoji))
+	    {
+	      Lisp_Object val = assq_no_quit (Qemoji, Vscript_representative_chars);
+	      if (CONSP (val))
+		{
+		  int face_id;
+		  val = XCDR (val);
+		  if (CONSP (val))
+		    val = XCAR (val);
+		  else if (VECTORP (val))
+		    val = AREF (val, 0);
+		  c = XFIXNAT (val);
+		  face_id = FACE_FOR_CHAR (f, face, c, pos - 1, string);
+		  face = FACE_FROM_ID (f, face_id);
+		}
+	    }
 	  font_object = font_for_char (face, c, pos - 1, string);
 	  if (NILP (font_object))
 	    return Qnil;
@@ -5423,6 +5444,7 @@ syms_of_font (void)
   DEFSYM (Qiso8859_1, "iso8859-1");
   DEFSYM (Qiso10646_1, "iso10646-1");
   DEFSYM (Qunicode_bmp, "unicode-bmp");
+  DEFSYM (Qemoji, "emoji");
 
   /* Symbols representing keys of font extra info.  */
   DEFSYM (QCotf, ":otf");
diff --git a/src/font.h b/src/font.h
index d3e1530642..1da72cca07 100644
--- a/src/font.h
+++ b/src/font.h
@@ -885,7 +885,7 @@ valid_font_driver (struct font_driver const *d)
 extern Lisp_Object font_update_drivers (struct frame *f, Lisp_Object list);
 extern Lisp_Object font_range (ptrdiff_t, ptrdiff_t, ptrdiff_t *,
 			       struct window *, struct face *,
-			       Lisp_Object);
+			       Lisp_Object, int);
 extern void font_fill_lglyph_metrics (Lisp_Object, struct font *, unsigned int);
 
 extern Lisp_Object font_put_extra (Lisp_Object font, Lisp_Object prop,





  reply	other threads:[~2021-09-21 17:43 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 14:28 bug#39799: 28.0.50; Most emoji sequences don’t render correctly Mike FABIAN
2020-02-28  7:14 ` Eli Zaretskii
2020-02-28  7:36   ` Mike FABIAN
2020-02-28  8:25     ` Eli Zaretskii
2020-02-28 12:21       ` Robert Pluim
2020-02-28 12:46         ` Mike FABIAN
2020-02-28 13:19           ` Robert Pluim
2020-02-28 13:50             ` Mike FABIAN
2020-02-28 13:56               ` Eli Zaretskii
2020-02-28 14:44                 ` Mike FABIAN
2020-02-28 13:08         ` Eli Zaretskii
2020-02-28 13:47           ` Mike FABIAN
2020-02-28 13:54             ` Eli Zaretskii
2020-02-28 14:14           ` Robert Pluim
2020-02-28 14:45             ` Eli Zaretskii
2020-02-28 15:32               ` Mike FABIAN
2020-02-28 15:57                 ` Robert Pluim
2020-02-28 15:39               ` Robert Pluim
2020-02-28 16:38                 ` Mike FABIAN
2020-02-28 14:46             ` Eli Zaretskii
2020-02-28 15:35               ` Robert Pluim
2020-02-28 15:44                 ` Eli Zaretskii
2020-02-28 16:24                   ` Robert Pluim
2020-02-28 17:30                     ` Mike FABIAN
2020-02-28 17:55                       ` Mike FABIAN
2020-02-28 18:01                       ` Robert Pluim
2020-02-28 19:29                         ` Mike FABIAN
2020-02-28 19:34                         ` Mike FABIAN
2020-02-28 21:32                         ` Mike FABIAN
2020-02-28 21:38                           ` Robert Pluim
2020-02-28 20:21                       ` Eli Zaretskii
2020-02-28 20:25                         ` Eli Zaretskii
2020-02-28 21:02                           ` Eli Zaretskii
2020-02-28 21:47                             ` Robert Pluim
2020-02-28 22:07                               ` Eli Zaretskii
2020-02-29  7:50                                 ` Mike FABIAN
2020-02-29  9:40                                   ` Eli Zaretskii
2020-02-29 10:45                                     ` Mike FABIAN
2020-02-28 21:10                         ` Mike FABIAN
2020-02-28 21:49                           ` Eli Zaretskii
2020-02-29  7:59                             ` Mike FABIAN
2020-02-29 10:04                               ` Eli Zaretskii
2020-02-29 11:14                                 ` Mike FABIAN
2020-02-29 11:52                                   ` Eli Zaretskii
2020-02-29 16:59                                     ` Mike FABIAN
2020-02-28 20:13                     ` Eli Zaretskii
2020-02-28 20:38                       ` Robert Pluim
2020-02-28 20:55                         ` Eli Zaretskii
2020-02-28 21:22                           ` Robert Pluim
2020-02-28 21:27                             ` Mike FABIAN
2020-02-28 21:52                             ` Eli Zaretskii
2020-02-29  8:01                               ` Mike FABIAN
2020-02-29  9:49                                 ` Eli Zaretskii
2020-02-29 10:26                                   ` Mike FABIAN
2020-02-29 11:19                                     ` Eli Zaretskii
2020-02-29 11:36                                       ` Mike FABIAN
2020-02-29 11:58                                         ` Eli Zaretskii
2020-02-29 17:03                                           ` Mike FABIAN
2020-02-29 17:19                                             ` Eli Zaretskii
2020-02-29 11:41                                       ` Mike FABIAN
2020-02-29 12:02                                         ` Eli Zaretskii
2020-02-29 17:14                                           ` Mike FABIAN
2020-02-29 17:27                                             ` Eli Zaretskii
2020-03-02  9:10                                               ` Robert Pluim
2020-03-02 11:02                                                 ` Eli Zaretskii
2020-02-28 21:14                         ` Mike FABIAN
2020-02-28 21:50                           ` Eli Zaretskii
2020-02-28 16:19             ` Eli Zaretskii
2020-02-28 16:39               ` Robert Pluim
2020-02-28 20:16                 ` Eli Zaretskii
2020-02-28 20:56                   ` Robert Pluim
2021-09-20 20:38                     ` Robert Pluim
2021-09-21  9:16                       ` Eli Zaretskii
2021-09-21 10:34                         ` Robert Pluim
2021-09-21 10:54                           ` Eli Zaretskii
2021-09-21 11:31                             ` Eli Zaretskii
2021-09-21 17:43                               ` Robert Pluim [this message]
2021-09-21 18:28                                 ` Eli Zaretskii
2021-09-22  9:02                                   ` Robert Pluim
2021-09-24 19:28                                     ` Mike FABIAN
2021-09-25  5:55                                       ` Eli Zaretskii
2021-09-25  7:35                                         ` Mike FABIAN
2021-09-25  9:19                                           ` Eli Zaretskii
2021-11-06 18:59                                             ` Lars Ingebrigtsen
2021-09-21 11:48                       ` Mike FABIAN
2021-09-21 11:58                         ` Eli Zaretskii
2021-09-21 12:27                           ` Mike FABIAN
2021-09-21 12:37                             ` Eli Zaretskii
2021-09-21 12:50                           ` Robert Pluim
2021-09-21 13:06                             ` Eli Zaretskii
2021-09-21 13:25                               ` Mike FABIAN
2021-09-21 13:53                                 ` Robert Pluim
2021-09-21 14:19                                   ` Eli Zaretskii
2021-09-21 14:43                                     ` Robert Pluim
2021-09-21 15:58                                       ` Eli Zaretskii
2021-09-21 16:10                                         ` Robert Pluim
2021-09-21 16:23                                           ` Eli Zaretskii
2021-09-21 16:50                                             ` Eli Zaretskii
2021-09-21 18:20                                               ` Eli Zaretskii
2021-09-22  8:59                                                 ` Robert Pluim
2021-09-22 13:47                                                   ` Eli Zaretskii
2021-09-24 11:41                                                 ` Robert Pluim
2021-09-24 12:04                                                   ` Eli Zaretskii
2021-09-24 12:10                                                     ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnn9g6za.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=39799@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mfabian@redhat.com \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.