From 7410e40bd93beb4ab1a577d084112413431cede2 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Fri, 4 Aug 2006 16:13:00 +0000 Subject: [PATCH] 2006-08-04 Keith Packard (keithp@keithp.com) reviewed by: plam Make cache directories configurable. Simplify and correct some code which deals with per-directory caches. --- ChangeLog | 24 +++ configure.in | 22 ++- fc-cache/fc-cache.c | 7 +- fontconfig/fontconfig.h | 4 +- fonts.conf.in | 5 + fonts.dtd | 12 ++ src/Makefile.am | 3 +- src/fccache.c | 323 ++++++++++++++++++++-------------------- src/fccfg.c | 28 +++- src/fcdir.c | 6 +- src/fcinit.c | 2 + src/fcint.h | 13 +- src/fcxml.c | 17 +++ test/fonts.conf.in | 1 + test/run-test.sh | 6 +- 15 files changed, 294 insertions(+), 179 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8e6404..5e4b1f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2006-08-04 Keith Packard (keithp@keithp.com) + reviewed by: plam + + * configure.in: + * fonts.conf.in: + * fonts.dtd: + * fc-cache/fc-cache.c (scanDirs): + * fontconfig/fontconfig.h: + * src/Makefile.am: + * src/fcint.h: + * src/fccache.c (FcDirCacheValid, FcDirHasCurrentArch, + FcDirCacheUnlink, FcDirCacheBasename, + FcCacheReadDirs, FcDirCacheOpen, FcDirCacheRead, + FcMakeDirectory, FcDirCacheWrite): + * src/fccfg.c (FcConfigCreate, FcConfigDestroy, FcConfigAddCacheDir, + FcConfigGetCacheDirs): + * src/fcdir.c (FcDirScanConfig, FcDirSave): + * src/fcinit.c (FcInitFallbackConfig): + * src/fcxml.c (fcElementMap, FcEndElement): + * test/fonts.conf.in, test/run-test.sh: + + Make cache directories configurable. Simplify and correct + some code which deals with per-directory caches. + 2006-07-19 Jon Burgess (jburgess@uklinux.net) reviewed by: plam diff --git a/configure.in b/configure.in index acdc1f1..a3d2c77 100644 --- a/configure.in +++ b/configure.in @@ -431,6 +431,22 @@ esac AC_SUBST(FC_FONTPATH) +# +# Set default cache directory path +# +AC_ARG_WITH(cache-dir, [ --with-cache-dir=DIR Use DIR to store cache files (default /var/cache/fontconfig)], fc_cachedir="$withval", fc_cachedir=yes) + +case $fc_cachedir in +no|yes) + fc_cachedir=`eval echo "${localstatedir}/cache/"${PACKAGE}` + ;; +*) + ;; +esac +AC_SUBST(fc_cachedir) +FC_CACHEDIR=${fc_cachedir} +AC_SUBST(FC_CACHEDIR) + FC_FONTDATE=`LC_ALL=C date` AC_SUBST(FC_FONTDATE) @@ -516,12 +532,6 @@ fi AC_SUBST(DOCDIR) -# -# Make /var/cache/fontconfig directory available to source code -# - -pkgcachedir='${localstatedir}/cache/'${PACKAGE} -AC_SUBST(pkgcachedir) AC_OUTPUT([ Makefile diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c index 5e4ada4..8519388 100644 --- a/fc-cache/fc-cache.c +++ b/fc-cache/fc-cache.c @@ -230,7 +230,8 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool ret++; continue; } - if (!force && FcDirCacheValid (dir) && FcDirCacheHasCurrentArch (dir)) + if (!force && FcDirCacheValid (dir, config) && + FcDirCacheHasCurrentArch (dir, config)) { if (verbose) printf ("skipping, %d fonts, %d dirs\n", @@ -244,14 +245,12 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool /* This is the only reason we can't combine * Valid w/HasCurrentArch... */ - if (!FcDirCacheValid (dir)) + if (!FcDirCacheValid (dir, config)) if (!FcDirCacheUnlink (dir, config)) ret++; if (!FcDirSave (set, subdirs, dir)) { - if (!ret) - fprintf (stderr, "Caches are currently saved to \"%s\"\n", PKGCACHEDIR); fprintf (stderr, "Can't save cache for \"%s\"\n", dir); ret++; } diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 2ddd42f..8ef2f7c 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -276,10 +276,10 @@ typedef struct _FcStrSet FcStrSet; _FCFUNCPROTOBEGIN FcBool -FcDirCacheValid (const FcChar8 *cache_file); +FcDirCacheValid (const FcChar8 *cache_file, FcConfig *config); FcBool -FcDirCacheHasCurrentArch (const FcChar8 *dir); +FcDirCacheHasCurrentArch (const FcChar8 *dir, FcConfig *config); FcBool FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config); diff --git a/fonts.conf.in b/fonts.conf.in index 3329d7a..035ee32 100644 --- a/fonts.conf.in +++ b/fonts.conf.in @@ -27,6 +27,11 @@ @FC_FONTPATH@ ~/.fonts + + + @FC_CACHEDIR@ + ~/.fonts/fontconfig + diff --git a/fonts.dtd b/fonts.dtd index 6c9a33d..cd016d3 100644 --- a/fonts.dtd +++ b/fonts.dtd @@ -22,6 +22,18 @@ + + + +