emacs-devel
[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 21:55:04 +0200

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> 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);
    }



reply via email to

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