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.devel Subject: Re: Order of fonts returned by list-fonts Date: Sun, 09 Jan 2022 21:55:04 +0200 Message-ID: <83fspwadlz.fsf@gnu.org> References: <87r19hhm0f.fsf@gmail.com> <83o84kajzk.fsf@gnu.org> <87ilusitje.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="4623"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?Q?K=C3=A9vin?= Le Gouguec Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jan 09 20:56:30 2022 Return-path: Envelope-to: ged-emacs-devel@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 1n6eIo-00011V-GA for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Jan 2022 20:56:30 +0100 Original-Received: from localhost ([::1]:55842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6eIm-00008m-IM for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Jan 2022 14:56:28 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6eHr-0007o9-Oe for emacs-devel@gnu.org; Sun, 09 Jan 2022 14:55:31 -0500 Original-Received: from [2001:470:142:3::e] (port=58908 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 1n6eHr-00046x-E5; Sun, 09 Jan 2022 14:55: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=iKQkw+r/EeW7X9Q9PDkFPWCHOtvtp+btlzjKxdhipng=; b=Urw16lauADNlIoLxXXB2 5UhI/i3RcHvQBQu/n6QmVBV0nRaBkx5FTveK6g5IvcWwzXAdi5R0V7GANSKvgHO4Z0e4mIOUawDSf /x9odcqQPlEAVJ921Do3k7wWDKDlP50D6PMdHIJMZtcIsq2RFa/GsntZGgI0Ab+I2emjyC2XDxBiy nirRmy0mXNd08Pv2SKxjadPL4pFNIx1lb5hubMj7++wvdmXQ7oSpkWhrPbvkbJHu3GR5tqUD3xnPH TexigfElx5ifodZHkeOACuwP8JC9OEPMnIHiqKMNStDybHMeD2Oq4gqE/J1ixSmxJCvtxd2idRRje qs7QnZqDFamp0g==; Original-Received: from [87.69.77.57] (port=3027 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 1n6eHd-0008Jm-33; Sun, 09 Jan 2022 14:55:31 -0500 In-Reply-To: <87ilusitje.fsf@gmail.com> (message from =?utf-8?Q?K=C3=A9vin?= Le Gouguec on Sun, 09 Jan 2022 20:43:49 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284508 Archived-At: > From: Kévin Le Gouguec > Cc: emacs-devel@gnu.org > Date: Sun, 09 Jan 2022 20:43:49 +0100 > > > 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? > > (Mmm. Each time I've seen an nreverse (specifically, at the end of > font_list_entities and ftfont_list), I've assumed it was because we had > just iterated over something and accumulated results by Fcons'ing an > item with an accumulator, so we had "inverted" the order of the thing we > were iterating on, and nreverse restored the "original" order) That's right. Here's what ftfont.c does to generate the list of matching fonts: for (i = 0; i < fontset->nfont; i++) { FcPattern *pat = fontset->fonts[i]; FcChar8 *str; if (FcPatternGetString (pat, FC_FAMILY, 0, &str) == FcResultMatch) list = Fcons (intern ((char *) str), list); }