]> git.wh0rd.org - fontconfig.git/blobdiff - src/fccfg.c
Merge with HEAD and finish the GCC 4 cleanups (no more warnings!)
[fontconfig.git] / src / fccfg.c
index aaa05f56b47341ca34a3fb07eb0faaa7c1778f5f..aaca6efc75652446ace1edda21bef51acde3a1c4 100644 (file)
@@ -250,36 +250,35 @@ FcConfigBuildFonts (FcConfig *config)
     FcFontSet      *fonts, *cached_fonts;
     FcGlobalCache   *cache;
     FcStrList      *list;
+    FcStrSet       *oldDirs;
     FcChar8        *dir;
 
-#if 0
-    if (config->cache)
-       FcGlobalCacheLoad (cache, config->cache);
-#endif
-    if (config->fonts[FcSetSystem])
-       return FcTrue;
-
     fonts = FcFontSetCreate ();
     if (!fonts)
        goto bail0;
-
-#if 0
+    
     cache = FcGlobalCacheCreate ();
     if (!cache)
        goto bail1;
-#endif
 
-    cached_fonts = FcCacheRead(config);
+    oldDirs = FcStrSetCreate ();
+    if (!oldDirs)
+        goto bail2;
+
+    if (config->cache)
+       FcGlobalCacheLoad (cache, oldDirs, config->cache);
+
+    cached_fonts = FcCacheRead(config, cache);
     if (!cached_fonts)
     {
        list = FcConfigGetFontDirs (config);
        if (!list)
-           goto bail1;
+           goto bail2;
        
        while ((dir = FcStrListNext (list)))
        {
            if (FcDebug () & FC_DBG_FONTSET)
-               printf ("scan dir %s\n", dir);
+               printf ("build scan dir %s\n", dir);
            FcDirScanConfig (fonts, config->fontDirs, cache, 
                             config->blanks, dir, FcFalse, config);
        }
@@ -290,26 +289,39 @@ FcConfigBuildFonts (FcConfig *config)
     {
        int i;
 
+        for (i = 0; i < oldDirs->num; i++)
+        {
+           if (FcDebug () & FC_DBG_FONTSET)
+               printf ("scan dir %s\n", dir);
+           FcDirScanConfig (fonts, config->fontDirs, cache, 
+                            config->blanks, oldDirs->strs[i], 
+                             FcFalse, config);
+       }
+
        for (i = 0; i < cached_fonts->nfont; i++)
        {
            if (FcConfigAcceptFont (config, cached_fonts->fonts[i]))
                FcFontSetAdd (fonts, cached_fonts->fonts[i]);
+
+           cached_fonts->fonts[i] = 0; /* prevent free in FcFontSetDestroy */
        }
+       cached_fonts->nfont = 0;
        FcFontSetDestroy (cached_fonts);
     }
     
     if (FcDebug () & FC_DBG_FONTSET)
        FcFontSetPrint (fonts);
 
-#if 0
     if (config->cache)
        FcGlobalCacheSave (cache, config->cache);
     FcGlobalCacheDestroy (cache);
-#endif
+    FcStrSetDestroy (oldDirs);
 
     FcConfigSetFonts (config, fonts, FcSetSystem);
     
     return FcTrue;
+bail2:
+    FcStrSetDestroy (oldDirs);
 bail1:
     FcFontSetDestroy (fonts);
 bail0:
@@ -778,7 +790,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
        break;
     case FcOpString:
        v.type = FcTypeString;
-       v.u.s = FcObjectStaticName(e->u.sval);
+       v.u.s = FcStrStaticName(e->u.sval);
        v = FcValueSave (v);
        break;
     case FcOpMatrix:
@@ -896,7 +908,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
                switch (e->op) {
                case FcOpPlus:
                    v.type = FcTypeString;
-                   v.u.s = FcObjectStaticName (FcStrPlus (vl.u.s, vr.u.s));
+                   v.u.s = FcStrStaticName (FcStrPlus (vl.u.s, vr.u.s));
                         
                    if (!v.u.s)
                        v.type = FcTypeVoid;
@@ -1640,7 +1652,7 @@ FcConfigHome (void)
            home = getenv ("USERPROFILE");
 #endif
 
-       return home;
+       return (FcChar8 *) home;
     }
     return 0;
 }