fontconfig: Branch 'fc-2_4-keithp' - 2 commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 fc-cache/fc-cache.c     |    4 -
 fc-cat/fc-cat.c         |  119 +++++++++++++++++++++++++++++++++++++-----------
 fc-list/fc-list.c       |    2 
 fontconfig/fontconfig.h |   23 ++-------
 src/fccache.c           |   30 +++++++++---
 src/fcint.h             |    8 ++-
 6 files changed, 131 insertions(+), 55 deletions(-)

New commits:
diff-tree f57783d2e9c7362b1e5d5e3a967ba90fa49ade6e (from 0a87ce715e1862c56702f5be43af9f246aa34e68)
Author: Keith Packard <keithp@xxxxxxxxxxxxxxx>
Date:   Thu Aug 31 14:38:18 2006 -0700

    Revert ABI changes from version 2.3
    
    Accidental ABI changes and additions were discovered by looking at the
    differences in fontconfig.h. All of those have been reverted.

diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index cf4ea6c..5fc4092 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -227,7 +227,7 @@ scanDirs (FcStrList *list, FcConfig *con
 	    FcDirCacheUnlink (dir, config);
 
 	if (!force)
-	    was_valid = FcDirCacheValid (dir, config);
+	    was_valid = FcDirCacheValid (dir);
 	
 	if (!FcDirScanConfig (set, subdirs, FcConfigGetBlanks (config), dir, force, config))
 	{
@@ -249,7 +249,7 @@ scanDirs (FcStrList *list, FcConfig *con
 		printf ("caching, %d fonts, %d dirs\n", 
 			set->nfont, nsubdirs (subdirs));
 
-	    if (!FcDirCacheValid (dir, config))
+	    if (!FcDirCacheValid (dir))
 	    {
 		fprintf (stderr, "%s: failed to write cache\n", dir);
 		(void) FcDirCacheUnlink (dir, config);
diff --git a/fc-list/fc-list.c b/fc-list/fc-list.c
index d8a3364..b85dfd7 100644
--- a/fc-list/fc-list.c
+++ b/fc-list/fc-list.c
@@ -150,7 +150,7 @@ main (int argc, char **argv)
 	    FcChar8 *font;
 	    FcChar8 *file;
 
-	    font = FcNameUnparseEscaped (fs->fonts[j], FcFalse);
+	    font = FcNameUnparse (fs->fonts[j]);
 	    if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch)
 		printf ("%s: ", file);
 	    printf ("%s\n", font);
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 410da1e..feb781e 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -211,15 +211,15 @@ typedef struct _FcLangSet   FcLangSet;
 typedef struct _FcValue {
     FcType	type;
     union {
-	const FcChar8  *s;
+	const FcChar8	*s;
 	int		i;
 	FcBool		b;
 	double		d;
-	const FcMatrix  *m;
-	const FcCharSet *c;
+	const FcMatrix	*m;
+	const FcCharSet	*c;
 	void		*f;
 	const FcPattern	*p;
-	const FcLangSet *l;
+	const FcLangSet	*l;
     } u;
 } FcValue;
 
@@ -273,13 +273,7 @@ typedef struct _FcStrSet    FcStrSet;
 _FCFUNCPROTOBEGIN
 
 FcBool
-FcDirCacheValid (const FcChar8 *cache_file, FcConfig *config);
-
-FcBool
-FcDirCacheHasCurrentArch (const FcChar8 *dir, FcConfig *config);
-
-FcBool
-FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config);
+FcDirCacheValid (const FcChar8 *cache_file);
 
 /* fcblanks.c */
 FcBlanks *
@@ -325,10 +319,6 @@ FcConfigBuildFonts (FcConfig *config);
 FcStrList *
 FcConfigGetFontDirs (FcConfig   *config);
 
-const FcChar8 *
-FcConfigNormalizeFontDir (FcConfig  	*config, 
-			  const FcChar8 *d);
-
 FcStrList *
 FcConfigGetConfigDirs (FcConfig   *config);
 
@@ -665,9 +655,6 @@ FcNameParse (const FcChar8 *name);
 FcChar8 *
 FcNameUnparse (FcPattern *pat);
 
-FcChar8 *
-FcNameUnparseEscaped (FcPattern *pat, FcBool escape);
-
 /* fcpat.c */
 FcPattern *
 FcPatternCreate (void);
diff --git a/src/fccache.c b/src/fccache.c
index 378e39e..dd0896b 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -379,12 +379,24 @@ FcDirCacheValidate (int fd, off_t size, 
     return ret;
 }
 
-FcBool
-FcDirCacheValid (const FcChar8 *dir, FcConfig *config)
+static FcBool
+FcDirCacheValidConfig (const FcChar8 *dir, FcConfig *config)
 {
     return FcDirCacheProcess (config, dir, FcDirCacheValidate, NULL, NULL);
 }
 
+FcBool
+FcDirCacheValid (const FcChar8 *dir)
+{
+    FcConfig	*config;
+    
+    config = FcConfigGetCurrent ();
+    if (!config)
+        return FcFalse;
+
+    return FcDirCacheValidConfig (dir, config);
+}
+
 void
 FcDirCacheUnmap (FcCache *cache)
 {
diff --git a/src/fcint.h b/src/fcint.h
index 73d9331..0bc5df2 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -512,6 +512,9 @@ FcDirCacheMap (const FcChar8 *dir, FcCon
 FcBool
 FcDirCacheLoad (int fd, off_t size, void *closure);
     
+FcBool
+FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config);
+
 /* fccfg.c */
 
 FcBool
@@ -803,6 +806,9 @@ FcNameParseLangSet (const FcChar8 *strin
 FcBool
 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
 
+FcChar8 *
+FcNameUnparseEscaped (FcPattern *pat, FcBool escape);
+
 /* fclist.c */
 
 FcBool
diff-tree 0a87ce715e1862c56702f5be43af9f246aa34e68 (from d8ab9e6c42cb3513a6623df0c2866e1ebbd96485)
Author: Keith Packard <keithp@xxxxxxxxxxxxxxx>
Date:   Thu Aug 31 11:56:43 2006 -0700

    With no args, fc-cat now dumps all directories.
    
    Automatically list all font directories when no arguments are given to
    fc-cat. Also add -r option to recurse from specified cache directories.
    fc-cat also now prints the cache filename in verbose mode, along with the
    related directory name.

diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
index 63407e1..6074f1d 100644
--- a/fc-cat/fc-cat.c
+++ b/fc-cat/fc-cat.c
@@ -32,6 +32,7 @@
 #endif
 
 #include "../src/fccache.c"
+#include "../fc-arch/fcarch.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -53,6 +54,7 @@
 const struct option longopts[] = {
     {"version", 0, 0, 'V'},
     {"verbose", 0, 0, 'v'},
+    {"recurse", 0, 0, 'r'},
     {"help", 0, 0, '?'},
     {NULL,0,0,0},
 };
@@ -78,9 +80,6 @@ extern int optind, opterr, optopt;
 #define PUTC(c,f) putc(c,f)
 #endif
 
-FcBool
-FcCachePrintSet (FcFontSet *set, FcStrSet *dirs, char *base_name);
-
 static FcBool
 FcCacheWriteChars (FILE *f, const FcChar8 *chars)
 {
@@ -149,13 +148,15 @@ static void
 usage (char *program)
 {
 #if HAVE_GETOPT_LONG
-    fprintf (stderr, "usage: %s [-V?] [--version] [--help] <fonts.cache-2>\n",
-	     program);
+    fprintf (stderr, "usage: %s [-V?] [--version] [--help] {*-%s.cache-2|directory}...\n",
+	     program, FC_ARCHITECTURE);
 #else
-    fprintf (stderr, "usage: %s [-fsvV?] <fonts.cache-2>\n",
-	     program);
+    fprintf (stderr, "usage: %s [-fsvV?] {*-%s.cache-2|directory}...\n",
+	     program, FC_ARCHITECTURE);
 #endif
-    fprintf (stderr, "Reads font information caches in <fonts.cache-2>\n");
+    fprintf (stderr, "Reads font information cache from:\n"); 
+    fprintf (stderr, " 1) specified fontconfig cache file\n");
+    fprintf (stderr, " 2) related to a particular font directory\n");
     fprintf (stderr, "\n");
 #if HAVE_GETOPT_LONG
     fprintf (stderr, "  -V, --version        display font config version and exit\n");
@@ -201,7 +202,7 @@ FcFileBaseName (const char *cache, const
 }
 
 FcBool
-FcCachePrintSet (FcFontSet *set, FcStrSet *dirs, char *base_name)
+FcCachePrintSet (FcFontSet *set, FcStrSet *dirs, char *base_name, FcBool verbose)
 {
     FcPattern	    *font;
     FcChar8	    *name, *dir;
@@ -209,6 +210,7 @@ FcCachePrintSet (FcFontSet *set, FcStrSe
     int		    ret;
     int		    n;
     int		    id;
+    int		    ndir = 0;
     FcStrList	    *list;
 
     list = FcStrListCreate (dirs);
@@ -230,6 +232,7 @@ FcCachePrintSet (FcFontSet *set, FcStrSe
 	    goto bail3;
 	if (PUTC ('\n', stdout) == EOF)
 	    goto bail3;
+	ndir++;
     }
     
     for (n = 0; n < set->nfont; n++)
@@ -261,6 +264,8 @@ FcCachePrintSet (FcFontSet *set, FcStrSe
 	if (PUTC ('\n', stdout) == EOF)
 	    goto bail3;
     }
+    if (verbose && !set->nfont && !ndir)
+	printf ("<empty>\n");
     
     FcStrListDone (list);
 
@@ -286,12 +291,12 @@ FcCacheFileMap (const FcChar8 *file)
 	close (fd);
 	return NULL;
     }
-    if (FcCacheLoad (fd, file_stat.st_size, &cache)) {
+    if (!FcDirCacheLoad (fd, file_stat.st_size, &cache)) {
 	close (fd);
-	return cache;
+	return NULL;
     }
     close (fd);
-    return NULL;
+    return cache;
 }
 
 int
@@ -301,16 +306,21 @@ main (int argc, char **argv)
     int		ret = 0;
     FcFontSet	*fs;
     FcStrSet    *dirs;
+    FcStrSet	*args = NULL;
+    FcStrList	*arglist;
     FcCache	*cache;
     FcConfig	*config;
+    FcChar8	*arg;
     int		verbose = 0;
+    int		recurse = 0;
+    FcBool	first = FcTrue;
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
     int		c;
 
 #if HAVE_GETOPT_LONG
-    while ((c = getopt_long (argc, argv, "Vv?", longopts, NULL)) != -1)
+    while ((c = getopt_long (argc, argv, "Vvr?", longopts, NULL)) != -1)
 #else
-    while ((c = getopt (argc, argv, "Vv?")) != -1)
+    while ((c = getopt (argc, argv, "Vvr?")) != -1)
 #endif
     {
 	switch (c) {
@@ -321,6 +331,9 @@ main (int argc, char **argv)
 	case 'v':
 	    verbose++;
 	    break;
+	case 'r':
+	    recurse++;
+	    break;
 	default:
 	    usage (argv[0]);
 	}
@@ -338,22 +351,62 @@ main (int argc, char **argv)
     }
     FcConfigSetCurrent (config);
     
-    if (i >= argc)
-        usage (argv[0]);
+    args = FcStrSetCreate ();
+    if (!args)
+    {
+	fprintf (stderr, "%s: malloc failure\n", argv[0]);
+	return 1;
+    }
+    if (i < argc)
+    {
+	for (; i < argc; i++)
+	{
+	    if (!FcStrSetAdd (args, argv[i]))
+	    {
+		fprintf (stderr, "%s: malloc failure\n", argv[0]);
+		return 1;
+	    }
+	}
+	arglist = FcStrListCreate (args);
+	if (!arglist)
+	{
+	    fprintf (stderr, "%s: malloc failure\n", argv[0]);
+	    return 1;
+	}
+    }
+    else
+    {
+	recurse++;
+	arglist = FcConfigGetFontDirs (config);
+	while ((arg = FcStrListNext (arglist)))
+	    if (!FcStrSetAdd (args, arg))
+	    {
+		fprintf (stderr, "%s: malloc failure\n", argv[0]);
+		return 1;
+	    }
+	FcStrListDone (arglist);
+    }
+    arglist = FcStrListCreate (args);
+    if (!arglist)
+    {
+	fprintf (stderr, "%s: malloc failure\n", argv[0]);
+	return 1;
+    }
 
-    for (; i < argc; i++)
+    while ((arg = FcStrListNext (arglist)))
     {
-	int	j;
-	off_t	size;
-	intptr_t	*cache_dirs;
+	int	    j;
+	off_t	    size;
+	intptr_t    *cache_dirs;
+	FcChar8	    *cache_file = NULL;
 	
-	if (FcFileIsDir ((const FcChar8 *)argv[i]))
-	    cache = FcDirCacheMap ((const FcChar8 *) argv[i], config);
+	if (FcFileIsDir (arg))
+	    cache = FcDirCacheMap (arg, config, &cache_file);
 	else
-	    cache = FcCacheFileMap (argv[i]);
+	    cache = FcCacheFileMap (arg);
 	if (!cache)
 	{
-	    perror (argv[i]);
+	    perror ((char *) arg);
 	    ret++;
 	    continue;
 	}
@@ -362,17 +415,31 @@ main (int argc, char **argv)
 	fs = FcCacheSet (cache);
 	cache_dirs = FcCacheDirs (cache);
 	for (j = 0; j < cache->dirs_count; j++) 
+	{
 	    FcStrSetAdd (dirs, FcOffsetToPtr (cache_dirs,
 					      cache_dirs[j],
 					      FcChar8));
+	    if (recurse)
+		FcStrSetAdd (args, FcOffsetToPtr (cache_dirs,
+					      cache_dirs[j],
+					      FcChar8));
+	}
 
 	if (verbose)
-	    printf ("Name: %s\nDirectory: %s\n", argv[i], FcCacheDir(cache));
-        FcCachePrintSet (fs, dirs, FcCacheDir (cache));
+	{
+	    if (!first)
+		printf ("\n");
+	    printf ("Directory: %s\nCache: %s\n--------\n",
+		    FcCacheDir(cache), cache_file ? cache_file : arg);
+	    first = FcFalse;
+	}
+        FcCachePrintSet (fs, dirs, FcCacheDir (cache), verbose);
 
 	FcStrSetDestroy (dirs);
 
 	FcDirCacheUnmap (cache);
+	if (cache_file)
+	    FcStrFree (cache_file);
     }
 
     return 0;
diff --git a/src/fccache.c b/src/fccache.c
index 5012581..378e39e 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -197,7 +197,7 @@ FcCacheRead (FcConfig *config)
 static FcBool
 FcDirCacheProcess (FcConfig *config, const FcChar8 *dir, 
 		   FcBool (*callback) (int fd, off_t size, void *closure),
-		   void *closure)
+		   void *closure, FcChar8 **cache_file_ret)
 {
     int		fd = -1;
     FcChar8	cache_base[CACHEBASE_LEN];
@@ -221,7 +221,6 @@ FcDirCacheProcess (FcConfig *config, con
         if (!cache_hashed)
 	    break;
         fd = open((char *) cache_hashed, O_RDONLY | O_BINARY);
-	FcStrFree (cache_hashed);
         if (fd >= 0) {
 	    if (fstat (fd, &file_stat) >= 0 &&
 		dir_stat.st_mtime <= file_stat.st_mtime)
@@ -229,12 +228,17 @@ FcDirCacheProcess (FcConfig *config, con
 		ret = (*callback) (fd, file_stat.st_size, closure);
 		if (ret)
 		{
+		    if (cache_file_ret)
+			*cache_file_ret = cache_hashed;
+		    else
+			FcStrFree (cache_hashed);
 		    close (fd);
 		    break;
 		}
 	    }
 	    close (fd);
 	}
+    	FcStrFree (cache_hashed);
     }
     FcStrListDone (list);
     
@@ -303,13 +307,13 @@ FcDirCacheLoad (int fd, off_t size, void
 }
 
 FcCache *
-FcDirCacheMap (const FcChar8 *dir, FcConfig *config)
+FcDirCacheMap (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file)
 {
     FcCache *cache = NULL;
 
     if (!FcDirCacheProcess (config, dir,
 			    FcDirCacheLoad,
-			    &cache))
+			    &cache, cache_file))
 	return NULL;
     return cache;
 }
@@ -324,7 +328,7 @@ FcDirCacheRead (FcFontSet * set, FcStrSe
     intptr_t	*cache_dirs;
     FcPattern   **cache_fonts;
 
-    cache = FcDirCacheMap (dir, config);
+    cache = FcDirCacheMap (dir, config, NULL);
     if (!cache)
 	return FcFalse;
     
@@ -378,7 +382,7 @@ FcDirCacheValidate (int fd, off_t size, 
 FcBool
 FcDirCacheValid (const FcChar8 *dir, FcConfig *config)
 {
-    return FcDirCacheProcess (config, dir, FcDirCacheValidate, NULL);
+    return FcDirCacheProcess (config, dir, FcDirCacheValidate, NULL, NULL);
 }
 
 void
diff --git a/src/fcint.h b/src/fcint.h
index f95bb47..73d9331 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -507,7 +507,7 @@ FcBool
 FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir, FcConfig *config);
  
 FcCache *
-FcDirCacheMap (const FcChar8 *dir, FcConfig *config);
+FcDirCacheMap (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file);
     
 FcBool
 FcDirCacheLoad (int fd, off_t size, void *closure);
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux