Subject: bug#32159: 26.1; inhibit-compacting-font-caches does not fix all fonts lagging issue

From: Eli Zaretskii <[email-masked]>
Date: Tue, 17 Jul 2018 18:05:36 +0300

> From: Moses <[email-masked]>
> Date: Tue, 17 Jul 2018 12:22:27 +0800
> Cc: [email-masked], [email-masked]
> 
> > > and also the "iso10646-1" (encoding name?)?
> > Always use iso10646-1, it makes no sense to use anything else with
> > these scripts.
> 
> How could a user know that? This should at least put into the manual.

You can just drop the encoding, i.e. use

  (set-fontset-font "fontset-default" 'gujarati "Shruti")

The encoding part is just a precaution, and is nowadays only important
for some, hopefully rare, CJK use cases.  I used it in my example for
completeness' sake.

> > > I do not find it in C-u C-x = and the manual is not very clear about
> > > that. Anyway, why Emacs can not generate a "suggestion" of
> > > set-fontset-font in the first place and tell user to add it into
> > > .emacs?
> > It does, in a way: look at the output of "C-u C-x =".  Besides, how is
> > Emacs to know that what happens on your system now is a permanent
> > setup?
> 
> It needn't be a permanent setup.

Sorry, I'm not following: what you put on your ~/.emacs _is_ permanent
setup, in the sense that it will be in effect as long as you don't
change it.  It won't react to changes in the fonts you install, for
one thing.  If, for example, you are just trying some font, and didn't
yet decide whether you like it or not, suggesting that font for your
fontset customization will just confuse if not worse.

> If Emacs loading time becomes longer
> (for example, > 5 sec.), it should prompt users to change their
> fontset and give suggestion settings again.

First, the 5 sec figure is hard to decide on, because it depends on
many factors, like user impatience, the CPU speed, etc.

More importantly, if Emacs stops short of finding a font, it will not
have any useful suggestion for the actual setup of the fontset,
because it will not know what font to suggest.

But I think we are getting ahead of ourselves.  There could be a place
for user-level customization commands based on set-fontset-font
(although I envision non-trivial UI issues, due to the power and
flexibility of fontsets), but before we discuss that, we should
establish that customizing fontsets indeed fixes your real-life
problems.  That doing so for some fonts makes HELLO display faster
doesn't yet mean your real-life use cases are solved by doing the
same.

So please see if the problems that prompted your bug report are indeed
solved by customizing your fontset, including determining which
scripts/ranges of character codepoints needed such customization, and
let's defer the discussion of more user-friendly facilities to after
that.

> BTW, I still confused why Emacs needs to scan fonts to determine which
> character belongs to which font.

Not "belongs", but "can be displayed by".

And I don't think I understand your confusion: how else can any
program determine which font supports a given character, except by
checking the candidate fonts?

> On the other hand, browsers like Firefox, Chromium could display
> every script fonts very fast without issue.

I don't know how the browsers look for fonts.  If someone does, maybe
they can describe that, and we might then be able to learn something
useful.

Just for the record: I didn't write the code in Emacs that implements
font search, and have no real experience or expertise in that area, I
just know one or two things (literally) about what our code does.