]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcdir.c
Reduce number of allocations during FcSortWalk().
[fontconfig.git] / src / fcdir.c
index 8da50e93c282f75eeb8c60f23783861e4bfcafd0..59ea33dc7eec08da4bf3bf42b63189586cf29446 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $RCSId: xc/lib/fontconfig/src/fcdir.c,v 1.9 2002/08/31 22:17:32 keithp Exp $
+ * fontconfig/src/fcdir.c
  *
  * Copyright © 2000 Keith Packard
  *
@@ -61,15 +61,31 @@ FcFileScanFontConfig (FcFontSet             *set,
        font = FcFreeTypeQuery (file, id, blanks, &count);
        if (FcDebug () & FC_DBG_SCAN)
            printf ("done\n");
+
+       /*
+        * Edit pattern with user-defined rules
+        */
+       if (font && config && !FcConfigSubstituteWithPat (config, font, NULL, FcMatchScan))
+       {
+           FcPatternDestroy (font);
+           font = NULL;
+           ret = FcFalse;
+       }
+
        /*
         * Add the font
         */
        if (font && (!config || FcConfigAcceptFont (config, font)))
        {
+           if (FcDebug() & FC_DBG_SCANV)
+           {
+               printf ("Final font pattern:\n");
+               FcPatternPrint (font);
+           }
            if (!FcFontSetAdd (set, font))
            {
                FcPatternDestroy (font);
-               font = 0;
+               font = NULL;
                ret = FcFalse;
            }
        }
@@ -130,6 +146,7 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
     int                        i;
     FcBlanks           *blanks = FcConfigGetBlanks (config);
     FcCache            *cache = NULL;
+    struct stat                dir_stat;
 
     if (FcDebug () & FC_DBG_FONTSET)
        printf ("cache scan dir %s\n", dir);
@@ -158,6 +175,11 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
            ret = FcFalse;
        goto bail_1;
     }
+    if (stat ((char *) dir, &dir_stat) < 0)
+    {
+       ret = FcFalse;
+       goto bail_1;
+    }
 
     set = FcFontSetCreate();
     if (!set) 
@@ -202,7 +224,7 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
     /*
      * Build the cache object
      */
-    cache = FcDirCacheBuild (set, dir, dirs);
+    cache = FcDirCacheBuild (set, dir, &dir_stat, dirs);
     if (!cache)
        goto bail3;
     
@@ -257,7 +279,7 @@ FcDirScanConfig (FcFontSet  *set,
                 FcBool         force,
                 FcConfig       *config)
 {
-    return FcFalse; /* XXX fixme */
+    return FcFalse; /* XXX deprecated */
 }
 
 FcBool
@@ -268,7 +290,7 @@ FcDirScan (FcFontSet            *set,
           const FcChar8    *dir,
           FcBool           force)
 {
-    return FcDirScanConfig (set, dirs, blanks, dir, force, NULL);
+    return FcFalse; /* XXX deprecated */
 }
 
 FcBool
@@ -276,3 +298,6 @@ FcDirSave (FcFontSet *set, FcStrSet * dirs, const FcChar8 *dir)
 {
     return FcFalse; /* XXX deprecated */
 }
+#define __fcdir__
+#include "fcaliastail.h"
+#undef __fcdir__