]> git.wh0rd.org - fontconfig.git/blobdiff - fc-match/fc-match.c
FcStrPathPlus: new helper function
[fontconfig.git] / fc-match / fc-match.c
index 86ff25387b09e02b4a085927ee99dc8092126027..ca7eee0c0dd4462386714729f2299cb24e648b50 100644 (file)
@@ -7,15 +7,15 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
+ * documentation, and that the name of the author(s) not be used in
  * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
+ * specific, written prior permission.  The authors make no
  * representations about the suitability of this software for any purpose.  It
  * is provided "as is" without express or implied warranty.
  *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
@@ -98,16 +98,16 @@ usage (char *program, int error)
 int
 main (int argc, char **argv)
 {
-    int                verbose = 0;
-    int                sort = 0, all = 0;
-    FcChar8     *format = NULL;
-    int                i;
-    FcObjectSet *os = 0;
-    FcFontSet  *fs;
-    FcPattern   *pat;
-    FcResult   result;
+    int                        verbose = 0;
+    int                        sort = 0, all = 0;
+    const FcChar8      *format = NULL;
+    int                        i;
+    FcObjectSet                *os = 0;
+    FcFontSet          *fs;
+    FcPattern          *pat;
+    FcResult           result;
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
-    int                c;
+    int                        c;
 
 #if HAVE_GETOPT_LONG
     while ((c = getopt_long (argc, argv, "asvf:Vh", longopts, NULL)) != -1)
@@ -195,6 +195,14 @@ main (int argc, char **argv)
     }
     FcPatternDestroy (pat);
 
+    if (!format)
+    {
+       if (os)
+           format = (const FcChar8 *) "%{=unparse}\n";
+       else
+           format = (const FcChar8 *) "%{=fcmatch}\n";
+    }
+
     if (fs)
     {
        int     j;
@@ -209,7 +217,7 @@ main (int argc, char **argv)
            {
                FcPatternPrint (font);
            }
-           else if (format)
+           else
            {
                FcChar8 *s;
 
@@ -220,34 +228,6 @@ main (int argc, char **argv)
                    free (s);
                }
            }
-           else if (os)
-           {
-               FcChar8 *str;
-               str = FcNameUnparse (font);
-               printf ("%s\n", str);
-               free (str);
-           }
-           else
-           {
-               FcChar8 *family;
-               FcChar8 *style;
-               FcChar8 *file;
-
-               if (FcPatternGetString (font, FC_FILE, 0, &file) != FcResultMatch)
-                   file = (FcChar8 *) "<unknown filename>";
-               else
-               {
-                   FcChar8 *slash = (FcChar8 *) strrchr ((char *) file, '/');
-                   if (slash)
-                       file = slash+1;
-               }
-               if (FcPatternGetString (font, FC_FAMILY, 0, &family) != FcResultMatch)
-                   family = (FcChar8 *) "<unknown family>";
-               if (FcPatternGetString (font, FC_STYLE, 0, &style) != FcResultMatch)
-                   style = (FcChar8 *) "<unknown style>";
-
-               printf ("%s: \"%s\" \"%s\"\n", file, family, style);
-           }
 
            FcPatternDestroy (font);
        }