[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#57214: 29.0.50; Incorrect rendering of Emoji (grapheme cluster) in O
From: |
Eli Zaretskii |
Subject: |
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@gmail.com
> From: Protesilaos Stavrou <info@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.