From: Patrick Lam Date: Mon, 30 Jan 2006 04:27:53 +0000 (+0000) Subject: Add documentation for FcConfigNormalizeFontDir. X-Git-Tag: fc-2_3_94~56 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=971cf18018a4f41bca196dd81989e67672e52112;p=fontconfig.git Add documentation for FcConfigNormalizeFontDir. Write directory information to global caches to fix make check (reported by Ronny V. Vindenes). This changes the global cache format again. --- diff --git a/ChangeLog b/ChangeLog index 0975c22..17c2c56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-01-29 Patrick Lam + * 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 * fc-cache/fc-cache.c (scanDirs): * fontconfig/fontconfig.h: diff --git a/doc/fcconfig.fncs b/doc/fcconfig.fncs index 3680b0e..db7ee02 100644 --- a/doc/fcconfig.fncs +++ b/doc/fcconfig.fncs @@ -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. +@@ diff --git a/src/fccache.c b/src/fccache.c index a687483..924494f 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -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); diff --git a/src/fcdir.c b/src/fcdir.c index adb39fb..d75f8a3 100644 --- a/src/fcdir.c +++ b/src/fcdir.c @@ -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]); diff --git a/src/fcint.h b/src/fcint.h index b77b50d..e0bce4b 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -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);