Subject: bug#66416: 29.1; Crashes when visiting HELLO file with pgtk on Wayland

From: Yuchen Guo <[email-masked]>
Date: Tue, 10 Oct 2023 12:59:58 +0000

Eli Zaretskii <[email-masked]> writes:

> You do have the freedom, and Emacs gives users more freedom in
> customizing fonts than most other GUI apps.

In my experience, Emacs is certainly one of, if not the most effective
at customizing fonts, made even more impressive considering the fact
that everything is controlled by elisp.

Kudos to you for making a truly wonderful GUI possible!

> You just need to know very well what you are doing to exercise that
> freedom, so we are trying hard to make the need for that as small and
> rare as possible.

Yes.  In a previous reply you mentioned that this configuration is
non-trivial, and indeed a perfect out-of-the-box experience is a noble
goal in itself.

Alas, some of us users would still try to customize the fonts with very
little understanding of the intricacies of Emacs internals.

> Thanks.  The question is: how can Emacs distinguish between these
> fonts and decide that one of them is not suitable.

I think this is not possible without the user explicitly specifying
which variant is needed.  In HTML this is done with language tags, such
as lang="zh-Hans", but this strategy only covers a minority of cases,
because

- the author of the HTML document has to specify this language tag
- the browser must understand this tag
- only applies to HTML documents

In most other cases, such as the user interface of an Android phone, the
default variant is chosen during language configuration.  If a non-CJK
language was chosen, such as en-US for American English (I do this), it
will behave in the same manner as Emacs.

> In general, Emacs picks up the first font that matches the fontset's
> spec, so we need to come up with two things: (a) the way for Emacs to
> distinguish between these fonts, and (b) the way to encode the
> requirements for a "good" font in our default fontset.  Then Emacs
> will be able to pick up the correct font automatically.

"Good" is, in this case, defined by user.  One font suitable for
Mainland China users is not suitable for Taiwan, Hong Kong or Japan
users, and vice versa.  In other words, it is impossible for Emacs to
determine what variant does a given user prefer.

But there's good news.  I've rebuilt Emacs from latest commit (9 hours
ago) in the emacs-29 branch, with debug symbols enabled.  Fresh out of
the oven!  This was all made very simple and declarative thanks to the
Nix package manager:

https://codeberg.org/m0p/dotfiles/commit/e1fb4ffc4b4ce3a914adbd4c4a49863b2a48afeb

with the following init.el

https://codeberg.org/m0p/dotfiles/raw/commit/eec25a4ae443de78ea3d8ea3d94541060d7861d7/imports/not-nix-config-files/emacs-init.el

We will see if Emacs crashes again.  So far with (4 hours, 43 minutes, 3
seconds) uptime.