]> git.wh0rd.org - fontconfig.git/blobdiff - fc-match/fc-match.c
Make fc-match --sort call FcFontRenderPrepare.
[fontconfig.git] / fc-match / fc-match.c
index fa45018d55589f04f7fe7249470a9ff1b0d22550..bf9817b8064d83bcdbc4075a7a1896350f6e79ef 100644 (file)
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <fontconfig/fontconfig.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #else
 #define HAVE_GETOPT 1
 #endif
 
+#include <fontconfig/fontconfig.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
 #ifndef HAVE_GETOPT
 #define HAVE_GETOPT 0
 #endif
@@ -140,12 +141,28 @@ main (int argc, char **argv)
     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);
@@ -186,5 +203,6 @@ main (int argc, char **argv)
        }
        FcFontSetDestroy (fs);
     }
+    FcFini ();
     return 0;
 }