help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Order of fonts returned by list-fonts


From: Eli Zaretskii
Subject: Re: Order of fonts returned by list-fonts
Date: Sun, 09 Jan 2022 19:37:19 +0200

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Date: Sat, 08 Jan 2022 23:59:28 +0100

This list is not the right place for discussions where you question
the correctness of low-level font-handling code in Emacs.  Please
consider moving this to emacs-devel.

> My distro ships with Noto Color Emoji 13.1.  I have installed version 14
> under ~/.local/share/fonts.  fc-match seems to prioritize the latter:
> 
> $ fc-match -f '%{fullname} %{file}\n' "Noto Color Emoji"
> > Noto Color Emoji /home/peniblec/.local/share/fonts/NotoColorEmoji.ttf
> 
> Emacs, however, seems to favour the former:
> 
> (find-font (font-spec :family "Noto Color Emoji"))
> > #<font-entity ftcrhb GOOG Noto\ Color\ Emoji nil iso10646-1 regular
> > normal normal 0 nil 100 0 ((:font-entity
> > "/usr/share/fonts/truetype/NotoColorEmoji.ttf" . 0))>
> 
> (list-fonts (font-spec :family "Noto Color Emoji"))
> > (#<font-entity ftcrhb GOOG Noto\ Color\ Emoji nil iso10646-1 regular
> >  normal normal 0 nil 100 0 ((:font-entity
> >  "/usr/share/fonts/truetype/NotoColorEmoji.ttf" . 0))> 
> >  #<font-entity ftcrhb GOOG Noto\ Color\ Emoji nil iso10646-1 regular
> >  normal normal 0 nil 100 0 ((:font-entity
> >  "/home/peniblec/.local/share/fonts/NotoColorEmoji.ttf" . 0))>)
> 
> Could this be considered a bug?  I didn't dig into the code yet, beside
> looking at font_list_entities (which led me to restart with
> EMACS_FONT_LOG set; unfortunately font-show-log doesn't have much to say
> about how font files are searched).

As you've probably seen, font_list_entities calls the font driver's
'list' method, and then reverses the resulting list.  That is supposed
to produce the list of fonts in the same order in which the font
driver lists the fonts.  Does that mean that Fontconfig produces
matching fonts with the best/newest/user-local one the last?

> I don't know if my expectation (that Emacs and fc-match should agree on
> how files are prioritized) is warranted; I know that Emacs relies on
> Fontconfig APIs to some degree, but I'm sure there is more complexity
> lurking under the hood.

Emacs doesn't assign any priorities to the fonts returned by the font
driver due to the order in which they are returned; it sorts the list
of fonts by other criteria.  However, after sorting (if there's more
than one candidate), Emacs will use the first matching font.  What
happens in your case can only be established by stepping through the
code with a debugger.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]