From: Steve Molitor <stevemolitor@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: How to use "smart kerning" font features in Emacs using composition-function-table
Date: Sun, 26 Nov 2023 14:42:36 -0600 [thread overview]
Message-ID: <CAJrM8VVzKnvaPYsD57XhCwX9fLSNR=_50TEmBW=Y-YHLLA6xEQ@mail.gmail.com> (raw)
In-Reply-To: <83il5o9so6.fsf@gnu.org>
> Do you really need the space character there? What happens if you omit
> it?
If I type:
x mm
Then the second "m" is supposed to get shifted away from the first m. If
I take away the space character that stops working. Commit Mono looks at
3 character sequences to do the kerning.
> And what about '?' and '!'?
Commit Mono doesn't seem to take them into account when kerning. Other
fonts like Github's Monaspace might, however.
For ligature support, I do need something like this for Commit Mono:
(set-char-table-range
composition-function-table
t
`([" [,-.:;A-Z_a-z><=!&|+-?/\\]+" 0 font-shape-gstring]))
(I'm probably missing some characters but common ligatures and the
kerning work. I could finesse it to support mode-specific ligatures.)
> 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.
Does performance suffer a lot in those languages, like Arabic?
Thanks again for the responses, I appreciate it. I have more understanding
of how character composition works in Emacs now.
On Sun, Nov 26, 2023 at 2:16 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > 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.
next prev parent reply other threads:[~2023-11-26 20:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-26 15:48 How to use "smart kerning" font features in Emacs using composition-function-table Steve Molitor
2023-11-26 17:52 ` Eli Zaretskii
2023-11-26 19:49 ` Steve Molitor
2023-11-26 20:16 ` Eli Zaretskii
2023-11-26 20:42 ` Steve Molitor [this message]
2023-11-27 12:03 ` Eli Zaretskii
[not found] ` <CAJrM8VW0P+-cO_cup6W-teoJV46nZTcsPrFbaKdXDD_CK_5Rxw@mail.gmail.com>
2023-11-27 15:22 ` Eli Zaretskii
2023-11-27 16:16 ` Steve Molitor
2023-11-28 5:18 ` Yuan Fu
2023-11-28 13:27 ` Steve Molitor
2023-11-29 0:58 ` Yuan Fu
2023-11-28 14:20 ` Eli Zaretskii
2023-11-29 0:57 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJrM8VVzKnvaPYsD57XhCwX9fLSNR=_50TEmBW=Y-YHLLA6xEQ@mail.gmail.com' \
--to=stevemolitor@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.