On Tue, Sep 9, 2025 at 1:34 Eli Zaretskii <eliz@gnu.org> wrote:

 It also means using this will
probably slow down redisplay of the relevant text parts, unless we
find a way of avoiding some of the slow code parts.

Let me think about the best way of doing this.  Meanwhile, I invite
you to read the large commentary at the beginning of xdisp.c, which
mentions character composition, and also take at least a cursory look
at the "automatic compositions" parts of composite.c, which is where
most of the code that deals with character compositions lives.

Thanks for pointing out the direction, I might need to digest all that with extra time. I’ll see if I can also help improving the commentary if there’s a chance. 



The reason why Emacs tries to avoid using the shaper, unless
composition-function-table tells us we must, is that the
implementation of shaping and composition in Emacs is exposed to Lisp
and uses Lisp code for some of its workings, and thus is slow.  Emacs
is unique in this: no other program allows the user to affect
character composition and shaping by a simple change of a
character-indexed table, while the session keeps running.  This gives
Lisp programs and users an unprecedented freedom of affecting how
stuff is displayed, but it comes at a price.

It is extremely powerful design, maybe there is a chance that the shaping engine can serve as additional source of information passing to the composition — so that we can take advantage of both. I’m guessing, I probably will realize how unpractical this idea is, later.