From: Eli Zaretskii <eliz@gnu.org>
To: Nicolas Ouellet-payeur <nicolaso@google.com>
Cc: lumarzeli30@gmail.com, emacs-devel@gnu.org
Subject: Re: Supporting stylistic sets
Date: Fri, 23 Sep 2022 23:10:58 +0300 [thread overview]
Message-ID: <83a66pq2b1.fsf@gnu.org> (raw)
In-Reply-To: <CADuLPF7xDhDvhE=xYekNiCutsUTTMU-N9qU9dUUzBqsGagNHbA@mail.gmail.com> (message from Nicolas Ouellet-payeur on Fri, 23 Sep 2022 15:20:54 -0400)
> From: Nicolas Ouellet-payeur <nicolaso@google.com>
> Date: Fri, 23 Sep 2022 15:20:54 -0400
> Cc: समीर सिंह Sameer Singh <lumarzeli30@gmail.com>,
> emacs-devel@gnu.org
>
> In my case specific: because the 'cv31' variant of my font changes the
> shape of parentheses, and I like that shape better. I would rather set
> it everywhere, even the minibuffer, mode-line, header-line.
You could do something similar to what jit-lock does: place a text
property or an overlay on each parenthesis that is going to be
displayed.
> > IMO, it is impractical to shape everything via a shaping engine
> > without completely redesigning how we handle character compositions in
> > the display engine, because what we have now was not designed to be
> > used for all the text we display.
>
> That's one of my big worries, as well. That's why I'm anxious to share
> a proof-of-concept ASAP, and see if it's worth pursuing.
>
> Initially it *was* super janky, because I did the naïve thing and passed
> strings through hbfont_shape() without caching the result. Each
> redisplay would pass the strings to HarfBuzz again, and create a bunch
> of new Lisp vectors... Then the GC would go crazy, and cause a *lot* of
> jank.
>
> I then tried to put everything into `gstring_hash_table' in composite.c.
> That made things better, but the hashtable would keep growing in size
> all the time. Basically leaking memory on purpose...
>
> My latest attempt is to tweak `region_cache' so it can store arbitrary
> Lisp_Objects, rather than just 1s or 0s for known-ness of regions. Then
> I stick the lgstrings into that cache. Different frames have different
> face properties, so there's one region_cache per (frame,buffer) pair.
> This works, but right now it's incomplete and crashes all the time like
> I said.
>
> It's not *noticeably* jankier so far, and I even used the
> `gstring_hash_table' version as my main editor for a while. But maybe my
> computer is just fast enough, or my use-cases are too simple. It's
> *definitely* way too slow for very long lines. For example, a JSON file
> that's a single line and multiple megabytes. We'd need to fall back to
> the existing code in cases like that.
To measure the slowdown, run the benchmark of scrolling through a
large file, like xdisp.c, one line at a time, and compare with the
current code.
I think one other source of slowdown is that the glyph production is
interrupted too frequently. This is something unrelated to caching
the compositions.
> > You can have ligatures today without passing everything through the
> > shaping engine.
>
> Yes, but you need to configure those manually. Here, the advantage of
> passing them to HarfBuzz is that it can read those ligatures from the
> font file without any extra configuration. i.e., "Support ligatures out
> of the box" as described in etc/TODO. That's not going to change the
> world, but if we can make it work it'll be neat.
But what do you do if the user wants to disable ligation, or control
which ligatures should and shouldn't happen? The fact that a font
that supports ligatures is used in some buffer (or even the default
face) doesn't yet mean the user wants these ligatures everywhere. As
a simple example, consider stuff like := or **-, which is sometimes
shown on the mode line -- we don't want ligation there, do we? If you
leave it to the font to decide when to ligate, Emacs users lose
control of that. That might be OK in the lies of VSCode, but not in
Emacs.
> > And the main difficulty with such a redesign is to do it in a way that
> > still allows easy customization of composition rules from Lisp.
>
> A quick test shows that `prettify-symbols-mode' still works, but I'm
> sure there's subtle bugs hiding underneath.
prettify-symbols-mode uses static compositions, not automatic
compositions, so it's little wonder prettify-symbols-mode isn't
affected: it uses completely different code paths.
I was talking about the way we control automatic compositions through
composition-function-table. This gives us all the freedom and
convenience to control compositions, but it comes with a price: we
need to call into Lisp (which then calls back into C) to produce
glyphs, and we need to match the text against regexps to know what
sequences can and cannot be composed.
next prev parent reply other threads:[~2022-09-23 20:10 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-23 12:54 Supporting stylistic sets समीर सिंह Sameer Singh
2022-09-23 15:37 ` Eli Zaretskii
2022-09-23 17:27 ` समीर सिंह Sameer Singh
2022-09-23 17:31 ` Nicolas Ouellet-payeur
2022-09-23 18:09 ` Eli Zaretskii
2022-09-23 19:20 ` Nicolas Ouellet-payeur
2022-09-23 20:10 ` Eli Zaretskii [this message]
[not found] ` <CADuLPF5sKi4NMcGSdy1GAi8=KHBfUcVa3tV=XwnhPfWxroAJCA@mail.gmail.com>
2022-09-26 17:07 ` Eli Zaretskii
2022-09-26 17:46 ` Nicolas Ouellet-payeur
2022-09-26 18:28 ` Eli Zaretskii
2022-09-26 19:06 ` Yuri Khan
2022-09-26 19:20 ` Eli Zaretskii
2022-09-23 17:55 ` Eli Zaretskii
2022-09-23 18:26 ` Visuwesh
2022-09-23 18:55 ` Eli Zaretskii
2022-09-24 4:59 ` Visuwesh
2022-09-24 6:33 ` Eli Zaretskii
2022-09-24 8:42 ` Visuwesh
2022-09-24 4:43 ` समीर सिंह Sameer Singh
2022-09-24 6:55 ` Eli Zaretskii
2022-09-24 8:00 ` समीर सिंह Sameer Singh
2022-09-24 8:27 ` Eli Zaretskii
2022-09-24 8:34 ` समीर सिंह Sameer Singh
2022-09-24 8:38 ` Eli Zaretskii
2022-09-24 8:41 ` समीर सिंह Sameer Singh
2022-09-24 8:50 ` समीर सिंह Sameer Singh
2022-09-24 12:09 ` समीर सिंह Sameer Singh
2022-09-24 12:35 ` Eli Zaretskii
2022-09-24 12:45 ` समीर सिंह Sameer Singh
2022-09-24 13:00 ` Eli Zaretskii
2022-09-24 13:10 ` समीर सिंह Sameer Singh
2022-09-24 14:18 ` Eli Zaretskii
2022-09-24 14:26 ` समीर सिंह Sameer Singh
2022-09-24 15:01 ` Eli Zaretskii
2022-09-24 15:02 ` समीर सिंह Sameer Singh
2022-09-24 15:21 ` Eli Zaretskii
2022-09-24 15:50 ` समीर सिंह Sameer Singh
2022-09-24 16:14 ` Eli Zaretskii
2022-09-24 16:42 ` Yuri Khan
2022-09-24 17:02 ` Eli Zaretskii
2022-09-24 17:09 ` समीर सिंह Sameer Singh
2022-09-24 17:11 ` समीर सिंह Sameer Singh
2022-09-25 22:19 ` Clément Pit-Claudel
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=83a66pq2b1.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=lumarzeli30@gmail.com \
--cc=nicolaso@google.com \
/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.