From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70993: set-fontset-font doesn't use specified font for some scripts Date: Fri, 17 May 2024 10:10:29 +0300 Message-ID: <865xvchq1m.fsf@gnu.org> References: <4adb892bae445f61388156a41e4a0d65@rodrigomorales.site> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8247"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70993@debbugs.gnu.org To: Rodrigo Morales Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 17 09:11:31 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s7rkY-0001xK-GP for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 May 2024 09:11:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7rkC-00048G-2q; Fri, 17 May 2024 03:11:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7rk4-00047o-FL for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 03:11:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s7rk3-0005G2-5J for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 03:10:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s7rk5-0002az-Hc for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 03:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 May 2024 07:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70993 X-GNU-PR-Package: emacs Original-Received: via spool by 70993-submit@debbugs.gnu.org id=B70993.17159298509971 (code B ref 70993); Fri, 17 May 2024 07:11:01 +0000 Original-Received: (at 70993) by debbugs.gnu.org; 17 May 2024 07:10:50 +0000 Original-Received: from localhost ([127.0.0.1]:53560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7rjt-0002al-Co for submit@debbugs.gnu.org; Fri, 17 May 2024 03:10:49 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7rjr-0002af-9F for 70993@debbugs.gnu.org; Fri, 17 May 2024 03:10:48 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7rjh-0004vr-AI; Fri, 17 May 2024 03:10:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=TaepVBdBAaGwuq801kBWHt8LIevQFVjNQz62ou5y26w=; b=V5TYS6qRyczXJwXO5FTd EytKMTQtaq9vN9fT4ZMG0RIyPRwXQDSpnBAVqGDm57H1KJSMoVgSVoj3rZL3+V+UOjXAnXBL+XBow 2Narlyiu5KgBKU28gC8d50RplgP/PzfEwneE+SpsSF5uk8N85ZJ0lyqUMyM8ZqMC6hmoBdPicecu2 kY619Op6nTGjTtLdNGTmc5kBkJjo7Myyv2FgQMFWWOjij0Y5KBcCKJWwafu8lIM0ZWloMsESHu7mW fKQJ5YzINslAfQSMHRmrZOkWMdLhwCbLQ6bpe9IaEhMnRfoZmxuQJh00pN3NQeEckEBcdsFEshp5J 4+GRrAG8hnFD3g==; In-Reply-To: <4adb892bae445f61388156a41e4a0d65@rodrigomorales.site> (message from Rodrigo Morales on Thu, 16 May 2024 22:30:56 -0500) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285224 Archived-At: > Date: Thu, 16 May 2024 22:30:56 -0500 > From: Rodrigo Morales > > > I downloaded the font =cozette.bdf= from https://github.com/slavfox/Cozette/releases/tag/v.1.24.1 . This is a bitmap font that define glyphs for a small set of characters since it is intended for programming. > > I launched emacs using =emacs -Q=. I opened the file =/tmp/a.txt=. The contents of that file are shown below. > > #+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 called =what-cursor-position= with a prefix argument in the first character of the word from each script to take note of the font that is used by default: > > Brahmi: ftcrhb:-GOOG-Noto Sans Brahmi-regular-normal-normal-*-12-*-*-*-*-0-iso10646-1 (#x2E) > Egyptian Hieroglyphs: ftcrhb:-GOOG-Noto Sans Egyptian Hieroglyphs-regular-normal-normal-*-12-*-*-*-*-0-iso10646-1 (#x15D) > 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 (#x0D) > Chinese: ftcrhb:-GOOG-Noto Sans CJK KR-regular-normal-normal-*-12-*-*-*-*-0-iso10646-1 (#x2703) > > I then evaluated the following sexp to force the use of the =Cozette= font in the scripts that are shown in that file. Sidenote: I am aware that =Cozette= doesn't define glyphs for these script symbols. The reason I'm reporting this bug is that the current behavior is not consistent. > > #+BEGIN_SRC elisp > (progn > (set-fontset-font t 'brahmi (font-spec :family "Cozette")) > (set-fontset-font t 'egyptian (font-spec :family "Cozette")) > (set-fontset-font t 'ethiopic (font-spec :family "Cozette")) > (set-fontset-font t 'tagbanwa (font-spec :family "Cozette")) > (set-fontset-font t 'han (font-spec :family "Cozette"))) > #+END_SRC > > Upon evaluation, the font changed for the Brahmi and Egyptian Hieroglyphs characters. Because =Cozette= doesn't define glyphs for characters in those scripts, a hexadecimal character code in a box is shown for those scripts. As for Amharic, Tagbanwa and Chinese characters, the font didn't change. I called =what-cursor-position= with a prefix argument in each line to take note of the fonts: > > 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) > > This is not consistent behavior because even though we forced the use of a single font for all scripts in the file in the sexp shown above, Emacs tried to use "Cozette" in the lines containing the Brahmi and Egyptian Hieroglyphs characters (group A) and because no glyph was found, it displayed the hexadecimal character code in a box, while Emacs didn't change the font in the lines containing Amharic, Tagbanwa and Chinese characters (group B), so it didn't display hexadecimal character code in a box as happened in (group A). > > The consistent behavior would be that characters of all scripts shown in the file /tmp/a.txt display a hexadecimal character code in a box after evaluation of the sexp shown above because Cozette version 1.24.1 (the font used to reproduce the bug) doesn't define glyphs for those scripts. I think some people might think that the current behavior happens because Emacs uses a fallback font, but this still shouldn't happen because I had explicitly set the use of a single font for those scripts (I didn't pass =prepend= or =append= as the 5th parameter of set-fontset-font) so Emacs should honour that and don't assume that I want to use fallback fonts. Users that want to handle fallback fonts should explicitly pass 'prepend or 'append as the 5th parameter to set-fontset-font. I think you need to evaluate those set-fontset-font expressions _before_ displaying any characters from the corresponding scripts (i.e., at the very beginning of the Emacs session), to get reliable results. That's because some scripts require characters to be composed on display, and Emacs caches these compositions together with the font used to display those characters. Changing the fontset after some character compositions were already cached will not change the font recorded in the cached compositions. IOW, set-fontset-font cannot be reliably used in the middle of an Emacs session.