X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=fc-match%2Ffc-match.c;h=bf9817b8064d83bcdbc4075a7a1896350f6e79ef;hb=0602c605af04ea73af700b223ec4ac1dfd5a36f1;hp=3ddba74c42ab0a7bd2b41488428e580be9da4708;hpb=b1297aa8977901075e95e40bc430fc823e1fb230;p=fontconfig.git diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c index 3ddba74..bf9817b 100644 --- a/fc-match/fc-match.c +++ b/fc-match/fc-match.c @@ -22,11 +22,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include -#include -#include #ifdef HAVE_CONFIG_H #include #else @@ -36,6 +31,12 @@ #define HAVE_GETOPT 1 #endif +#include +#include +#include +#include +#include + #ifndef HAVE_GETOPT #define HAVE_GETOPT 0 #endif @@ -47,7 +48,7 @@ #undef _GNU_SOURCE #define _GNU_SOURCE #include -const struct option longopts[] = { +static const struct option longopts[] = { {"sort", 0, 0, 's'}, {"version", 0, 0, 'V'}, {"verbose", 0, 0, 'v'}, @@ -134,21 +135,39 @@ main (int argc, char **argv) else pat = FcPatternCreate (); + if (!pat) + return 1; + FcConfigSubstitute (0, pat, FcMatchPattern); FcDefaultSubstitute (pat); + fs = FcFontSetCreate (); + if (sort) - fs = FcFontSort (0, pat, FcTrue, 0, &result); + { + FcFontSet *font_patterns; + int j; + font_patterns = FcFontSort (0, pat, FcTrue, 0, &result); + + for (j = 0; j < font_patterns->nfont; j++) + { + FcPattern *font_pattern; + + font_pattern = FcFontRenderPrepare (NULL, pat, font_patterns->fonts[j]); + if (font_pattern) + FcFontSetAdd (fs, font_pattern); + } + + FcFontSetSortDestroy (font_patterns); + } else { FcPattern *match; - fs = FcFontSetCreate (); match = FcFontMatch (0, pat, &result); if (match) FcFontSetAdd (fs, match); } - if (pat) - FcPatternDestroy (pat); + FcPatternDestroy (pat); if (fs) { @@ -184,5 +203,6 @@ main (int argc, char **argv) } FcFontSetDestroy (fs); } + FcFini (); return 0; }