From 41af588f543ca5c0efaeb699992376d89cb35763 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 15 Jan 2009 19:12:37 -0500 Subject: [fc-match] Accept list of elements like fc-list (bug #13017) Also make --verbose not ignore list of elements and only print those. Update docs. --- fc-match/fc-match.c | 48 +++++++++++++++++++++++++++++++++++++----------- fc-match/fc-match.sgml | 29 ++++++++++++++++++++--------- 2 files changed, 57 insertions(+), 20 deletions(-) (limited to 'fc-match') diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c index c402905..6f3d2dc 100644 --- a/fc-match/fc-match.c +++ b/fc-match/fc-match.c @@ -69,25 +69,25 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-savVh] [-f FORMAT] [--sort] [--all] [--verbose] [--format=FORMAT] [--version] [--help] [pattern]\n", + fprintf (file, "usage: %s [-savVh] [-f FORMAT] [--sort] [--all] [--verbose] [--format=FORMAT] [--version] [--help] [pattern] {element...}\n", program); #else - fprintf (file, "usage: %s [-savVh] [-f FORMAT] [pattern]\n", + fprintf (file, "usage: %s [-savVh] [-f FORMAT] [pattern] {element...}\n", program); #endif - fprintf (file, "List fonts matching [pattern]\n"); + fprintf (file, "List best font matching [pattern]\n"); fprintf (file, "\n"); #if HAVE_GETOPT_LONG fprintf (file, " -s, --sort display sorted list of matches\n"); fprintf (file, " -a, --all display unpruned sorted list of matches\n"); - fprintf (file, " -v, --verbose display entire font pattern\n"); + fprintf (file, " -v, --verbose display entire font pattern verbosely\n"); fprintf (file, " -f, --format=FORMAT use the given output format\n"); fprintf (file, " -V, --version display font config version and exit\n"); fprintf (file, " -h, --help display this help and exit\n"); #else fprintf (file, " -s, (sort) display sorted list of matches\n"); fprintf (file, " -a (all) display unpruned sorted list of matches\n"); - fprintf (file, " -v (verbose) display entire font pattern\n"); + fprintf (file, " -v (verbose) display entire font pattern verbosely\n"); fprintf (file, " -f FORMAT (format) use the given output format\n"); fprintf (file, " -V (version) display font config version and exit\n"); fprintf (file, " -h (help) display this help and exit\n"); @@ -102,6 +102,7 @@ main (int argc, char **argv) int sort = 0, all = 0; FcChar8 *format = NULL; int i; + FcObjectSet *os = 0; FcFontSet *fs; FcPattern *pat; FcResult result; @@ -148,7 +149,15 @@ 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 (); @@ -192,25 +201,35 @@ main (int argc, char **argv) for (j = 0; j < fs->nfont; j++) { + FcPattern *font; + + font = FcPatternFilter (fs->fonts[j], os); + if (verbose) { - FcPatternPrint (fs->fonts[j]); + FcPatternPrint (font); } else if (format) { FcChar8 *s; - s = FcPatternFormat (fs->fonts[j], format); - printf ("%s", s); + s = FcPatternFormat (font, format); 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 (fs->fonts[j], FC_FILE, 0, &file) != FcResultMatch) + if (FcPatternGetString (font, FC_FILE, 0, &file) != FcResultMatch) file = (FcChar8 *) ""; else { @@ -218,16 +237,23 @@ main (int argc, char **argv) if (slash) file = slash+1; } - if (FcPatternGetString (fs->fonts[j], FC_FAMILY, 0, &family) != FcResultMatch) + if (FcPatternGetString (font, FC_FAMILY, 0, &family) != FcResultMatch) family = (FcChar8 *) ""; - if (FcPatternGetString (fs->fonts[j], FC_STYLE, 0, &style) != FcResultMatch) + if (FcPatternGetString (font, FC_STYLE, 0, &style) != FcResultMatch) style = (FcChar8 *) ""; printf ("%s: \"%s\" \"%s\"\n", file, family, style); } + + FcPatternDestroy (font); } FcFontSetDestroy (fs); } + + if (os) + FcObjectSetDestroy (os); + FcFini (); + return 0; } diff --git a/fc-match/fc-match.sgml b/fc-match/fc-match.sgml index 8c71033..86e6b46 100644 --- a/fc-match/fc-match.sgml +++ b/fc-match/fc-match.sgml @@ -73,7 +73,8 @@ manpage.1: manpage.sgml - + + @@ -81,14 +82,15 @@ manpage.1: manpage.sgml DESCRIPTION &dhpackage; matches - font-pattern (empty + pattern (empty pattern by default) using the normal fontconfig matching rules to find the best font available. If is given, the sorted list of best -matching fonts is displayed. With , the whole font pattern -for each match is printed, otherwise only the file, family and style -are printed. The option works like +matching fonts is displayed. +The option works like except that no pruning is done on the list of fonts. - +If any elements are specified, only those are printed. +Otherwise short file name, family, and style are printed, unless verbose +output is requested. OPTIONS @@ -120,7 +122,9 @@ are printed. The option works like - Print whole font pattern for each match. + Print verbose output of the whole font pattern for each match, + or elements if any is + provided. @@ -150,13 +154,20 @@ are printed. The option works like - + Displays fonts matching - font-pattern (uses empty pattern by default). + pattern (uses empty pattern by default). + + + + + If set, the element property + is displayed for matching fonts. + -- cgit v1.2.3