Subject: bug#71025: set-fontset-font doesn't show some scripts as glyphless characters

From: Eli Zaretskii <[email-masked]>
Date: Sat, 18 May 2024 10:57:30 +0300

> From: Rodrigo Morales <[email-masked]>
> Date: Sat, 18 May 2024 00:59:37 -0500
> 
> 
> I need characters from specific scripts to be shown as glyphless
> characters (i.e. hexadecimal codes inside boxes). In [[1][this message]],
> Eli Zaretskii cited the docstring of set-fontset-font (relevant part
> shown in QUOTE block below) to backup the suggestion that if I wanted to
> display Amharic and Chinese characters as glyphless characters, I should
> call =set-fontset-font= with =CHARACTERS= equal to =nil=.
> 
> #+BEGIN_QUOTE
> CHARACTERS may be nil. In that case, use FONT-SPEC for any character for
> which no font-spec is specified in FONTSET."
> #+END_QUOTE
> 
> I tried Eli's suggestion. However, this didn't make the characters from
> all of the specified scripts to be shown as hexadecimal codes inside
> boxes. I explain how I reproduced the issue in the lines below.
> 
> I emptied =~/.config/emacs/init.el= and inserted the following sexps
> into that file.
> 
> #+HEADER: :tangle ~/.config/emacs/init.el
> #+BEGIN_SRC elisp
> (set-fontset-font t 'brahmi nil)
> (set-fontset-font t 'egyptian nil)
> (set-fontset-font t 'ethiopic nil)
> (set-fontset-font t 'tagbanwa nil)
> (set-fontset-font t 'han nil)
> #+END_SRC
> 
> I created the file =/tmp/a.txt= with the following content
> 
> #+HEADER: :tangle /tmp/a.txt
> #+BEGIN_SRC text
> The following lines were retrieved from the HELLO buffer which is
> opened by calling view-hello-file in GNU Emacs 29.3.
> Brahmi (𑀩𑁆𑀭𑀸𑀳𑁆𑀫𑀻)       𑀦𑀫𑀲𑁆𑀢𑁂
> Egyptian Hieroglyphs (𓂋𓏤𓈖𓆎𓅓‌𓏏𓊖) 𓅓𓊵𓏏𓊪, 𓇍𓇋𓂻𓍘𓇋
> Amharic (አማርኛ)  ሠላም
> Tagbanwa (ᝦᝪᝯ)  ᝫᝩᝬᝥ ᝣᝮᝧᝯ
> Chinese (中文,普通话,汉语)     你好
> #+END_SRC
> 
> I launched Emacs by running =$ emacs= in a terminal emulator. I didn't
> use the =-Q= flag so that =~/.config/emacs/init.el= is read.
> 
> I evaluated =(find-file "/tmp/a.txt")=, and I could see that
> hexadecimal codes in a box were shown for the Brahmi and Egyptian
> Hieroglyphs characters. This is expected behavior. However, the
> Amharic, Tagbanwa and Chinese characters weren't shown as hexadecimal
> codes inside a box but instead they were shown using other fonts. This
> is unexpected behavior. I called =describe-char= in the first
> character of each line to see which font is used for each script.
> 
> + Brahmi: no font available
> + Egyptian Hieroglyphs: no font available
> + Amharic: ftcrhb:-GOOG-Noto Sans
>   Ethiopic-regular-normal-normal-*-12-*-*-*-*-0-iso10646-1 (#x2B)
> + Tagbanwa: ftcrhb:-GOOG-Noto Sans
>   Tagbanwa-regular-normal-normal-*-12-*-*-*-*-0-iso10646-1 (#x12)
> + Chinese: ftcrhb:-GOOG-Noto Sans CJK
>   KR-regular-normal-normal-*-12-*-*-*-*-0-iso10646-1 (#x2703)
> 
> Just to make it clear, to me the behavior that actually honours the
> docstring of =set-fontset-font= is that the characters from the
> scripts in the file =/tmp/a.txt= are shown as hexadecimal codes inside
> boxes.

I cannot reproduce this.  On my system, those 5 lines in the init file
show all the scripts in a.txt as hexadecimal codes.

Do you have site-init files in your Emacs installation?  Or some
early-init file?  Maybe something other than the init file is
affecting this.  Otherwise, I have no idea why this doesn't work for
you, as it does for me.