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 18:55:58 +0300 Message-ID: <86ttiwfn5d.fsf@gnu.org> References: <4adb892bae445f61388156a41e4a0d65@rodrigomorales.site> <865xvchq1m.fsf@gnu.org> <87v83cpjtg.fsf@rodrigomorales.site> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28160"; 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 17:57:17 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 1s7zxM-00076b-Rn for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 May 2024 17:57:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7zx9-0001jm-Kl; Fri, 17 May 2024 11:57:03 -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 1s7zx5-0001j1-Rn for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 11:57: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 1s7zx5-00005G-IK for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 11:56:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s7zx8-0006F8-07 for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 11:57:02 -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 15:57: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.171596137323958 (code B ref 70993); Fri, 17 May 2024 15:57:01 +0000 Original-Received: (at 70993) by debbugs.gnu.org; 17 May 2024 15:56:13 +0000 Original-Received: from localhost ([127.0.0.1]:55911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7zwK-0006EM-Vz for submit@debbugs.gnu.org; Fri, 17 May 2024 11:56:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53584) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7zwJ-0006EE-1E for 70993@debbugs.gnu.org; Fri, 17 May 2024 11:56:11 -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 1s7zw8-0007vX-NC; Fri, 17 May 2024 11:56:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=VW0NefgS4nZsrV2i/2jaO6BKTJZVZLb2w/9UZ5EsUww=; b=fHviOuAvSjfy W5C/m5/ax0ERfxmW79KwXNx6Uv/uRIohL/k2+7OcuUHUkkV7dJVkF1VKpfqL5k8fHx0cEDaNgjqlA Eg6gJnOgT2AxSTzFIhDV9WmkYmbIpVK2GpWP2vxJXTRcmXl0HW+PRDtqJe7Bv0okl0k/8p9Nf0rIc 2XqoIyVveY17/JLKdKo8d8Xie1uzxrHWT58X3xMyGTXyMiGnw9bAsWONEtTKS5Pd3X7ekYEf6NgyL yy6rNPhNtE/dqMEKdd8A5TTjNzDaTR1rv69KkXCKs0EYXF8YIH6Tf/W76HmETzGn0SFO4edwbyL7o UwOV9Eydds0LFdbhqvMZUA==; In-Reply-To: <87v83cpjtg.fsf@rodrigomorales.site> (message from Rodrigo Morales on Fri, 17 May 2024 09:57:47 -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:285253 Archived-At: > From: Rodrigo Morales > CC: <70993@debbugs.gnu.org> > Date: Fri, 17 May 2024 09:57:47 -0500 > > Eli Zaretskii writes: > > (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")) Fir Chinese characters, you need to do the same for cjk-misc charset as well. Not sure it will help you though. In any case, it sounds like Emacs rejects the Cozette font for some scripts. Why that happens, I don't know, sorry. Can you set font-log to nil before you visit your a.txt file, and then post the value of font-log after the file is displayed? That could perhaps tell us something about the cause of this behavior. In general, the Emacs font search and the related features are designed to find good fonts for displaying each character, whereas you are trying to do the opposite: force Emacs to choose a font that can NOT display characters. The doc string of set-fontset-font explains how to set up a fontset so that certain characters have no font: use nil for the FONT-SPEC argument. So if you want Amharic and Chinese characters to display as glyphless characters, use this: (set-fontset-font t 'han nil) (set-fontset-font t 'ethiopic nil) > > 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. This is indeed a limitation for someone who modifies the fontsets a lot during a session, but unless someone submits patches to lift it, it will remain a limitation, sorry.