summaryrefslogtreecommitdiff
path: root/fc-match
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-01-15 19:12:37 -0500
committerBehdad Esfahbod <behdad@behdad.org>2009-02-13 16:54:07 -0800
commit41af588f543ca5c0efaeb699992376d89cb35763 (patch)
treefdc8473b31d51e8fdb61cffc7c763485831ac1e8 /fc-match
parent263f16ced279b0c09834bb4ca0df87fd0f76dcaf (diff)
[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.
Diffstat (limited to 'fc-match')
-rw-r--r--fc-match/fc-match.c48
-rw-r--r--fc-match/fc-match.sgml29
2 files changed, 57 insertions, 20 deletions
diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c
index c4029054..6f3d2dc8 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 *) "<unknown filename>";
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 *) "<unknown family>";
- if (FcPatternGetString (fs->fonts[j], FC_STYLE, 0, &style) != FcResultMatch)
+ if (FcPatternGetString (font, FC_STYLE, 0, &style) != FcResultMatch)
style = (FcChar8 *) "<unknown style>";
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 8c710330..86e6b46b 100644
--- a/fc-match/fc-match.sgml
+++ b/fc-match/fc-match.sgml
@@ -73,7 +73,8 @@ manpage.1: manpage.sgml
</group>
<arg><option>--version</option></arg>
<arg><option>--help</option></arg>
- <arg><option><replaceable>font-pattern</replaceable></option></arg>
+ <sbr>
+ <arg><option><replaceable>pattern</replaceable></option> <arg rep="repeat"><option><replaceable>element</replaceable></option></arg> </arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -81,14 +82,15 @@ manpage.1: manpage.sgml
<title>DESCRIPTION</title>
<para><command>&dhpackage;</command> matches
- <replaceable>font-pattern</replaceable> (empty
+ <replaceable>pattern</replaceable> (empty
pattern by default) using the normal fontconfig matching rules to find
the best font available. If <option>--sort</option> is given, the sorted list of best
-matching fonts is displayed. With <option>--verbose</option>, the whole font pattern
-for each match is printed, otherwise only the file, family and style
-are printed. The <option>--all</option> option works like
+matching fonts is displayed.
+The <option>--all</option> option works like
<option>--sort</option> except that no pruning is done on the list of fonts.</para>
-
+If any elements are specified, only those are printed.
+Otherwise short file name, family, and style are printed, unless verbose
+output is requested.</para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
@@ -120,7 +122,9 @@ are printed. The <option>--all</option> option works like
<option>--verbose</option>
</term>
<listitem>
- <para>Print whole font pattern for each match.</para>
+ <para>Print verbose output of the whole font pattern for each match,
+ or <replaceable>element</replaceable>s if any is
+ provided.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -150,13 +154,20 @@ are printed. The <option>--all</option> option works like
</listitem>
</varlistentry>
<varlistentry>
- <term><option><replaceable>font-pattern</replaceable></option>
+ <term><option><replaceable>pattern</replaceable></option>
</term>
<listitem>
<para>Displays fonts matching
- <replaceable>font-pattern</replaceable> (uses empty pattern by default).</para>
+ <replaceable>pattern</replaceable> (uses empty pattern by default).</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option><replaceable>element</replaceable></option>
+ </term>
+ <listitem>
+ <para>If set, the <replaceable>element</replaceable> property
+ is displayed for matching fonts.</para>
+ </listitem>
</variablelist>
</refsect1>