From: Patrick Lam Date: Thu, 15 Sep 2005 20:36:44 +0000 (+0000) Subject: Revert ill-advised addition of FC_RENDER. Add strategy for handling objects X-Git-Tag: fc-2_3_90~9 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=13cdf607533ad592b896b738c5642f3685fd8053;p=fontconfig.git Revert ill-advised addition of FC_RENDER. Add strategy for handling objects 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. --- diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index b967580..312256f 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -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 diff --git a/src/fccache.c b/src/fccache.c index 1f53065..31630f1 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -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; diff --git a/src/fccfg.c b/src/fccfg.c index aaca6ef..5d6339f 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -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); diff --git a/src/fcname.c b/src/fcname.c index 5004032..b4d417e 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -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