From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rodrigo Morales Newsgroups: gmane.emacs.bugs Subject: bug#70993: set-fontset-font doesn't use specified font for some scripts Date: Fri, 17 May 2024 09:57:47 -0500 Message-ID: <87v83cpjtg.fsf@rodrigomorales.site> References: <4adb892bae445f61388156a41e4a0d65@rodrigomorales.site> <865xvchq1m.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40736"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70993@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 17 16:58:25 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 1s7z2O-000ANn-4B for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 May 2024 16:58:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7z22-0003ol-2e; Fri, 17 May 2024 10:58:02 -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 1s7z1z-0003oI-Nj for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 10:57:59 -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 1s7z1z-00049D-G4 for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 10:57:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s7z22-0005ON-42 for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 10:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Rodrigo Morales Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 May 2024 14:58:02 +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.171595788120721 (code B ref 70993); Fri, 17 May 2024 14:58:02 +0000 Original-Received: (at 70993) by debbugs.gnu.org; 17 May 2024 14:58:01 +0000 Original-Received: from localhost ([127.0.0.1]:55666 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7z1z-0005O9-Ld for submit@debbugs.gnu.org; Fri, 17 May 2024 10:58:01 -0400 Original-Received: from smtpout1.mo12.mail-out.ovh.ca ([51.161.45.254]:34909) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7z1v-0005O1-Ah for 70993@debbugs.gnu.org; Fri, 17 May 2024 10:57:58 -0400 Original-Received: from mxplan1.mail.ovh.ca (unknown [10.111.38.131]) by mo12.mail-out.ovh.ca (Postfix) with ESMTPS id 4Vgqnp6yTXzHpwV; Fri, 17 May 2024 11:57:50 -0300 (ADT) Original-Received: from rodrigomorales.site (54.39.251.57) by DAG2EX1.mxpca1.local (172.16.2.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 17 May 2024 10:57:49 -0400 Authentication-Results: garm.ovh; auth=pass (GARM-95B002549e1402-3ba7-46fa-b27b-c07186033572, 281853F6B06FDD851947ED2DB442EC878C9318D3) smtp.auth=me@rodrigomorales.site X-OVh-ClientIp: 190.232.101.8 In-Reply-To: <865xvchq1m.fsf@gnu.org> X-Originating-IP: [54.39.251.57] X-ClientProxiedBy: DAG2EX1.mxpca1.local (172.16.2.11) To DAG2EX1.mxpca1.local (172.16.2.11) X-Ovh-Tracer-GUID: 9f894ff7-98a2-4b2a-8321-95932354ec1c X-Ovh-Tracer-Id: 8101412782726520474 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrvdehfedgudefhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjfhffkfggtgfgihesthhqredttddtjeenucfhrhhomheptfhoughrihhgohcuofhorhgrlhgvshcuoehmvgesrhhoughrihhgohhmohhrrghlvghsrdhsihhtvgeqnecuggftrfgrthhtvghrnhepkeeftdeiffehheejueeuvdevtefhveeuheefjeevueffheejffffffeigfdvleehnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpfihikhhiphgvughirgdrohhrghdpghhnuhdrohhrghenucfkphepuddvjedrtddrtddruddpheegrdefledrvdehuddrheejpdduledtrddvfedvrddutddurdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehmvgesrhhoughrihhgohhmohhrrghlvghsrdhsihhtvgdpnhgspghrtghpthhtohepvddprhgtphhtthhopegvlhhiiiesghhnuhdrohhr ghdprhgtphhtthhopeejtdelleefseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohduvddpmhhouggvpe 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:285247 Archived-At: Eli Zaretskii writes: > 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. I tried setting the font for those scripts in an empty ~/.config/emacs/init.el but the hexadecimal code inside a box was not shown. I cleaned the file =3D~/.config/emacs/init.el=3D in my system and inserted the following sexp: #+HEADER: :tangle ~/.config/emacs/init.el #+BEGIN_SRC elisp (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 I then launched =3Demacs=3D without the =3D-Q=3D flag so that =3D~/.config/emacs/init.el=3D is read. Afterwards, I opened the file =3D/tmp/a.txt=3D which contained the same content as in my first message in this bug report. #+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 (=F0=91=80=A9=F0=91=81=86=F0=91=80=AD=F0=91=80=B8=F0=91=80=B3=F0=91= =81=86=F0=91=80=AB=F0=91=80=BB) =F0=91=80=A6=F0=91=80=AB=F0=91=80=B2=F0=91= =81=86=F0=91=80=A2=F0=91=81=82 Egyptian Hieroglyphs (=F0=93=82=8B=F0=93=8F=A4=F0=93=88=96=F0=93=86=8E=F0= =93=85=93=E2=80=8C=F0=93=8F=8F=F0=93=8A=96) =F0=93=85=93=F0=93=8A=B5=F0=93= =8F=8F=F0=93=8A=AA, =F0=93=87=8D=F0=93=87=8B=F0=93=82=BB=F0=93=8D=98=F0=93= =87=8B Amharic (=E1=8A=A0=E1=88=9B=E1=88=AD=E1=8A=9B) =E1=88=A0=E1=88=8B=E1=88=9D Tagbanwa (=E1=9D=A6=E1=9D=AA=E1=9D=AF) =E1=9D=AB=E1=9D=A9=E1=9D=AC=E1=9D=A5= =E1=9D=A3=E1=9D=AE=E1=9D=A7=E1=9D=AF Chinese (=E4=B8=AD=E6=96=87,=E6=99=AE=E9=80=9A=E8=AF=9D,=E6=B1=89=E8=AF=AD)= =E4=BD=A0=E5=A5=BD #+END_SRC The lines containing the scripts Brahmi and Egyptian Hieroglyphs showed the hexadecimal code inside a box, while the lines containing the scripts Amharic, Tagbanwa and Chinese didn't show the hexadecimal code inside a box. Here's the font reported by what-cursor-position when called with a prefix argument in each line: 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) > 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. This is a significant limitation for users that feel the need to regularly change the font for a given script in the middle of an Emacs session (e.g. users of the package [[https://github.com/tumashu/cnfonts][cnfonts]], the package primarily uses set-fontset-font for setting the font for the scripts 'kana, 'han, 'cjk-misc, 'bopomofo and 'hangul). As for me, I usually change the font for the script 'han because I'm studying Asian languages and the glyphs for a unique code point can be significantly different when using different fonts, see more information in table "Same code point, different language tags" in https://en.wikipedia.org/wiki/Variant_Chinese_characters I lack knowledge on how Emacs internals work to set the font for specific scripts and how glyphs for each character are chosen so I don't know how difficult this would be to implement but I believe that given that Emacs is called an extensible and customizable text editor in https://www.gnu.org/software/emacs/, set-fontset-font should have a reliable and consistent behavior when it is run in the middle of an Emacs session. Thus, giving users the freedom to change the font for any script at any time reliably and making Emacs more customizable. Please let me know your thoughts.