[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Wed Dec 24 01:53:48 PST 2014


 fc-cache/fc-cache.c    |   26 +++++++++++++++++---------
 fc-cache/fc-cache.sgml |   31 ++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 10 deletions(-)

New commits:
commit 456937cd15568c7f1a633445dee44ae8e2ed395f
Author: Akira TAGOH <akira at tagoh.org>
Date:   Wed Dec 24 18:53:41 2014 +0900

    fc-cache: Add an option to raise an error if no fonts found
    
    and get back the behavior.

diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index e85c9fc..18cd6c5 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -65,6 +65,7 @@
 #define _GNU_SOURCE
 #include <getopt.h>
 const struct option longopts[] = {
+    {"error-on-no-fonts", 0, 0, 'E'},
     {"force", 0, 0, 'f'},
     {"really-force", 0, 0, 'r'},
     {"sysroot", required_argument, 0, 'y'},
@@ -86,16 +87,17 @@ usage (char *program, int error)
 {
     FILE *file = error ? stderr : stdout;
 #if HAVE_GETOPT_LONG
-    fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
+    fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [--error-on-no-fonts] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
 	     program);
 #else
-    fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [dirs]\n",
+    fprintf (file, "usage: %s [-EfrsvVh] [-y SYSROOT] [dirs]\n",
 	     program);
 #endif
     fprintf (file, "Build font information caches in [dirs]\n"
 	     "(all directories in font configuration by default).\n");
     fprintf (file, "\n");
 #if HAVE_GETOPT_LONG
+    fprintf (file, "  -E, --error-on-no-fonts  raise an error if no fonts in a directory\n");
     fprintf (file, "  -f, --force              scan directories with apparently valid caches\n");
     fprintf (file, "  -r, --really-force       erase all existing caches, then rescan\n");
     fprintf (file, "  -s, --system-only        scan system-wide directories only\n");
@@ -104,6 +106,8 @@ usage (char *program, int error)
     fprintf (file, "  -V, --version            display font config version and exit\n");
     fprintf (file, "  -h, --help               display this help and exit\n");
 #else
+    fprintf (file, "  -E         (error-on-no-fonts)\n");
+    fprintf (file, "                       raise an error if no fonts in a directory\n");
     fprintf (file, "  -f         (force)   scan directories with apparently valid caches\n");
     fprintf (file, "  -r,   (really force) erase all existing caches, then rescan\n");
     fprintf (file, "  -s         (system)  scan system-wide directories only\n");
@@ -118,7 +122,7 @@ usage (char *program, int error)
 static FcStrSet *processed_dirs;
 
 static int
-scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool recursive, int *changed, FcStrSet *updateDirs)
+scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool recursive, FcBool error_on_no_fonts, int *changed, FcStrSet *updateDirs)
 {
     int		    ret = 0;
     const FcChar8   *dir;
@@ -251,13 +255,13 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
 		continue;
 	    }
 	    FcStrSetAdd (processed_dirs, dir);
-	    ret += scanDirs (sublist, config, force, really_force, verbose, recursive, changed, updateDirs);
+	    ret += scanDirs (sublist, config, force, really_force, verbose, recursive, error_on_no_fonts, changed, updateDirs);
 	    FcStrListDone (sublist);
 	}
 	else
 	    FcDirCacheUnload (cache);
     }
-    if (!was_processed)
+    if (error_on_no_fonts && !was_processed)
 	ret++;
     return ret;
 }
@@ -292,6 +296,7 @@ main (int argc, char **argv)
     FcBool	force = FcFalse;
     FcBool	really_force = FcFalse;
     FcBool	systemOnly = FcFalse;
+    FcBool	error_on_no_fonts = FcFalse;
     FcConfig	*config;
     FcChar8     *sysroot = NULL;
     int		i;
@@ -301,12 +306,15 @@ main (int argc, char **argv)
     int		c;
 
 #if HAVE_GETOPT_LONG
-    while ((c = getopt_long (argc, argv, "frsy:Vvh", longopts, NULL)) != -1)
+    while ((c = getopt_long (argc, argv, "Efrsy:Vvh", longopts, NULL)) != -1)
 #else
-    while ((c = getopt (argc, argv, "frsy:Vvh")) != -1)
+    while ((c = getopt (argc, argv, "Efrsy:Vvh")) != -1)
 #endif
     {
 	switch (c) {
+	case 'E':
+	    error_on_no_fonts = FcTrue;
+	    break;
 	case 'r':
 	    really_force = FcTrue;
 	    /* fall through */
@@ -387,13 +395,13 @@ main (int argc, char **argv)
 
     updateDirs = FcStrSetCreate ();
     changed = 0;
-    ret = scanDirs (list, config, force, really_force, verbose, FcTrue, &changed, updateDirs);
+    ret = scanDirs (list, config, force, really_force, verbose, FcTrue, error_on_no_fonts, &changed, updateDirs);
     /* Update the directory cache again to avoid the race condition as much as possible */
     FcStrListDone (list);
     list = FcStrListCreate (updateDirs);
     if (list)
     {
-	ret += scanDirs (list, config, FcTrue, FcFalse, verbose, FcFalse, &changed, NULL);
+	ret += scanDirs (list, config, FcTrue, FcFalse, verbose, FcFalse, error_on_no_fonts, &changed, NULL);
 	FcStrListDone (list);
     }
     FcStrSetDestroy (updateDirs);
diff --git a/fc-cache/fc-cache.sgml b/fc-cache/fc-cache.sgml
index 3740be7..7e5159b 100644
--- a/fc-cache/fc-cache.sgml
+++ b/fc-cache/fc-cache.sgml
@@ -63,9 +63,14 @@ manpage.1: manpage.sgml
     <cmdsynopsis>
       <command>&dhpackage;</command>
 
-      <arg><option>-frsvVh</option></arg>
+      <arg><option>-EfrsvVh</option></arg>
+      <arg><option>--error-on-no-fonts</option></arg>
       <arg><option>--force</option></arg>
       <arg><option>--really-force</option></arg>
+      <group>
+	<arg><option>-y</option> <option><replaceable>dir</replaceable></option></arg>
+	<arg><option>--sysroot</option> <option><replaceable>dir</replaceable></option></arg>
+      </group>
       <arg><option>--system-only</option></arg>
       <arg><option>--verbose</option></arg>
       <arg><option>--version</option></arg>
@@ -103,6 +108,16 @@ manpage.1: manpage.sgml
 
     <variablelist>
       <varlistentry>
+	<term><option>-E</option>
+	  <option>--error-on-no-fonts</option>
+	</term>
+	<listitem>
+	  <para>Raise an error if there are no fonts in
+	    <option><replaceable>dir</replaceable></option> or directories
+	    in the configuration if not given.</para>
+	</listitem>
+      </varlistentry>
+      <varlistentry>
         <term><option>-f</option>
           <option>--force</option>
         </term>
@@ -137,6 +152,15 @@ manpage.1: manpage.sgml
         </listitem>
       </varlistentry>
       <varlistentry>
+	<term><option>-y</option>
+	  <option>-sysroot</option>
+	  <option><replaceable>dir</replaceable></option>
+	</term>
+	<listitem>
+	  <para>Prepend <option><replaceable>dir</replaceable></option> to all paths for scanning.</para>
+	</listitem>
+      </varlistentry>
+      <varlistentry>
         <term><option>-h</option>
           <option>--help</option>
         </term>
@@ -163,6 +187,11 @@ manpage.1: manpage.sgml
   </refsect1>
 
   <refsect1>
+    <title>RETURN CODES</title>
+    <para><command>fc-cache</command> returns zero if the caches successfully generated. otherwise non-zero.</para>
+  </refsect1>
+  
+  <refsect1>
     <title>FILES</title>
     <variablelist>
       <varlistentry>


More information about the Fontconfig mailing list