]> git.wh0rd.org - fontconfig.git/blobdiff - src/fccfg.c
Revert to original FcFontSetMatch algorithm to avoid losing fonts.
[fontconfig.git] / src / fccfg.c
index 8eb82e5a3cac0f7611f4b5ca009ea0a9e834d00e..586c6567e4fca29fd6a9950ac617ebd5d7aa6bfe 100644 (file)
@@ -265,7 +265,6 @@ FcBool
 FcConfigBuildFonts (FcConfig *config)
 {
     FcFontSet      *fonts, *cached_fonts;
-    FcGlobalCache   *cache;
     FcStrList      *list;
     FcStrSet       *oldDirs;
     FcChar8        *dir;
@@ -274,18 +273,11 @@ FcConfigBuildFonts (FcConfig *config)
     if (!fonts)
        goto bail0;
     
-    cache = FcGlobalCacheCreate ();
-    if (!cache)
-       goto bail1;
-
     oldDirs = FcStrSetCreate ();
     if (!oldDirs)
         goto bail2;
 
-    if (config->cache)
-       FcGlobalCacheLoad (cache, oldDirs, config->cache, config);
-
-    cached_fonts = FcCacheRead(config, cache);
+    cached_fonts = FcCacheRead(config);
     if (!cached_fonts)
     {
        list = FcConfigGetFontDirs (config);
@@ -296,7 +288,7 @@ FcConfigBuildFonts (FcConfig *config)
        {
            if (FcDebug () & FC_DBG_FONTSET)
                printf ("build scan dir %s\n", dir);
-           FcDirScanConfig (fonts, config->fontDirs, cache, 
+           FcDirScanConfig (fonts, config->fontDirs,
                             config->blanks, dir, FcFalse, config);
        }
        
@@ -310,7 +302,7 @@ FcConfigBuildFonts (FcConfig *config)
         {
            if (FcDebug () & FC_DBG_FONTSET)
                printf ("scan dir %s\n", oldDirs->strs[i]);
-           FcDirScanConfig (fonts, config->fontDirs, cache, 
+           FcDirScanConfig (fonts, config->fontDirs,
                             config->blanks, oldDirs->strs[i], 
                              FcFalse, config);
        }
@@ -333,9 +325,6 @@ FcConfigBuildFonts (FcConfig *config)
     if (FcDebug () & FC_DBG_FONTSET)
        FcFontSetPrint (fonts);
 
-    if (config->cache)
-       FcGlobalCacheSave (cache, config->cache, config);
-    FcGlobalCacheDestroy (cache);
     FcStrSetDestroy (oldDirs);
 
     FcConfigSetFonts (config, fonts, FcSetSystem);
@@ -344,8 +333,6 @@ FcConfigBuildFonts (FcConfig *config)
 bail3:
     FcStrSetDestroy (oldDirs);
 bail2:
-    FcGlobalCacheDestroy (cache);
-bail1:
     FcFontSetDestroy (fonts);
 bail0:
     return FcFalse;
@@ -392,113 +379,13 @@ FcConfigGetConfigDirs (FcConfig   *config)
     return FcStrListCreate (config->configDirs);
 }
 
-static FcChar8 *
-FcConfigInodeMatchFontDir (FcConfig *config, const FcChar8 *d)
-{
-    int                n;
-    ino_t      di;
-    dev_t      dd;
-    struct stat s;
-
-    /* first we do string matches rather than file accesses */
-    /* FcStrSetMember doesn't tell us the index so that we can return
-     * the config-owned copy. */
-    for (n = 0; n < config->fontDirs->num; n++)
-    {
-       if (!FcStrCmp (config->fontDirs->strs[n], d))
-           return config->fontDirs->strs[n];
-    }
-
-    /* If this is a bottleneck, we can cache the fontDir inodes. */
-    if (stat ((char *)d, &s) == -1)
-       return 0;
-    di = s.st_ino; dd = s.st_dev;
-
-    for (n = 0; n < config->fontDirs->num; n++)
-    {
-       if (stat ((char *)config->fontDirs->strs[n], &s) == -1)
-           continue;
-       if (di == s.st_ino && dd == s.st_dev)
-           return config->fontDirs->strs[n];
-    }
-    return 0;
-}
-
 FcBool
 FcConfigAddFontDir (FcConfig       *config,
                    const FcChar8   *d)
 {
-    /* Avoid adding d if it's an alias of something else, too. */
-    if (FcConfigInodeMatchFontDir(config, d))
-       return FcTrue;
     return FcStrSetAddFilename (config->fontDirs, d);
 }
 
-static FcBool
-FcConfigAddFontDirSubdirs (FcConfig        *config,
-                          const FcChar8   *d)
-{
-    DIR *dir;
-    struct dirent *e;
-    FcChar8 *subdir;
-    FcBool added = FcFalse;
-    
-    if (!(dir = opendir ((char *) d)))
-       return FcFalse;
-    if (!(subdir = (FcChar8 *) malloc (strlen ((char *) d) + FC_MAX_FILE_LEN + 2)))
-    {
-       fprintf (stderr, "out of memory");
-       return FcFalse;
-    }
-    while ((e = readdir (dir)))
-    {
-       if (strcmp (e->d_name, ".") && strcmp (e->d_name, "..") &&
-           strlen (e->d_name) < FC_MAX_FILE_LEN)
-       {
-           strcpy ((char *)subdir, (char *)d);
-           strcat ((char *)subdir, "/");
-           strcat ((char *)subdir, e->d_name);
-           if (FcFileIsDir (subdir))
-           {
-               if (FcConfigInodeMatchFontDir(config, subdir))
-                   continue; /* already added */
-               FcStrSetAddFilename (config->fontDirs, subdir);
-               FcConfigAddFontDirSubdirs (config, subdir);
-               added = FcTrue;
-           }
-       }
-    }
-    free (subdir);
-    closedir (dir);
-    return added;
-}
-
-const FcChar8 *
-FcConfigNormalizeFontDir (FcConfig     *config, 
-                         const FcChar8 *d)
-{
-    FcChar8    *d0;
-    int                n, n0;
-    FcBool     added = FcFalse;
-
-    d0 = FcConfigInodeMatchFontDir(config, d);
-    if (d0)
-       return d0;
-
-    /* Ok, we didn't find it in fontDirs; let's add subdirs.... */
-    for (n = 0, n0 = config->fontDirs->num; n < n0; n++) 
-    {
-       if (FcConfigAddFontDirSubdirs (config, config->fontDirs->strs[n]))
-           added = FcTrue;
-    }
-
-    /* ... and try again. */
-    if (added)
-       return FcConfigInodeMatchFontDir(config, d);
-
-    return 0;
-}
-
 FcBool
 FcConfigAddDir (FcConfig           *config,
                const FcChar8       *d)
@@ -1899,7 +1786,7 @@ FcConfigAppFontAddFile (FcConfig    *config,
        FcConfigSetFonts (config, set, FcSetApplication);
     }
        
-    if (!FcFileScanConfig (set, subdirs, 0, config->blanks, file, FcFalse, config))
+    if (!FcFileScanConfig (set, subdirs, config->blanks, file, FcFalse, config))
     {
        FcStrSetDestroy (subdirs);
        return FcFalse;
@@ -1947,7 +1834,7 @@ FcConfigAppFontAddDir (FcConfig       *config,
        FcConfigSetFonts (config, set, FcSetApplication);
     }
     
-    if (!FcDirScanConfig (set, subdirs, 0, config->blanks, dir, FcFalse, config))
+    if (!FcDirScanConfig (set, subdirs, config->blanks, dir, FcFalse, config))
     {
        FcStrSetDestroy (subdirs);
        return FcFalse;