Subject: bug#70000: 29.2; Grapheme handling incorrect

From: jman <[email-masked]>
Date: Fri, 27 Jun 2025 08:50:04 +0200

[1. text/plain]

> The bottom line is what I said at the beginning: we need some protocol
> by which a terminal emulator could be queried about whether it
> supports character composition, and if so, what is the screen width of
> a given sequence of codepoints that will be composed, without actually
> displaying them.  Better yet, some standard table of such widths could
> be accepted by complying terminal emulators, and then Emacs could use
> such a table to know the width in advance (similarly to how it knows
> that from the Unicode data files).
>
> Until such protocols or tables exist, Emacs will be unable to produce
> correct display on these terminal emulators.

Eli, Phillip, I think today such protocol exists.

The author of the terminal emulator Kitty implemented a text-sizing protocol[0] that tells any text
editor how to treat graphemes and especially grapheme clusters. For example if I paste the emoji of
the "writing hand"[1] (which is composed by 2 graphemes U+270D and U+FE0F) into the buffer I am
writing into, Emacs does not understand how to display it, just as other TTY text editors don't (I
also tried nano). Note that this happens only when using `emacs --no-window-system`. When using
`emacs-pgtk` all is good (as Eli points out, Harfbuzz does the work to treat grapheme correctly).

According to the author of Kitty[2], the mode 2027 mentioned in this thread was not a suitable
solution.

I am curious to hear your thoughts about this, if this could be a way out to fix the issue. I
realize that this is a protocol developed by a single person and not a committee with wide industry
adoption. but as far as I know it's the only working solution to the problem.

I am using Emacs 30.1 and I am experiencing the same problem reported in this thread since basically
ever.

Thanks!

Cheers,

[0]: https://sw.kovidgoyal.net/kitty/text-sizing-protocol/
[1]: https://emojipedia.org/writing-hand
[2]: https://github.com/kovidgoyal/kitty/issues/8749#issuecomment-2999678687