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

From: Yuchen Guo <[email-masked]>
Date: Tue, 10 Oct 2023 16:26:55 +0000

Eli Zaretskii <[email-masked]> writes:

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

How can I check this?  I tried `describe-font' on the font I wish to
use, the output is the following

name (opened by): -GOOG-Noto Serif CJK SC-medium-normal-normal-*-48-*-*-*-*-0-iso10646-1
       full name: Noto Serif CJK SC:pixelsize=48:foundry=GOOG:weight=medium:slant=normal:width=normal:scalable=true
       file name: /.../share/fonts/opentype/noto-cjk/NotoSerifCJK-VF.otf.ttc

`fc-match' from fontconfig says

        familylang: "en"(s)
        stylelang: "en"(s)
        fullnamelang: "en"(s)
        lang: aa|ay|bg|bi|bin|br|ch|da|de|en|es|eu|fj|fo|fur
        fy|gd|gl|gn|gv|haw|ho|ia|ig|id|ie|io|is|it|ja|ki|ko|kum|lb|mg|nb|nds
        nl|nn|no|nr|oc|om|os|pt|rm|ru|sel|sm|sma|smj|so|sq|ss|st|sv|sw|tl|to
        ts|uz|vo|wa|xh|yap|zh-cn|zh-hk|zh-mo|zh-sg|zh-tw|zu|an|fil|ht|jv|kj|kwm
        li|ms|na|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|za(s)
        namelang: "en"(s)

Does this mean that the font itself is broken?

> 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.
>
> ...
> See above: is it really impossible?

I'm now convinced that this is indeed possible.  Thanks for the
detailed explanation, and apologies for not reading `(emacs)Language Environments'
earlier.  But now I'm unsure whether this is a problem on the part of
the font, or something that could be fixed in Emacs.

The selection of Free-as-in-Freedom CJK fonts is already too
few, good ones even less, we could ill afford to lose more of them due
to trivial configuration problems.

In the meantime, I'm using the following snippet for fallback.  I've
removed all other configuration:
	
	(defun my-configure-font (frame)
	  "Configure font given initial non-daemon FRAME.
	Intended for `after-make-frame-functions'."
	  ;; 简体中文与标点。
	  (set-fontset-font t 'han (font-spec :family "Noto Serif CJK SC" :weight 'medium))
	  (set-fontset-font t 'cjk-misc (font-spec :family "Noto Serif CJK SC" :weight 'medium))
	  (remove-hook 'after-make-frame-functions #'my-configure-font))
	
	(add-hook 'after-make-frame-functions #'my-configure-font)

Does this make any sense?