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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 10 Oct 2023 16:40:54 +0300

> From: Yuchen Guo <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 10 Oct 2023 12:59:58 +0000
> 
> > 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.

Emacs has something similar, it can access the language tags of the
font.  If the font specifies a language tag, we can configure the
default fontset in a way that in specific language-environments the
fonts with corresponding language tags are moved to the front of the
fontset.

Do the fonts that you want to use have such language tags?  If they
do, which language tags correspond to what language-environments in
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.

These all are different language-environments in Emacs.  Type

  C-x RET l Chinese TAB

and you will see the Chinese language-environments that Emacs
supports.  When Emacs starts, the initial language-environment is
determined from the system locale, and the default fontset is arranged
accordingly.

So if certain language tags should be required from Chinese fonts in
specific Chinese language-environments, we can express that in our
default fontset, so that the need for configuring fonts manually is
avoided in more cases.

> In other words, it is impossible for Emacs to determine what variant
> does a given user prefer.

See above: is it really impossible?

> 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.

Thanks.