diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2008-12-29 20:00:26 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2009-02-13 16:54:04 -0800 |
commit | 0c93b91db0cdf7c5e901477c266b45c8baeadd00 (patch) | |
tree | fd3df21df4f20d88a9af8426533fcb0ed542541a /fc-query | |
parent | 5cf04b201fb5e9dc989d30cf5c30f7575dda56bc (diff) |
Implement FcPatternFormat and use it in cmdline tools (bug #17107)
Still need to add more features, but the API is there, and used
by cmdline tools with -f or --format.
Diffstat (limited to 'fc-query')
-rw-r--r-- | fc-query/fc-query.c | 25 | ||||
-rw-r--r-- | fc-query/fc-query.sgml | 36 |
2 files changed, 48 insertions, 13 deletions
diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c index 6ea45ea5..8fec7d47 100644 --- a/fc-query/fc-query.c +++ b/fc-query/fc-query.c @@ -53,6 +53,7 @@ #include <getopt.h> static const struct option longopts[] = { {"index", 1, 0, 'i'}, + {"format", 1, 0, 'f'}, {"version", 0, 0, 'V'}, {"help", 0, 0, 'h'}, {NULL,0,0,0}, @@ -69,20 +70,22 @@ usage (char *program, int error) { FILE *file = error ? stderr : stdout; #if HAVE_GETOPT_LONG - fprintf (file, "usage: %s [-Vh] [-i index] [--index index] [--version] [--help] font-file...\n", + fprintf (file, "usage: %s [-Vh] [-i index] [-f FORMAT] [--index index] [--format FORMAT] [--version] [--help] font-file...\n", program); #else - fprintf (file, "usage: %s [-Vh] [-i index] font-file...\n", + fprintf (file, "usage: %s [-Vh] [-i index] [-f FORMAT] font-file...\n", program); #endif fprintf (file, "Query font files and print resulting pattern(s)\n"); fprintf (file, "\n"); #if HAVE_GETOPT_LONG fprintf (file, " -i, --index INDEX display the INDEX face of each font file only\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, " -i INDEX (index) display the INDEX face of each font file only\n"); + fprintf (file, " -f FORMAT (format) use the given output format\n"); fprintf (file, " -a (all) display unpruned sorted list of matches\n"); fprintf (file, " -V (version) display font config version and exit\n"); fprintf (file, " -h (help) display this help and exit\n"); @@ -95,6 +98,7 @@ main (int argc, char **argv) { int index_set = 0; int set_index = 0; + FcChar8 *format = NULL; int err = 0; int i; FcBlanks *blanks; @@ -112,6 +116,9 @@ main (int argc, char **argv) index_set = 1; set_index = atoi (optarg); break; + case 'f': + format = (FcChar8 *) strdup (optarg); + break; case 'V': fprintf (stderr, "fontconfig version %d.%d.%d\n", FC_MAJOR, FC_MINOR, FC_REVISION); @@ -151,7 +158,19 @@ main (int argc, char **argv) pat = FcFreeTypeQuery ((FcChar8 *) argv[i], index, blanks, &count); if (pat) { - FcPatternPrint (pat); + if (format) + { + FcChar8 *s; + + s = FcPatternFormat (pat, format); + printf ("%s", s); + free (s); + } + else + { + FcPatternPrint (pat); + } + FcPatternDestroy (pat); } else diff --git a/fc-query/fc-query.sgml b/fc-query/fc-query.sgml index 2c731291..e363db51 100644 --- a/fc-query/fc-query.sgml +++ b/fc-query/fc-query.sgml @@ -63,13 +63,17 @@ manpage.1: manpage.sgml <command>&dhpackage;</command> <arg><option>-Vh</option></arg> - <arg><option>--version</option></arg> - <arg><option>--help</option></arg> <sbr> <group> <arg><option>-i</option> <option><replaceable>index</replaceable></option></arg> <arg><option>--index</option> <option><replaceable>index</replaceable></option></arg> </group> + <group> + <arg><option>-f</option> <option><replaceable>format</replaceable></option></arg> + <arg><option>--format</option> <option><replaceable>format</replaceable></option></arg> + </group> + <arg><option>--version</option></arg> + <arg><option>--help</option></arg> <arg choice="req" rep="repeat"><option><replaceable>font-file</replaceable></option></arg> </cmdsynopsis> @@ -93,11 +97,23 @@ manpage.1: manpage.sgml <variablelist> <varlistentry> - <term><option>-h</option> - <option>--help</option> + <term><option>-i</option> + <option>--index</option> + <option><replaceable>index</replaceable></option> </term> <listitem> - <para>Show summary of options.</para> + <para>Only query face indexed <replaceable>index</replaceable> of + each file.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-f</option> + <option>--format</option> + <option><replaceable>format</replaceable></option> + </term> + <listitem> + <para>Format output according to the format specifier + <replaceable>format</replaceable>.</para> </listitem> </varlistentry> <varlistentry> @@ -109,13 +125,11 @@ manpage.1: manpage.sgml </listitem> </varlistentry> <varlistentry> - <term><option>-i</option> - <option>--index</option> - <option><replaceable>index</replaceable></option> + <term><option>-h</option> + <option>--help</option> </term> <listitem> - <para>Only query face indexed <replaceable>index</replaceable> of - each file.</para> + <para>Show summary of options.</para> </listitem> </varlistentry> <varlistentry> @@ -142,6 +156,8 @@ manpage.1: manpage.sgml <command>fc-cache</command>(1) <command>fc-list</command>(1) <command>fc-match</command>(1) + <function>FcFreeTypeQuery</function>(3) + <function>FcPatternFormat</function>(3) </para> <para>The fontconfig user's guide, in HTML format: |