From: Behdad Esfahbod Date: Fri, 16 Jan 2009 00:12:37 +0000 (-0500) Subject: [fc-match] Accept list of elements like fc-list (bug #13017) X-Git-Tag: 2.7.0~130 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=41af588f543ca5c0efaeb699992376d89cb35763;p=fontconfig.git [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. --- diff --git a/fc-list/fc-list.c b/fc-list/fc-list.c index f7a66b5..470b4b9 100644 --- a/fc-list/fc-list.c +++ b/fc-list/fc-list.c @@ -76,13 +76,13 @@ usage (char *program, int error) fprintf (file, "List fonts matching [pattern]\n"); fprintf (file, "\n"); #if HAVE_GETOPT_LONG - 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, " -q, --quiet suppress all normal output, exit 1 if no fonts matched\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, " -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, " -q, (quiet) suppress all normal output, exit 1 if no fonts matched\n"); fprintf (file, " -V (version) display font config version and exit\n"); @@ -144,13 +144,12 @@ main (int argc, char **argv) if (argv[i]) { pat = FcNameParse ((FcChar8 *) argv[i]); - if (!verbose) - while (argv[++i]) - { - if (!os) - os = FcObjectSetCreate (); - FcObjectSetAdd (os, argv[i]); - } + while (argv[++i]) + { + if (!os) + os = FcObjectSetCreate (); + FcObjectSetAdd (os, argv[i]); + } } else pat = FcPatternCreate (); @@ -170,9 +169,6 @@ main (int argc, char **argv) for (j = 0; j < fs->nfont; j++) { - FcChar8 *font; - FcChar8 *file; - if (verbose) { FcPatternPrint (fs->fonts[j]); @@ -187,11 +183,14 @@ main (int argc, char **argv) } else { - font = FcNameUnparse (fs->fonts[j]); + FcChar8 *str; + FcChar8 *file; + + str = FcNameUnparse (fs->fonts[j]); if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) printf ("%s: ", file); - printf ("%s\n", font); - free (font); + printf ("%s\n", str); + free (str); } } } diff --git a/fc-list/fc-list.sgml b/fc-list/fc-list.sgml index cc98779..ffa0891 100644 --- a/fc-list/fc-list.sgml +++ b/fc-list/fc-list.sgml @@ -81,9 +81,9 @@ manpage.1: manpage.sgml &dhpackage; lists fonts and styles available on the system for applications using fontconfig. - With , the whole font pattern - for each font is printed, otherwise only the elements requested - are printed (family and style if none provided). + If any elements are specified, only those are printed. + Otherwise family and style are printed, unless verbose + output is requested. OPTIONS @@ -98,9 +98,9 @@ manpage.1: manpage.sgml - Print whole font pattern for each match. Provided - elements are ignored in this - case. + Print verbose output of the whole font pattern for each match, + or elements if any is + provided. 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. +