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.
This commit is contained in:
Patrick Lam 2005-09-15 20:36:44 +00:00
parent 0fa237d1e0
commit 13cdf60753
4 changed files with 81 additions and 23 deletions

View File

@ -96,7 +96,6 @@ typedef int FcBool;
#define FC_CAPABILITY "capability" /* String */ #define FC_CAPABILITY "capability" /* String */
#define FC_FONTFORMAT "fontformat" /* String */ #define FC_FONTFORMAT "fontformat" /* String */
#define FC_EMBOLDEN "embolden" /* Bool - true if emboldening needed*/ #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_DIR_CACHE_FILE "fonts.cache-"FC_CACHE_VERSION
#define FC_USER_CACHE_FILE ".fonts.cache-"FC_CACHE_VERSION #define FC_USER_CACHE_FILE ".fonts.cache-"FC_CACHE_VERSION

View File

@ -420,6 +420,7 @@ FcCacheSkipToArch (int fd, const char * arch)
return -1; return -1;
bs = strtol(candidate_arch_machine_name_count, &candidate_arch, 16); 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)) if (!bs || bs < strlen (candidate_arch_machine_name_count))
return -1; return -1;

View File

@ -292,7 +292,7 @@ FcConfigBuildFonts (FcConfig *config)
for (i = 0; i < oldDirs->num; i++) for (i = 0; i < oldDirs->num; i++)
{ {
if (FcDebug () & FC_DBG_FONTSET) if (FcDebug () & FC_DBG_FONTSET)
printf ("scan dir %s\n", dir); printf ("scan dir %s\n", oldDirs->strs[i]);
FcDirScanConfig (fonts, config->fontDirs, cache, FcDirScanConfig (fonts, config->fontDirs, cache,
config->blanks, oldDirs->strs[i], config->blanks, oldDirs->strs[i],
FcFalse, config); FcFalse, config);

View File

@ -61,6 +61,7 @@ static const FcObjectType _FcBaseObjectTypes[] = {
{ FC_RGBA, FcTypeInteger, }, { FC_RGBA, FcTypeInteger, },
{ FC_SCALE, FcTypeDouble, }, { FC_SCALE, FcTypeDouble, },
{ FC_MINSPACE, FcTypeBool, }, { FC_MINSPACE, FcTypeBool, },
/* { FC_RENDER, FcTypeBool, },*/
{ FC_CHAR_WIDTH, FcTypeInteger }, { FC_CHAR_WIDTH, FcTypeInteger },
{ FC_CHAR_HEIGHT, FcTypeInteger }, { FC_CHAR_HEIGHT, FcTypeInteger },
{ FC_MATRIX, FcTypeMatrix }, { FC_MATRIX, FcTypeMatrix },
@ -70,11 +71,13 @@ static const FcObjectType _FcBaseObjectTypes[] = {
{ FC_CAPABILITY, FcTypeString }, { FC_CAPABILITY, FcTypeString },
{ FC_FONTFORMAT, FcTypeString }, { FC_FONTFORMAT, FcTypeString },
{ FC_EMBOLDEN, FcTypeBool }, { FC_EMBOLDEN, FcTypeBool },
{ FC_RENDER, FcTypeBool, },
}; };
#define NUM_OBJECT_TYPES (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0]) #define NUM_OBJECT_TYPES (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0])
static FcObjectType * _FcUserObjectNames = 0;
static int user_obj_alloc = 0;
typedef struct _FcObjectTypeList FcObjectTypeList; typedef struct _FcObjectTypeList FcObjectTypeList;
struct _FcObjectTypeList { struct _FcObjectTypeList {
@ -155,25 +158,6 @@ FcNameGetObjectType (const char *object)
return 0; return 0;
} }
static FcObjectPtr
FcObjectToPtrLookup (const char * object)
{
FcObjectPtr 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;
}
}
return 0;
}
#define OBJECT_HASH_SIZE 31 #define OBJECT_HASH_SIZE 31
struct objectBucket { struct objectBucket {
struct objectBucket *next; struct objectBucket *next;
@ -188,6 +172,77 @@ static int biggest_known_ntypes = NUM_OBJECT_TYPES;
static int biggest_known_count = 0; static int biggest_known_count = 0;
static char * biggest_ptr; static char * biggest_ptr;
static FcObjectPtr
FcObjectToPtrLookup (const char * object)
{
FcObjectPtr i = 0, n;
const FcObjectTypeList *l;
FcObjectType *t = _FcUserObjectNames;
for (l = _FcObjectTypes; l; l = l->next)
{
for (i = 0; i < l->ntypes; i++)
{
t = (FcObjectType *)&l->types[i];
if (!strcmp (object, t->object))
{
if (l == (FcObjectTypeList*)_FcUserObjectNames)
return i + biggest_known_ntypes;
else
return i;
}
}
}
/* 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;
}
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 FcObjectPtr
FcObjectToPtr (const char * name) FcObjectToPtr (const char * name)
{ {
@ -237,7 +292,10 @@ FcObjectStaticNameFini (void)
const char * const char *
FcObjectPtrU (FcObjectPtr si) 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 int