FcBool
FcConfigBuildFonts (FcConfig *config)
{
- FcFontSet *fonts;
+ FcFontSet *fonts, *cached_fonts;
FcGlobalCache *cache;
FcStrList *list;
FcChar8 *dir;
if (config->cache)
FcGlobalCacheLoad (cache, config->cache);
- list = FcConfigGetFontDirs (config);
- if (!list)
- goto bail1;
-
- while ((dir = FcStrListNext (list)))
+ cached_fonts = FcCacheRead(config, cache);
+ if (!cached_fonts)
{
- if (FcDebug () & FC_DBG_FONTSET)
- printf ("scan dir %s\n", dir);
- FcDirScanConfig (fonts, config->fontDirs, cache,
- config->blanks, dir, FcFalse, config);
+ list = FcConfigGetFontDirs (config);
+ if (!list)
+ goto bail1;
+
+ while ((dir = FcStrListNext (list)))
+ {
+ if (FcDebug () & FC_DBG_FONTSET)
+ printf ("scan dir %s\n", dir);
+ FcDirScanConfig (fonts, config->fontDirs, cache,
+ config->blanks, dir, FcFalse, config);
+ }
+
+ FcStrListDone (list);
+ }
+ else
+ {
+ int i;
+
+ for (i = 0; i < cached_fonts->nfont; i++)
+ {
+ if (FcConfigAcceptFont (config, cached_fonts->fonts[i]))
+ FcFontSetAdd (fonts, cached_fonts->fonts[i]);
+
+ cached_fonts->fonts[i] = 0; /* prevent free in FcFontSetDestroy */
+ }
+ cached_fonts->nfont = 0;
+ FcFontSetDestroy (cached_fonts);
}
-
- FcStrListDone (list);
if (FcDebug () & FC_DBG_FONTSET)
FcFontSetPrint (fonts);
}
FcBool
-FcConfigCompareValue (const FcValue left_o,
+FcConfigCompareValue (const FcValue *left_o,
FcOp op,
- const FcValue right_o)
+ const FcValue *right_o)
{
- FcValue left = left_o;
- FcValue right = right_o;
+ FcValue left = FcValueCanonicalize(left_o);
+ FcValue right = FcValueCanonicalize(right_o);
FcBool ret = FcFalse;
left = FcConfigPromote (left, right);
ret = FcStrStrIgnoreCase (left.u.s, right.u.s) != 0;
break;
case FcOpNotEqual:
- case FcOpNotContains:
ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) != 0;
break;
+ case FcOpNotContains:
+ ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
+ break;
default:
break;
}
break;
case FcOpString:
v.type = FcTypeString;
- v.u.s = e->u.sval;
+ v.u.s = FcStrStaticName(e->u.sval);
v = FcValueSave (v);
break;
case FcOpMatrix:
vl = FcConfigEvaluate (p, e->u.tree.left);
vr = FcConfigEvaluate (p, e->u.tree.right);
v.type = FcTypeBool;
- v.u.b = FcConfigCompareValue (vl, e->op, vr);
+ v.u.b = FcConfigCompareValue (&vl, e->op, &vr);
FcValueDestroy (vl);
FcValueDestroy (vr);
break;
switch (e->op) {
case FcOpPlus:
v.type = FcTypeString;
- v.u.s = FcStrPlus (vl.u.s, vr.u.s);
+ v.u.s = FcStrStaticName (FcStrPlus (vl.u.s, vr.u.s));
+
if (!v.u.s)
v.type = FcTypeVoid;
break;
e = 0;
}
- for (v = values; v; v = v->next)
+ for (v = values; v; v = FcValueListPtrU(v->next))
{
/* Compare the pattern value to the match expression value */
- if (FcConfigCompareValue (v->value, t->op, value))
+ if (FcConfigCompareValue (&v->value, t->op, &value))
{
if (!ret)
ret = v;
FcConfigValues (FcPattern *p, FcExpr *e, FcValueBinding binding)
{
FcValueList *l;
+ FcValueListPtr lp;
if (!e)
return 0;
if (e->op == FcOpComma)
{
l->value = FcConfigEvaluate (p, e->u.tree.left);
- l->next = FcConfigValues (p, e->u.tree.right, binding);
+ l->next = FcValueListPtrCreateDynamic(FcConfigValues (p, e->u.tree.right, binding));
}
else
{
l->value = FcConfigEvaluate (p, e);
- l->next = 0;
+ l->next = FcValueListPtrCreateDynamic(0);
}
l->binding = binding;
- while (l && l->value.type == FcTypeVoid)
+ lp = FcValueListPtrCreateDynamic(l);
+ while (FcValueListPtrU(lp) && FcValueListPtrU(lp)->value.type == FcTypeVoid)
{
- FcValueList *next = l->next;
-
- FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList));
- free (l);
- l = next;
+ FcValueListPtr next = FcValueListPtrU(lp)->next;
+
+ if (lp.bank == FC_BANK_DYNAMIC)
+ {
+ FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList));
+ free (l);
+ }
+ lp = next;
}
return l;
}
static FcBool
-FcConfigAdd (FcValueList **head,
+FcConfigAdd (FcValueListPtr *head,
FcValueList *position,
FcBool append,
FcValueList *new)
{
- FcValueList **prev, *last, *v;
+ FcValueListPtr *prev, last, v;
FcValueBinding sameBinding;
if (position)
sameBinding = position->binding;
else
sameBinding = FcValueBindingWeak;
- for (v = new; v; v = v->next)
- if (v->binding == FcValueBindingSame)
- v->binding = sameBinding;
+ for (v = FcValueListPtrCreateDynamic(new); FcValueListPtrU(v);
+ v = FcValueListPtrU(v)->next)
+ if (FcValueListPtrU(v)->binding == FcValueBindingSame)
+ FcValueListPtrU(v)->binding = sameBinding;
if (append)
{
if (position)
prev = &position->next;
else
- for (prev = head; *prev; prev = &(*prev)->next)
+ for (prev = head; FcValueListPtrU(*prev);
+ prev = &(FcValueListPtrU(*prev)->next))
;
}
else
{
if (position)
{
- for (prev = head; *prev; prev = &(*prev)->next)
+ for (prev = head; FcValueListPtrU(*prev);
+ prev = &(FcValueListPtrU(*prev)->next))
{
- if (*prev == position)
+ if (FcValueListPtrU(*prev) == position)
break;
}
}
if (FcDebug () & FC_DBG_EDIT)
{
- if (!*prev)
+ if (!FcValueListPtrU(*prev))
printf ("position not on list\n");
}
}
if (new)
{
- last = new;
- while (last->next)
- last = last->next;
+ last = FcValueListPtrCreateDynamic(new);
+ while (FcValueListPtrU(FcValueListPtrU(last)->next))
+ last = FcValueListPtrU(last)->next;
- last->next = *prev;
- *prev = new;
+ FcValueListPtrU(last)->next = *prev;
+ *prev = FcValueListPtrCreateDynamic(new);
}
if (FcDebug () & FC_DBG_EDIT)
}
static void
-FcConfigDel (FcValueList **head,
+FcConfigDel (FcValueListPtr *head,
FcValueList *position)
{
- FcValueList **prev;
+ FcValueListPtr *prev;
- for (prev = head; *prev; prev = &(*prev)->next)
+ for (prev = head; FcValueListPtrU(*prev);
+ prev = &(FcValueListPtrU(*prev)->next))
{
- if (*prev == position)
+ if (FcValueListPtrU(*prev) == position)
{
*prev = position->next;
- position->next = 0;
- FcValueListDestroy (position);
+ position->next = FcValueListPtrCreateDynamic(0);
+ FcValueListDestroy (FcValueListPtrCreateDynamic(position));
break;
}
}
FcPatternElt *e = FcPatternFindElt (p, object);
if (!e)
return;
- while (e->values)
- FcConfigDel (&e->values, e->values);
+ while (FcValueListPtrU(e->values))
+ FcConfigDel (&e->values, FcValueListPtrU(e->values));
}
static void
FcPatternElt *e = FcPatternFindElt (p, object);
if (!e)
return;
- if (!e->values)
+ if (!FcValueListPtrU(e->values))
FcPatternDel (p, object);
}
* Check to see if there is a match, mark the location
* to apply match-relative edits
*/
- st[i].value = FcConfigMatchValueList (m, t, st[i].elt->values);
+ st[i].value = FcConfigMatchValueList (m, t, FcValueListPtrU(st[i].elt->values));
if (!st[i].value)
break;
- if (t->qual == FcQualFirst && st[i].value != st[i].elt->values)
+ if (t->qual == FcQualFirst && st[i].value != FcValueListPtrU(st[i].elt->values))
break;
- if (t->qual == FcQualNotFirst && st[i].value == st[i].elt->values)
+ if (t->qual == FcQualNotFirst && st[i].value == FcValueListPtrU(st[i].elt->values))
break;
}
if (t)
if (t)
{
FcValueList *thisValue = st[i].value;
- FcValueList *nextValue = thisValue ? thisValue->next : 0;
+ FcValueList *nextValue = thisValue ? FcValueListPtrU(thisValue->next) : 0;
/*
* Append the new list of values after the current value
#ifdef _WIN32
if ((!path[0] || (path[strlen((char *) path)-1] != '/' &&
path[strlen((char *) path)-1] != '\\')) &&
- (file[0] != '/' && file[0] != '\\'))
+ !(file[0] == '/' ||
+ file[0] == '\\' ||
+ (isalpha (file[0]) && file[1] == ':' && (file[2] == '/' || file[2] == '\\'))))
strcat ((char *) path, "\\");
#else
if ((!path[0] || path[strlen((char *) path)-1] != '/') && file[0] != '/')