]> git.wh0rd.org - fontconfig.git/commitdiff
Add documentation for FcConfigNormalizeFontDir.
authorPatrick Lam <plam@MIT.EDU>
Mon, 30 Jan 2006 04:27:53 +0000 (04:27 +0000)
committerPatrick Lam <plam@MIT.EDU>
Mon, 30 Jan 2006 04:27:53 +0000 (04:27 +0000)
Write directory information to global caches to fix make check (reported by
    Ronny V. Vindenes). This changes the global cache format again.

ChangeLog
doc/fcconfig.fncs
src/fccache.c
src/fcdir.c
src/fcint.h

index 0975c223a5a77d2fb08061e142c9fe8f8fae2efc..17c2c56b9b4b82761bf4bb4c81b56a8527ade7e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-01-29  Patrick Lam  <plam@mit.edu>
+       * doc/fcconfig.fncs:
+       Add documentation for FcConfigNormalizeFontDir.
+
+       * src/fccache.c (FcGlobalCacheDirDestroy, FcGlobalCacheLoad,
+                        FcGlobalCacheUpdate, FcGlobalCacheSave):
+       * src/fcdir.c (FcDirScanConfig):
+       * src/fcint.h:
+
+       Write directory information to global caches to fix make check
+       (reported by Ronny V. Vindenes).  This changes the global cache
+       format again.
+       
 2006-01-27  Patrick Lam  <plam@mit.edu>
        * fc-cache/fc-cache.c (scanDirs):
        * fontconfig/fontconfig.h:
index 3680b0e7c902d387f1e9b36b87e5b9966ef3e9c9..db7ee027aa40510039d23dbf746a807ae616efb9 100644 (file)
@@ -290,3 +290,14 @@ in 'config'.  Any include files referenced from within 'file' will be loaded
 with FcConfigLoad and also parsed.  If 'complain' is FcFalse, no warning
 will be displayed if 'file' does not exist.
 @@
+
+@RET@          const FcChar8 *
+@FUNC@         FcConfigNormalizeFontDir
+@TYPE1@                FcConfig *                      @ARG1@          config
+@TYPE2@                const FcChar8 *                 @ARG2@          dir
+@PURPOSE@      normalize a font directory
+@DESC@
+Converts the directory name given in 'dir' to a normal form, i.e. one 
+of the forms which are derived from the font directories specified
+in the config file.
+@@
index a687483bc9fdcdca1630d9433e8cbc75112ff2dc..924494f24ee07637fc982d43f912f8a633e3d599 100644 (file)
@@ -157,6 +157,7 @@ FcCacheWriteString (int fd, const char *chars)
 static void
 FcGlobalCacheDirDestroy (FcGlobalCacheDir *d)
 {
+    FcStrSetDestroy (d->subdirs);
     FcMemFree (FC_MEM_STRING, strlen (d->name)+1);
     free (d->name);
     FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheDir));
@@ -206,6 +207,7 @@ FcGlobalCacheLoad (FcGlobalCache    *cache,
     off_t              current_arch_start;
 
     struct stat        cache_stat, dir_stat;
+    char               subdirName[FC_MAX_FILE_LEN + 1 + 12 + 1];
 
     if (stat ((char *) cache_file, &cache_stat) < 0)
         return;
@@ -264,6 +266,11 @@ FcGlobalCacheLoad (FcGlobalCache    *cache,
        d->name = (char *)FcStrCopy ((FcChar8 *)name_buf);
        d->ent = 0;
        d->offset = lseek (cache->fd, 0, SEEK_CUR);
+
+       d->subdirs = FcStrSetCreate();
+       while (strlen(FcCacheReadString (cache->fd, subdirName, sizeof (subdirName))) > 0)
+           FcStrSetAdd (d->subdirs, (FcChar8 *)subdirName);
+
        if (read (cache->fd, &d->metadata, sizeof (FcCache)) != sizeof (FcCache))
            goto bail1;
        targ = FcCacheNextOffset (lseek(cache->fd, 0, SEEK_CUR)) + d->metadata.count;
@@ -324,11 +331,13 @@ FcGlobalCacheReadDir (FcFontSet *set, FcStrSet *dirs, FcGlobalCache * cache, con
 
 FcBool
 FcGlobalCacheUpdate (FcGlobalCache  *cache,
+                    FcStrSet       *dirs,
                     const char     *name,
                     FcFontSet      *set,
                     FcConfig       *config)
 {
-    FcGlobalCacheDir * d;
+    FcGlobalCacheDir    *d;
+    int                        i;
 
     name = (char *)FcConfigNormalizeFontDir (config, (FcChar8 *)name);
     for (d = cache->dirs; d; d = d->next)
@@ -351,6 +360,9 @@ FcGlobalCacheUpdate (FcGlobalCache  *cache,
     d->name = (char *)FcStrCopy ((FcChar8 *)name);
     d->ent = FcDirCacheProduce (set, &d->metadata);
     d->offset = 0;
+    d->subdirs = FcStrSetCreate();
+    for (i = 0; i < dirs->num; i++)
+       FcStrSetAdd (d->subdirs, dirs->strs[i]);
     return FcTrue;
 }
 
@@ -359,7 +371,7 @@ FcGlobalCacheSave (FcGlobalCache    *cache,
                   const FcChar8    *cache_file,
                   FcConfig         *config)
 {
-    int                        fd, fd_orig;
+    int                        fd, fd_orig, i;
     FcGlobalCacheDir   *dir;
     FcAtomic           *atomic;
     off_t              current_arch_start = 0, truncate_to;
@@ -424,6 +436,10 @@ FcGlobalCacheSave (FcGlobalCache    *cache,
        truncate_to += sizeof (FcCache);
        truncate_to = FcCacheNextOffset (truncate_to);
        truncate_to += dir->metadata.count;
+
+       for (i = 0; i < dir->subdirs->size; i++)
+           truncate_to += strlen((char *)dir->subdirs->strs[i]) + 1;
+       truncate_to ++;
     }
     truncate_to -= current_arch_start;
 
@@ -439,6 +455,11 @@ FcGlobalCacheSave (FcGlobalCache    *cache,
            const char * d = (const char *)FcConfigNormalizeFontDir (config, (const FcChar8 *)dir->name);
 
             FcCacheWriteString (fd, d);
+
+           for (i = 0; i < dir->subdirs->size; i++)
+               FcCacheWriteString (fd, (char *)dir->subdirs->strs[i]);
+           FcCacheWriteString (fd, "");
+           
             write (fd, &dir->metadata, sizeof(FcCache));
             lseek (fd, FcCacheNextOffset (lseek(fd, 0, SEEK_CUR)), SEEK_SET);
             write (fd, dir->ent, dir->metadata.count);
index adb39fb1fe62b45fb94ac35d3d3075304c5fbdb7..d75f8a34dd7fd7dfb5d577582f06af4dd3e480d7 100644 (file)
@@ -194,7 +194,7 @@ FcDirScanConfig (FcFontSet  *set,
      * add the cache entry 
      */
     if (ret && cache)
-       FcGlobalCacheUpdate (cache, (char *)dir, tmpSet, config);
+       FcGlobalCacheUpdate (cache, dirs, (char *)dir, tmpSet, config);
 
     for (i = 0; i < tmpSet->nfont; i++)
        FcFontSetAdd (set, tmpSet->fonts[i]);
index b77b50d08d3dda8a882bf0734f34b0a4962be695..e0bce4b484e0c8ac12609c754a5e2dcf1b142c49 100644 (file)
@@ -333,6 +333,7 @@ struct _FcGlobalCacheDir {
     char                       *name;
     FcCache                    metadata;
     off_t                      offset;
+    FcStrSet                   *subdirs;
     void                       *ent;
 };
 
@@ -447,6 +448,7 @@ FcGlobalCacheLoad (FcGlobalCache    *cache,
 
 FcBool
 FcGlobalCacheUpdate (FcGlobalCache  *cache,
+                    FcStrSet       *dirs,
                     const char     *file,
                     FcFontSet      *set,
                     FcConfig       *config);