GNU bug report logs - #57214
29.0.50; Incorrect rendering of Emoji (grapheme cluster) in Org heading

Previous Next

Package: emacs;

Reported by: Protesilaos Stavrou <info <at> protesilaos.com>

Date: Sun, 14 Aug 2022 18:48:01 UTC

Severity: normal

Found in version 29.0.50

Done: Protesilaos Stavrou <info <at> protesilaos.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 57214 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: summeremacs <at> gmail.com, 57214 <at> debbugs.gnu.org
Subject: Re: bug#57214: 29.0.50;
 Incorrect rendering of Emoji (grapheme cluster) in Org heading
Date: Sun, 14 Aug 2022 22:12:11 +0300
> Cc: summeremacs <at> gmail.com
> From: Protesilaos Stavrou <info <at> protesilaos.com>
> Date: Sun, 14 Aug 2022 21:47:21 +0300
> 
> I have encountered a bug where grapheme clusters are not rendered
> properly when used inside of a folded heading in Org.
> 
> Steps to reproduce with 'emacs -Q':
> 
> 1. Evaluate:
> 
>       (setq org-pretty-entties t
>             org-ellipsis " ☀️")
> 
> 2. Either visit an existing Org file or use the attached sample.
> 
> 3. Fold a heading in Org by pressing TAB with point somewhere on the
>    heading.
> 
> 4. Notice the incorrectly rendered sun emoji at the end of the folded
>    heading.
> 
> If I change 'org-ellipsis' to a single character emoji, such as the
> generic smile, the problem no longer occurs:

This is a limitation of how the ellipsis display is designed and
implemented in Emacs: we display the ellipsis via the buffer's
display-table, and character compositions aren't applied to glyphs
that come from the display-table.  You can clearly see this from how
org.el prepares the display-table:

  (when (and (stringp org-ellipsis) (not (equal "" org-ellipsis)))
    (unless org-display-table
      (setq org-display-table (make-display-table)))
    (set-display-table-slot
     org-display-table 4
     (vconcat (mapcar (lambda (c) (make-glyph-code c 'org-ellipsis))
		      org-ellipsis)))
    (setq buffer-display-table org-display-table))

As you see, the code puts each individual glyph of the Emoji sequence,
marked with its face, into a vector.  When the display engine uses the
glyphs from the display-table, it doesn't interpret them in any way.

So the only way this can work is if the font used for Emoji has a
precomposed glyph for the sequence you want, and that precomposed
glyph has a character code you could use instead of the string.




This bug report was last modified 2 years and 275 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.