]> git.wh0rd.org - fontconfig.git/blobdiff - fc-list/fc-list.c
Indent line
[fontconfig.git] / fc-list / fc-list.c
index 1d2d67b30b5ceed878011414826013616b949631..45c62958b0d3693ba9a58fe76849e036973629dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $XFree86: $
+ * $XFree86: xc/lib/fontconfig/fc-list/fc-list.c,v 1.2 2002/02/15 06:01:26 keithp Exp $
  *
  * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
  *
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #else
+#ifdef linux
+#define HAVE_GETOPT_LONG 1
+#endif
 #define HAVE_GETOPT 1
 #endif
 
+#ifndef HAVE_GETOPT
+#define HAVE_GETOPT 0
+#endif
+#ifndef HAVE_GETOPT_LONG
+#define HAVE_GETOPT_LONG 0
+#endif
+
 #if HAVE_GETOPT_LONG
+#undef  _GNU_SOURCE
 #define _GNU_SOURCE
 #include <getopt.h>
 const struct option longopts[] = {
@@ -50,10 +61,9 @@ extern int optind, opterr, optopt;
 
 static void usage (char *program)
 {
-    fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [dirs]\n",
+    fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [pattern] {element ...} \n",
             program);
-    fprintf (stderr, "Build font information caches in [dirs]\n"
-            "(all directories in font configuration by default).\n");
+    fprintf (stderr, "List fonts matching [pattern]\n");
     fprintf (stderr, "\n");
     fprintf (stderr, "  -v, --verbose        display status information while busy\n");
     fprintf (stderr, "  -V, --version        display font config version and exit\n");
@@ -66,7 +76,7 @@ main (int argc, char **argv)
 {
     int                verbose = 0;
     int                i;
-    FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_LANG, 0);
+    FcObjectSet *os = 0;
     FcFontSet  *fs;
     FcPattern   *pat;
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
@@ -101,10 +111,20 @@ main (int argc, char **argv)
        return 1;
     }
     if (argv[i])
-       pat = FcNameParse (argv[i]);
+    {
+       pat = FcNameParse ((FcChar8 *) argv[i]);
+       while (argv[++i])
+       {
+           if (!os)
+               os = FcObjectSetCreate ();
+           FcObjectSetAdd (os, argv[i]);
+       }
+    }
     else
        pat = FcPatternCreate ();
     
+    if (!os)
+       os = FcObjectSetBuild (FC_FAMILY, FC_STYLE);
     fs = FcFontList (0, pat, os);
     if (pat)
        FcPatternDestroy (pat);
@@ -116,8 +136,11 @@ main (int argc, char **argv)
        for (j = 0; j < fs->nfont; j++)
        {
            FcChar8 *font;
+           FcChar8 *file;
 
            font = FcNameUnparse (fs->fonts[j]);
+           if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch)
+               printf ("%s: ", file);
            printf ("%s\n", font);
            free (font);
        }