emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use "smart kerning" font features in Emacs using composition-


From: Eli Zaretskii
Subject: Re: How to use "smart kerning" font features in Emacs using composition-function-table
Date: Sun, 26 Nov 2023 22:16:25 +0200

> From: Steve Molitor <stevemolitor@gmail.com>
> Date: Sun, 26 Nov 2023 13:49:13 -0600
> Cc: emacs-devel@gnu.org
> 
> Thanks. This indeed does work (matching against the characters Commit
> Mono applies its kerning effect to):
> 
> (set-char-table-range
>  composition-function-table
>  t
>  `(["[ ,-.:;A-Z_a-z]+" 0 font-shape-gstring]))

Do you really need the space character there?  What happens if you
omit it?

And what about '?' and '!'?

> > But -- and it's a very significant "but" -- displaying text via the
> > shaping engine is expensive -- it involves calls from the display
> > engine to Lisp, which then calls back into C. So rules that match any
> > sequence of ASCII letters will slow down redisplay of almost any text
> > in Emacs. This is why Emacs by default doesn't use the text-shaping
> > engine except for scripts that cannot be displayed without non-trivial
> > character compositions.
> 
> Which scripts use the text-shaping engine?

Arabic, Korean (Hangul), various Indian scripts (Devanagar, Bengali,
Gurmukhi), and some others.  Grep for composition-function-table in
lisp/language/*.el, and you will see them all.

Typically, only specific sequences of codepoints are composed, with
rare exceptions, even if a script needs compositions.  This is again
for performance reasons.

> Is it possible to optionally use the text-shaping engine and bypass
> Lisp in say the "English" script?

No, not the way character composition was designed and implemented in
Emacs.  Character composition in Emacs was never meant to be used for
ASCII characters, nor, more generally, for a significant fraction of
buffer text, except in several scripts (such as Arabic) where all the
text must be shaped to be legible.  The calls to Lisp are so that
complex logic of composition and shaping required by some scripts
could be easily implemented and maintained.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]