]> git.wh0rd.org Git - fontconfig.git/commitdiff
Revert ill-advised addition of FC_RENDER. Add strategy for handling objects
authorPatrick Lam <plam@MIT.EDU>
Thu, 15 Sep 2005 20:36:44 +0000 (20:36 +0000)
committerPatrick Lam <plam@MIT.EDU>
Thu, 15 Sep 2005 20:36:44 +0000 (20:36 +0000)
    that aren't hardcoded into fontconfig, but generated by fontconfig
    clients: keep another array of user-defined objects (indexed after the
    built-in objects).
Fix compilation warning (uninitialized variable).
Add comment.

fontconfig/fontconfig.h
src/fccache.c
src/fccfg.c
src/fcname.c

index b967580b6e9c4563ed914d7798c77ce51f12e74d..312256f879e3321faae2c137f188bc6f4895a9f9 100644 (file)
@@ -96,7 +96,6 @@ typedef int           FcBool;
 #define FC_CAPABILITY       "capability"       /* String */
 #define FC_FONTFORMAT      "fontformat"        /* String */
 #define FC_EMBOLDEN        "embolden"          /* Bool - true if emboldening needed*/
-#define FC_RENDER          "render"            /* Bool */
 
 #define FC_DIR_CACHE_FILE          "fonts.cache-"FC_CACHE_VERSION
 #define FC_USER_CACHE_FILE         ".fonts.cache-"FC_CACHE_VERSION
index 1f530652f348a0d204d61c95458bdd3cbbf6d641..31630f1dc7a0bf8b69b832e1d43240baf1115f52 100644 (file)
@@ -420,6 +420,7 @@ FcCacheSkipToArch (int fd, const char * arch)
            return -1;
        bs = strtol(candidate_arch_machine_name_count, &candidate_arch, 16);
 
+       // count = 0 should probably be distinguished from the !bs condition
        if (!bs || bs < strlen (candidate_arch_machine_name_count))
            return -1;
 
index aaca6efc75652446ace1edda21bef51acde3a1c4..5d6339f65af9102b828000ece797127dffa5bb2d 100644 (file)
@@ -292,7 +292,7 @@ FcConfigBuildFonts (FcConfig *config)
         for (i = 0; i < oldDirs->num; i++)
         {
            if (FcDebug () & FC_DBG_FONTSET)
-               printf ("scan dir %s\n", dir);
+               printf ("scan dir %s\n", oldDirs->strs[i]);
            FcDirScanConfig (fonts, config->fontDirs, cache, 
                             config->blanks, oldDirs->strs[i], 
                              FcFalse, config);
index 500403247d53f735a02a1d8bc7db1dfbf5210eb6..b4d417e2d637cb1fddf35449a80fbbbbdd341f2e 100644 (file)
@@ -61,6 +61,7 @@ static const FcObjectType _FcBaseObjectTypes[] = {
     { FC_RGBA,         FcTypeInteger, },
     { FC_SCALE,                FcTypeDouble, },
     { FC_MINSPACE,     FcTypeBool, },
+/*    { FC_RENDER,     FcTypeBool, },*/
     { FC_CHAR_WIDTH,   FcTypeInteger },
     { FC_CHAR_HEIGHT,  FcTypeInteger },
     { FC_MATRIX,       FcTypeMatrix },
@@ -70,11 +71,13 @@ static const FcObjectType _FcBaseObjectTypes[] = {
     { FC_CAPABILITY,   FcTypeString },
     { FC_FONTFORMAT,   FcTypeString },
     { FC_EMBOLDEN,     FcTypeBool },
-    { FC_RENDER,       FcTypeBool, },
 };
 
 #define NUM_OBJECT_TYPES    (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0])
 
+static FcObjectType * _FcUserObjectNames = 0;
+static int user_obj_alloc = 0;
+
 typedef struct _FcObjectTypeList    FcObjectTypeList;
 
 struct _FcObjectTypeList {
@@ -155,38 +158,90 @@ FcNameGetObjectType (const char *object)
     return 0;
 }
 
+#define OBJECT_HASH_SIZE    31
+struct objectBucket {
+    struct objectBucket        *next;
+    FcChar32           hash;
+    int                        id;
+};
+static struct objectBucket *FcObjectBuckets[OBJECT_HASH_SIZE];
+
+static const FcObjectType *biggest_known_types = _FcBaseObjectTypes; 
+static FcBool allocated_biggest_known_types;
+static int biggest_known_ntypes = NUM_OBJECT_TYPES;
+static int biggest_known_count = 0;
+static char * biggest_ptr;
+
+
 static FcObjectPtr
 FcObjectToPtrLookup (const char * object)
 {
-    FcObjectPtr                    i;
+    FcObjectPtr                    i = 0, n;
     const FcObjectTypeList  *l;
-    const FcObjectType     *t;
+    FcObjectType           *t = _FcUserObjectNames;
 
     for (l = _FcObjectTypes; l; l = l->next)
     {
        for (i = 0; i < l->ntypes; i++)
        {
-           t = &l->types[i];
+           t = (FcObjectType *)&l->types[i];
            if (!strcmp (object, t->object))
-               return i;
+           {
+               if (l == (FcObjectTypeList*)_FcUserObjectNames)
+                   return i + biggest_known_ntypes;
+               else
+                   return i;
+           }
        }
     }
-    return 0;
-}
 
-#define OBJECT_HASH_SIZE    31
-struct objectBucket {
-    struct objectBucket        *next;
-    FcChar32           hash;
-    int                        id;
-};
-static struct objectBucket *FcObjectBuckets[OBJECT_HASH_SIZE];
+    /* We didn't match.  Look for the correct FcObjectTypeList
+     * to replace it in-place. */
+    for (l = _FcObjectTypes; l; l = l->next)
+    {
+       if (l->types == _FcUserObjectNames)
+           break;
+    }
 
-static const FcObjectType *biggest_known_types = _FcBaseObjectTypes; 
-static FcBool allocated_biggest_known_types;
-static int biggest_known_ntypes = NUM_OBJECT_TYPES;
-static int biggest_known_count = 0;
-static char * biggest_ptr;
+    if (!_FcUserObjectNames || 
+        (l && l->types == _FcUserObjectNames && user_obj_alloc < l->ntypes))
+    {
+       int nt = user_obj_alloc + 4;
+        FcObjectType * t = realloc (_FcUserObjectNames, 
+                                   nt * sizeof (FcObjectType));
+        if (!t)
+            return -1;
+       _FcUserObjectNames = t;
+       user_obj_alloc = nt;
+    }
+
+    if (l && l->types == _FcUserObjectNames)
+    {
+       n = l->ntypes;
+       FcNameUnregisterObjectTypesFree (l->types, l->ntypes, FcFalse);
+    }
+    else
+       n = 0;
+
+    FcNameRegisterObjectTypes (_FcUserObjectNames, n+1);
+
+    for (l = _FcObjectTypes; l; l = l->next)
+    {
+       if (l->types == _FcUserObjectNames)
+       {
+           t = (FcObjectType *)l->types;
+           break;
+       }
+    }
+
+    if (!t)
+       return 0;
+
+    t[n].object = object;
+    t[n].type = FcTypeVoid;
+
+    return n+biggest_known_ntypes;
+}
 
 FcObjectPtr
 FcObjectToPtr (const char * name)
@@ -237,7 +292,10 @@ FcObjectStaticNameFini (void)
 const char *
 FcObjectPtrU (FcObjectPtr si)
 {
-    return biggest_known_types[si].object;
+    if (si < biggest_known_ntypes)
+       return biggest_known_types[si].object;
+    else
+       return _FcUserObjectNames[si-biggest_known_ntypes].object;
 }
 
 int