[Fontconfig] [PATCH] Cache most recent regcomp() call in _FcStrRegexCmp().

Nick Alcock nick.alcock at oracle.com
Thu May 2 12:26:23 PDT 2013


On 2 May 2013, Behdad Esfahbod verbalised:

> On 13-05-02 06:12 AM, Nick Alcock wrote:
>> The call stack of all these regex calls is the same:
>> 
>> FcFontMatch
>> FcFontSetMatchInternal
>> FcCompare
>> FcCompareValueList
>> FcCompareFilename
>> FcStrRegexCmp
>> 
>> I'm sure some FC_DEBUG value can give useful output to say what value
>> list this is coming from, but the only one I've found that gives
>> anything (FC_DEBUG=2) just gives huge sprays of stuff that's useless for
>> this purpose :/
>
> Well, if you figure out, let us know.  Because I cannot reproduce it here,
> unless my search pattern has the "file" element set.  Is that what Emacs is
> doing?!

Ah!

Emacs's src/xftfont.c:xftfont_open tries to add, well, a lot. Trimmed to
contain only the FcPattern* calls:

  pat = FcPatternCreate ();
  FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity));
  FcPatternAddInteger (pat, FC_SLANT, i);
  FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity));
  FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size);
  val = AREF (entity, FONT_FAMILY_INDEX);
  if (! NILP (val))
    FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
  val = AREF (entity, FONT_FOUNDRY_INDEX);
  if (! NILP (val))
    FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val)));
  val = AREF (entity, FONT_SPACING_INDEX);
  if (! NILP (val))
    FcPatternAddInteger (pat, FC_SPACING, XINT (val));
  val = AREF (entity, FONT_DPI_INDEX);
  if (! NILP (val))
    {
      double dbl = XINT (val);

      FcPatternAddDouble (pat, FC_DPI, dbl);
    }
  val = AREF (entity, FONT_AVGWIDTH_INDEX);
  if (INTEGERP (val) && XINT (val) == 0)
    FcPatternAddBool (pat, FC_SCALABLE, FcTrue);
  /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz
     over 10x20-ISO8859-1.pcf.gz).  */
  FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity));

  xftfont_add_rendering_parameters (pat, entity);

  FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename));
  FcPatternAddInteger (pat, FC_INDEX, XINT (idx));

So, yes, the filename *is* unconditionally added. I don't know enough
about the Emacs Xft-handling code to know why, yet. (I'm not even sure
where that filename ultimately comes from...)

-- 
NULL && (void)


More information about the Fontconfig mailing list