all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Rodrigo Morales <me@rodrigomorales.site>
Cc: 70993@debbugs.gnu.org
Subject: bug#70993: set-fontset-font doesn't use specified font for some scripts
Date: Fri, 17 May 2024 18:55:58 +0300	[thread overview]
Message-ID: <86ttiwfn5d.fsf@gnu.org> (raw)
In-Reply-To: <87v83cpjtg.fsf@rodrigomorales.site> (message from Rodrigo Morales on Fri, 17 May 2024 09:57:47 -0500)

> From: Rodrigo Morales <me@rodrigomorales.site>
> CC: <70993@debbugs.gnu.org>
> Date: Fri, 17 May 2024 09:57:47 -0500
> 
> Eli Zaretskii <eliz@gnu.org> 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.





  reply	other threads:[~2024-05-17 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17  3:30 bug#70993: set-fontset-font doesn't use specified font for some scripts Rodrigo Morales
2024-05-17  7:10 ` Eli Zaretskii
2024-05-17 14:57   ` Rodrigo Morales
2024-05-17 15:55     ` Eli Zaretskii [this message]
2024-05-18  6:17 ` Rodrigo Morales
2024-05-18  8:05   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86ttiwfn5d.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=70993@debbugs.gnu.org \
    --cc=me@rodrigomorales.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.