Subject: bug#39799: 28.0.50; Most emoji sequences don’t render correctly

From: Eli Zaretskii <[email-masked]>
Date: Tue, 21 Sep 2021 21:28:40 +0300

> From: Robert Pluim <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Tue, 21 Sep 2021 19:43:05 +0200
> 
> Eli, is this the kind of thing you were thinking of? Seems to work so
> far (with a small addition to blocks.awk).

Yes, with a minor comment below.

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

How about just 'ch'?  We use such names all over the place, so
describing what it is in the comment should be enough.

> @@ -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;

For backward compatibility, I'd prefer here, if font_for_char returns
nil for the representative Emoji character, to call font_for_char
again with the face and codepoint for the original character.

Thanks.