]> git.wh0rd.org - fontconfig.git/blobdiff - fc-list/fc-list.c
Prevent fc-list from escaping strings when printing them.
[fontconfig.git] / fc-list / fc-list.c
index 14feab07c245c9ca45f0c0934d0bd78cc08ae507..48fbb601449f206260e6342caa72ea8c84dea2d7 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $XFree86: xc/lib/fontconfig/fc-list/fc-list.c,v 1.2 2002/02/15 06:01:26 keithp Exp $
+ * $RCSId: xc/lib/fontconfig/fc-list/fc-list.c,v 1.5 2002/06/30 23:45:40 keithp Exp $
  *
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -61,14 +61,24 @@ extern int optind, opterr, optopt;
 
 static void usage (char *program)
 {
-    fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [dirs]\n",
+#if HAVE_GETOPT_LONG
+    fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [pattern] {element ...} \n",
+            program);
+#else
+    fprintf (stderr, "usage: %s [-vV?] [pattern] {element ...} \n",
             program);
-    fprintf (stderr, "Build font information caches in [dirs]\n"
-            "(all directories in font configuration by default).\n");
+#endif
+    fprintf (stderr, "List fonts matching [pattern]\n");
     fprintf (stderr, "\n");
+#if HAVE_GETOPT_LONG
     fprintf (stderr, "  -v, --verbose        display status information while busy\n");
     fprintf (stderr, "  -V, --version        display font config version and exit\n");
     fprintf (stderr, "  -?, --help           display this help and exit\n");
+#else
+    fprintf (stderr, "  -v         (verbose) display status information while busy\n");
+    fprintf (stderr, "  -V         (version) display font config version and exit\n");
+    fprintf (stderr, "  -?         (help)    display this help and exit\n");
+#endif
     exit (1);
 }
 
@@ -77,7 +87,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
@@ -112,11 +122,22 @@ main (int argc, char **argv)
        return 1;
     }
     if (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, (char *) 0);
     fs = FcFontList (0, pat, os);
+    FcObjectSetDestroy (os);
     if (pat)
        FcPatternDestroy (pat);
 
@@ -127,12 +148,18 @@ main (int argc, char **argv)
        for (j = 0; j < fs->nfont; j++)
        {
            FcChar8 *font;
+           FcChar8 *file;
 
-           font = FcNameUnparse (fs->fonts[j]);
+           font = FcNameUnparseEscaped (fs->fonts[j], FcFalse);
+           if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch)
+               printf ("%s: ", file);
            printf ("%s\n", font);
            free (font);
        }
        FcFontSetDestroy (fs);
     }
+
+    FcFini ();
+
     return 0;
 }