[Fontconfig] FcPattern Gotcha

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Dec 2 01:09:48 UTC 2016


On Tue, 29 Nov 2016 16:30:35 +0900, Akira TAGOH wrote:

> Can you attach the example that can reproduce your issue?
> 
> FcNameParse() should generates the same FcPattern with the strings
> generated by FcNameUnparse().

OK, I have narrowed it down. Attached is the simplest C program I could
come up with to demonstrate the issue. Pass it a pattern string on the
command line, e.g.

    fc_pattern_2 sans-serif

and it will print out some information about what it found. Having
found a matching pattern, it calls FcNameUnparse to convert that to a
pattern string, followed by FcNameParse to convert the string back to a
pattern.

If the pattern includes the “charset” property, the FcNameParse call
fails, possibly even segfaults. Removing this property causes the parse
(and the subsequent match) to succeed. I helpfully put the call
“FcPatternDel(found_pat, FC_CHARSET);” inside an “if (true)” block, so
you can try changing it to “if (false)” to observe the effect.

I have libconfig 2.11.0 installed from the repo package on Debian
Unstable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fc_pattern_2.c
Type: text/x-c++src
Size: 3228 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/fontconfig/attachments/20161202/2b00d4bc/attachment.c>


More information about the Fontconfig mailing list