Normalize font dirs by using the form, as given in fonts.conf, and recorded
in FcConfig's fontDirs string set, as canonical. Actually update config.fontDirs as font directories are scanned.
This commit is contained in:
parent
5576a5873d
commit
cd9bca6970
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2006-01-09 Patrick Lam <plam@mit.edu>
|
||||||
|
* fc-cache/fc-cache.c (scanDirs):
|
||||||
|
* fc-cat/fc-cat.c (FcCacheGlobalFileReadAndPrint, FcCacheFileRead):
|
||||||
|
* src/fccache.c (FcGlobalCacheReadDir, FcCacheReadDirs,
|
||||||
|
FcDirCacheRead, FcDirCacheConsume, FcDirCacheWrite):
|
||||||
|
* src/fccfg.c (FcConfigNormalizeFontDir):
|
||||||
|
* src/fcdir.c (FcDirScanConfig):
|
||||||
|
* src/fcint.h:
|
||||||
|
|
||||||
|
Normalize font dirs by using the form, as given in fonts.conf, and
|
||||||
|
recorded in FcConfig's fontDirs string set, as canonical.
|
||||||
|
|
||||||
|
Actually update config.fontDirs as font directories are scanned.
|
||||||
|
|
||||||
2006-01-08 James Su <james.su@gmail.com>
|
2006-01-08 James Su <james.su@gmail.com>
|
||||||
* src/fcmatch.c (FcFontSetMatch):
|
* src/fcmatch.c (FcFontSetMatch):
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
|
||||||
FcStrSetDestroy (subdirs);
|
FcStrSetDestroy (subdirs);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!FcDirScan (set, subdirs, 0, FcConfigGetBlanks (config), dir, force))
|
if (!FcDirScanConfig (set, subdirs, 0, FcConfigGetBlanks (config), dir, force, config))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\"%s\": error scanning\n", dir);
|
fprintf (stderr, "\"%s\": error scanning\n", dir);
|
||||||
FcFontSetDestroy (set);
|
FcFontSetDestroy (set);
|
||||||
|
|
|
@ -202,7 +202,7 @@ FcCacheGlobalFileReadAndPrint (FcFontSet * set, FcStrSet *dirs, char *cache_file
|
||||||
printf ("fc-cat: printing global cache contents for dir %s\n",
|
printf ("fc-cat: printing global cache contents for dir %s\n",
|
||||||
name_buf);
|
name_buf);
|
||||||
|
|
||||||
if (!FcDirCacheConsume (fd, name_buf, set))
|
if (!FcDirCacheConsume (fd, name_buf, set, 0))
|
||||||
goto bail1;
|
goto bail1;
|
||||||
|
|
||||||
dir = strdup(name_buf);
|
dir = strdup(name_buf);
|
||||||
|
@ -261,7 +261,7 @@ FcCacheFileRead (FcFontSet * set, FcStrSet *dirs, char *cache_file)
|
||||||
if (ls)
|
if (ls)
|
||||||
*ls = 0;
|
*ls = 0;
|
||||||
|
|
||||||
if (!FcDirCacheConsume (fd, dir, set))
|
if (!FcDirCacheConsume (fd, dir, set, 0))
|
||||||
goto bail2;
|
goto bail2;
|
||||||
free (dir);
|
free (dir);
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,7 @@ static void *
|
||||||
FcDirCacheProduce (FcFontSet *set, FcCache * metadata);
|
FcDirCacheProduce (FcFontSet *set, FcCache * metadata);
|
||||||
|
|
||||||
static FcBool
|
static FcBool
|
||||||
FcDirCacheConsume (int fd, const char * dir, FcFontSet *set);
|
FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config);
|
||||||
|
|
||||||
FcBool
|
|
||||||
FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
FcCacheNextOffset(off_t w);
|
FcCacheNextOffset(off_t w);
|
||||||
|
@ -312,7 +309,7 @@ FcGlobalCacheReadDir (FcFontSet *set, FcStrSet *dirs, FcGlobalCache * cache, con
|
||||||
if (strncmp (d->name, dir, strlen(dir)) == 0)
|
if (strncmp (d->name, dir, strlen(dir)) == 0)
|
||||||
{
|
{
|
||||||
lseek (cache->fd, d->offset, SEEK_SET);
|
lseek (cache->fd, d->offset, SEEK_SET);
|
||||||
if (!FcDirCacheConsume (cache->fd, dir, set))
|
if (!FcDirCacheConsume (cache->fd, dir, set, config))
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
if (strcmp (d->name, dir) == 0)
|
if (strcmp (d->name, dir) == 0)
|
||||||
ret = FcTrue;
|
ret = FcTrue;
|
||||||
|
@ -788,7 +785,7 @@ FcCacheReadDirs (FcConfig * config, FcGlobalCache * cache,
|
||||||
free (file);
|
free (file);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!FcDirCacheValid (dir) || !FcDirCacheRead (set, subdirs, dir))
|
if (!FcDirCacheValid (dir) || !FcDirCacheRead (set, subdirs, dir, config))
|
||||||
{
|
{
|
||||||
if (FcDebug () & FC_DBG_FONTSET)
|
if (FcDebug () & FC_DBG_FONTSET)
|
||||||
printf ("cache scan dir %s\n", dir);
|
printf ("cache scan dir %s\n", dir);
|
||||||
|
@ -909,7 +906,7 @@ FcDirCacheOpen (char *cache_file)
|
||||||
|
|
||||||
/* read serialized state from the cache file */
|
/* read serialized state from the cache file */
|
||||||
FcBool
|
FcBool
|
||||||
FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir)
|
FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir, FcConfig *config)
|
||||||
{
|
{
|
||||||
char *cache_file;
|
char *cache_file;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -940,7 +937,7 @@ FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir)
|
||||||
while (strlen(FcCacheReadString (fd, subdirName, sizeof (subdirName))) > 0)
|
while (strlen(FcCacheReadString (fd, subdirName, sizeof (subdirName))) > 0)
|
||||||
FcStrSetAdd (dirs, (FcChar8 *)subdirName);
|
FcStrSetAdd (dirs, (FcChar8 *)subdirName);
|
||||||
|
|
||||||
if (!FcDirCacheConsume (fd, (const char *)dir, set))
|
if (!FcDirCacheConsume (fd, (const char *)dir, set, config))
|
||||||
goto bail1;
|
goto bail1;
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -955,7 +952,7 @@ FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcBool
|
static FcBool
|
||||||
FcDirCacheConsume (int fd, const char * dir, FcFontSet *set)
|
FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config)
|
||||||
{
|
{
|
||||||
FcCache metadata;
|
FcCache metadata;
|
||||||
void * current_dir_block;
|
void * current_dir_block;
|
||||||
|
@ -980,6 +977,8 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set)
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
|
|
||||||
FcCacheAddBankDir (metadata.bank, dir);
|
FcCacheAddBankDir (metadata.bank, dir);
|
||||||
|
if (config)
|
||||||
|
FcConfigAddFontDir (config, (FcChar8 *)dir);
|
||||||
|
|
||||||
if (!FcFontSetUnserialize (&metadata, set, current_dir_block))
|
if (!FcFontSetUnserialize (&metadata, set, current_dir_block))
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
|
@ -1052,6 +1051,10 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
|
||||||
char *current_arch_machine_name, * header;
|
char *current_arch_machine_name, * header;
|
||||||
void *current_dir_block = 0;
|
void *current_dir_block = 0;
|
||||||
|
|
||||||
|
dir = FcConfigNormalizeFontDir (FcConfigGetCurrent(), dir);
|
||||||
|
if (!dir)
|
||||||
|
return FcFalse;
|
||||||
|
|
||||||
cache_file = (char *)FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
|
cache_file = (char *)FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
|
||||||
if (!cache_file)
|
if (!cache_file)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
23
src/fccfg.c
23
src/fccfg.c
|
@ -388,6 +388,29 @@ FcConfigAddFontDir (FcConfig *config,
|
||||||
return FcStrSetAddFilename (config->fontDirs, d);
|
return FcStrSetAddFilename (config->fontDirs, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FcChar8 *
|
||||||
|
FcConfigNormalizeFontDir (FcConfig *config,
|
||||||
|
const FcChar8 *d)
|
||||||
|
{
|
||||||
|
/* If this is a bottleneck, we can cache the fontDir inodes. */
|
||||||
|
ino_t di;
|
||||||
|
int n;
|
||||||
|
struct stat s;
|
||||||
|
|
||||||
|
if (stat ((char *)d, &s) == -1)
|
||||||
|
return 0;
|
||||||
|
di = s.st_ino;
|
||||||
|
|
||||||
|
for (n = 0; n < config->fontDirs->num; n++)
|
||||||
|
{
|
||||||
|
if (stat ((char *)config->fontDirs->strs[n], &s) == -1)
|
||||||
|
continue;
|
||||||
|
if (di == s.st_ino)
|
||||||
|
return config->fontDirs->strs[n];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
FcBool
|
FcBool
|
||||||
FcConfigAddDir (FcConfig *config,
|
FcConfigAddDir (FcConfig *config,
|
||||||
const FcChar8 *d)
|
const FcChar8 *d)
|
||||||
|
|
|
@ -139,7 +139,7 @@ FcDirScanConfig (FcFontSet *set,
|
||||||
if (cache && FcGlobalCacheReadDir (set, dirs, cache, (char *)dir, config))
|
if (cache && FcGlobalCacheReadDir (set, dirs, cache, (char *)dir, config))
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
|
|
||||||
if (FcDirCacheValid (dir) && FcDirCacheRead (set, dirs, dir))
|
if (FcDirCacheValid (dir) && FcDirCacheRead (set, dirs, dir, config))
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +165,7 @@ FcDirScanConfig (FcFontSet *set,
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FcConfigAddFontDir (config, dir);
|
||||||
tmpSet = FcFontSetCreate();
|
tmpSet = FcFontSetCreate();
|
||||||
if (!tmpSet)
|
if (!tmpSet)
|
||||||
{
|
{
|
||||||
|
|
|
@ -461,7 +461,7 @@ FcBool
|
||||||
FcDirCacheWrite (FcFontSet *set, FcStrSet * dirs, const FcChar8 *dir);
|
FcDirCacheWrite (FcFontSet *set, FcStrSet * dirs, const FcChar8 *dir);
|
||||||
|
|
||||||
FcBool
|
FcBool
|
||||||
FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir);
|
FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir, FcConfig *config);
|
||||||
|
|
||||||
extern int *_fcBankId, *_fcBankIdx;
|
extern int *_fcBankId, *_fcBankIdx;
|
||||||
int
|
int
|
||||||
|
@ -494,6 +494,10 @@ FcBool
|
||||||
FcConfigAddConfigFile (FcConfig *config,
|
FcConfigAddConfigFile (FcConfig *config,
|
||||||
const FcChar8 *f);
|
const FcChar8 *f);
|
||||||
|
|
||||||
|
const FcChar8 *
|
||||||
|
FcConfigNormalizeFontDir (FcConfig *config,
|
||||||
|
const FcChar8 *d);
|
||||||
|
|
||||||
FcBool
|
FcBool
|
||||||
FcConfigSetCache (FcConfig *config,
|
FcConfigSetCache (FcConfig *config,
|
||||||
const FcChar8 *c);
|
const FcChar8 *c);
|
||||||
|
|
Loading…
Reference in New Issue