[Fontconfig] Pattern Matching Issues
Behdad Esfahbod
behdad at behdad.org
Thu Jan 30 11:27:55 PST 2014
On 14-01-30 10:14 AM, Tom Hacohen wrote:
> Hey,
>
> I have two issues with matching patterns with fontconfig.
> 1. Something seems wrong with FcFontSort in some cases. I've tried it both
> with fc-match and with code.
> If I run "fc-match :spacing=100" it finds the default font (doesn't have
> spacing=100), however if I run fc-list with the same parameter, I get a
> filtered result that doesn't include the default system font.
> It seems that fc-match is misbehaving, or am I missing something?
The problem is that in fcfreetype.c, we only set FC_SPACING on the font if
it's not FC_PROPORTIONAL. Then when matching, if the font pattern doesn't
have FC_SPACING, it is an implicit match. Ouch! I think we should fix the
first part. I'm sure there was a reason for it (broken fonts, etc?). But I
think we should fix it now. Here's the relevant part of fcfreetype.c:
if (spacing != FC_PROPORTIONAL)
if (!FcPatternAddInteger (pat, FC_SPACING, spacing))
goto bail2;
> 2. Both FcFontSort and FcFontList don't work for me with "ftface" as a
> filtering parameter.
> Testing:
> Use either of the attached c programs (modified versions of fc-match and
> fc-list) and try running them. I hard-coded a font path there (which correctly
> loads, I verified that), you might need to change that to a different path
> depending on your system (Arch here).
> compile with:
> gcc fc-list.c `pkg-config --cflags --libs fontconfig freetype2` list
>
> I would expect it to filter according to the FT_Face, but it doesn't, any ideas?
>
> If that's not what it's meant to do, what's the best way to load a list of
> "most similar to ftface" fonts available on the system? Do I have no analyse
> the face and create the pattern on my own?
Nah, that's not how it works. As Raimund suggested, try querying the font and
using that for matching. Curious why you need this though.
--
behdad
http://behdad.org/
More information about the Fontconfig
mailing list