]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcname.c
Overhaul the serialization system to create one mmapable file per directory
[fontconfig.git] / src / fcname.c
index 776fba863adbee08aaf6c9f62097ebb254d4e45b..1cdba565305ec3c77ef1b4d121ae57f15fe62925 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $RCSId: xc/lib/fontconfig/src/fcname.c,v 1.15 2002/09/26 00:17:28 keithp Exp $
  *
- * Copyright © 2000 Keith Packard
+ * Copyright Â© 2000 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -68,6 +68,8 @@ static const FcObjectType _FcBaseObjectTypes[] = {
     { FC_LANG,         FcTypeLangSet },
     { FC_FONTVERSION,  FcTypeInteger },
     { FC_CAPABILITY,   FcTypeString },
+    { FC_FONTFORMAT,   FcTypeString },
+    { FC_EMBOLDEN,     FcTypeBool },
 };
 
 #define NUM_OBJECT_TYPES    (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0])
@@ -143,6 +145,74 @@ FcNameGetObjectType (const char *object)
     return 0;
 }
 
+static int objectptr_count = 1;
+static int objectptr_alloc = 0;
+static int * objectptr_indices = 0;
+
+void
+FcObjectNewBank(void)
+{
+    objectptr_count = 1;
+    objectptr_alloc = 0;
+    objectptr_indices = 0;
+}
+
+// XXX todo: introduce a hashtable for faster lookup
+FcObjectPtr
+FcObjectToPtr (const char * object)
+{
+    int                            i;
+    const FcObjectTypeList  *l;
+    const FcObjectType     *t;
+    
+    for (l = _FcObjectTypes; l; l = l->next)
+    {
+       for (i = 0; i < l->ntypes; i++)
+       {
+           t = &l->types[i];
+           if (!strcmp (object, t->object))
+               return i;
+       }
+    }
+    abort();
+    return 0;
+}
+
+const char *
+FcObjectPtrU (FcObjectPtr si)
+{
+    return _FcObjectTypes->types[si].object;
+}
+
+int
+FcObjectNeededBytes (FcObjectPtr si)
+{
+    return 0;
+}
+
+void *
+FcObjectDistributeBytes (FcCache * metadata, void * block_ptr)
+{
+    return block_ptr;
+}
+
+FcObjectPtr
+FcObjectSerialize (FcObjectPtr si)
+{
+    return si;
+}
+
+void
+FcObjectUnserialize (FcCache metadata, FcConfig * config, void *block_ptr)
+{
+}
+
+int
+FcObjectPtrCompare (const FcObjectPtr a, const FcObjectPtr b)
+{
+    return a - b;
+}
+
 static const FcConstant _FcBaseConstants[] = {
     { (FcChar8 *) "thin",          "weight",   FC_WEIGHT_THIN, },
     { (FcChar8 *) "extralight",            "weight",   FC_WEIGHT_EXTRALIGHT, },
@@ -273,7 +343,7 @@ FcNameConstant (FcChar8 *string, int *result)
 }
 
 FcBool
-FcNameBool (FcChar8 *v, FcBool *result)
+FcNameBool (const FcChar8 *v, FcBool *result)
 {
     char    c0, c1;
 
@@ -319,7 +389,7 @@ FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m)
            v.u.i = atoi ((char *) string);
        break;
     case FcTypeString:
-       v.u.s = string;
+       v.u.s = FcObjectStaticName(string);
        break;
     case FcTypeBool:
        if (!FcNameBool (string, &v.u.b))
@@ -501,10 +571,12 @@ FcNameUnparseString (FcStrBuf         *buf,
 
 static FcBool
 FcNameUnparseValue (FcStrBuf   *buf,
-                   FcValue     v,
+                   int         bank,
+                   FcValue     *v0,
                    FcChar8     *escape)
 {
     FcChar8    temp[1024];
+    FcValue v = FcValueCanonicalize(v0);
     
     switch (v.type) {
     case FcTypeVoid:
@@ -535,14 +607,14 @@ FcNameUnparseValue (FcStrBuf      *buf,
 
 static FcBool
 FcNameUnparseValueList (FcStrBuf       *buf,
-                       FcValueList     *v,
+                       FcValueListPtr  v,
                        FcChar8         *escape)
 {
-    while (v)
+    while (FcValueListPtrU(v))
     {
-       if (!FcNameUnparseValue (buf, v->value, escape))
+       if (!FcNameUnparseValue (buf, v.bank, &FcValueListPtrU(v)->value, escape))
            return FcFalse;
-       if ((v = v->next))
+       if (FcValueListPtrU(v = FcValueListPtrU(v)->next))
            if (!FcNameUnparseString (buf, (FcChar8 *) ",", 0))
                return FcFalse;
     }