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.help Subject: Re: Order of fonts returned by list-fonts Date: Sun, 09 Jan 2022 19:37:19 +0200 Message-ID: <83o84kajzk.fsf@gnu.org> References: <87r19hhm0f.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21938"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 09 18:38:06 2022 Return-path: Envelope-to: geh-help-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 1n6c8r-0005Tm-3x for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 09 Jan 2022 18:38:05 +0100 Original-Received: from localhost ([::1]:47226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6c8p-0003FS-SY for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 09 Jan 2022 12:38:03 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6c8K-0003FH-5f for help-gnu-emacs@gnu.org; Sun, 09 Jan 2022 12:37:32 -0500 Original-Received: from [2001:470:142:3::e] (port=57298 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6c8J-0001XG-TS for help-gnu-emacs@gnu.org; Sun, 09 Jan 2022 12:37:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=tjSgK0J2twxUP6iSeF0MqowtL0XXqhW3lmYFnG7C5Qg=; b=CSYqgmlPSlPe2ZhhScgh fabeRWdUEOYj/1OPKJaQMPfRoUBLnLaopxPcNax66RX0MvlUICxL4r+kJoJ3Gqejema1ozCmP2+5H nNp6wwOAGP+fIOvVjgaDMlrjpnfCHgndic7K7jLjjXLeu+gHq8+Y7qzoNHJWWChtHl9O23oAYtUAN mOPWh0idT2KDi0lOMj4D+j86N7TSMTfduiaUBerL71NKMZKGIMv8i6YdWaopTmaL/p9ISBoVZpPoF y81HazmAFjTrZmpbvayos7uTa0ifKawo5XyTk+eEKcE6WFA6QUgjykfBW/ZOtyP2Gaw3Ddux2rw6+ 6pTBf2qf07qBeQ==; Original-Received: from [87.69.77.57] (port=2400 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6c8J-0002bx-GM for help-gnu-emacs@gnu.org; Sun, 09 Jan 2022 12:37:31 -0500 In-Reply-To: <87r19hhm0f.fsf@gmail.com> (message from =?utf-8?Q?K=C3=A9vin?= Le Gouguec on Sat, 08 Jan 2022 23:59:28 +0100) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:135160 Archived-At: > From: Kévin Le Gouguec > 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")) > > # > normal normal 0 nil 100 0 ((:font-entity > > "/usr/share/fonts/truetype/NotoColorEmoji.ttf" . 0))> > > (list-fonts (font-spec :family "Noto Color Emoji")) > > (# > normal normal 0 nil 100 0 ((:font-entity > > "/usr/share/fonts/truetype/NotoColorEmoji.ttf" . 0))> > > # > 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.