Patch: prefer cache files in /var/cache/fontconfig over <dir>/fonts.cache-2

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

 



Takashi made a patch to prefer the cache files in
/var/cache/fontconfig over cache files in the directories where
the fonts are.

The current behaviour is the opposite, i.e. the fonts.cache-2 files
in the directories where the fonts are are preferred.

We think it is better to prefer the caches in /var/cache/fontconfig
because the directories where the fonts are (e.g. /usr/share/fonts)
might be mounted readonly, maybe from some server via NFS.

If there is a problem with these cache files in the font directories,
there is Currently no way to fix the problem on a machine mounting
these directories readonly.

/var/cache/fontconfig should be writeable, therefore one can create
good caches by calling "fc-cache -f". But this won't help if the
because the broken cache files cannot be removed from the readonly
file system, the broken cache files are still preferred.

Because "fc-cache -f" can always create good caches in
/var/cache/fontconfig, the caches there should be preferred.

diff -ru fontconfig-2.3.93.20060210.orig/src/fccache.c fontconfig-2.3.93.20060210/src/fccache.c
--- fontconfig-2.3.93.20060210.orig/src/fccache.c	2006-02-10 13:06:08.000000000 +0100
+++ fontconfig-2.3.93.20060210/src/fccache.c	2006-02-10 17:43:09.000000000 +0100
@@ -1019,15 +1019,11 @@
     char	name_buf[FC_MAX_FILE_LEN];
     struct stat dir_stat;
 
-    cache_file = (char *)FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
-    if (!cache_file)
+    if (stat ((char *)dir, &dir_stat) == -1)
 	return -1;
 
-    fd = open(cache_file, O_RDONLY | O_BINARY);
-    if (fd != -1)
-	return fd;
-
-    if (stat ((char *)dir, &dir_stat) == -1)
+    cache_file = (char *)FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
+    if (!cache_file)
 	return -1;
 
     found = FcFalse;
@@ -1039,22 +1035,21 @@
 	cache_hashed = FcDirCacheHashName (cache_file, collisions++);
 	if (!cache_hashed)
 	{
+	    if (fd >= 0)
+		close (fd);
 	    FcStrFree ((FcChar8 *)cache_file);
 	    return -1;
 	}
 
-	if (fd > 0)
+	if (fd >= 0)
 	    close (fd);
 	fd = open(cache_hashed, O_RDONLY | O_BINARY);
 	FcStrFree ((FcChar8 *)cache_hashed);
 
 	if (fd == -1)
-	{
-	    FcStrFree ((FcChar8 *)cache_file);
-	    return -1;
-	}
+	    break;
 	if (!FcCacheReadString (fd, name_buf, sizeof (name_buf)) || !strlen(name_buf))
-	    goto bail;
+	    break;
 
 	name_buf_dir = FcStrDirname ((FcChar8 *)name_buf);
 	if (stat ((char *)name_buf_dir, &c) == -1)
@@ -1065,6 +1060,13 @@
 	FcStrFree (name_buf_dir);
 	found = (c.st_ino == dir_stat.st_ino) && (c.st_dev == dir_stat.st_dev);
     } while (!found);
+
+    if (! found || fd < 0) {
+	if (fd >= 0)
+	    close (fd);
+	fd = open(cache_file, O_RDONLY | O_BINARY );
+    }
+    
     FcStrFree ((FcChar8 *)cache_file);
     return fd;
 
-- 
Mike FABIAN   <mfabian@xxxxxxx>   http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。
_______________________________________________
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