/*
- * $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.14 2002/05/31 23:21:24 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.15 2002/06/02 20:52:06 keithp Exp $
*
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
*
FcPatternDestroy (FcPattern *p);
FcBool
-FcPatternEqual (FcPattern *pa, FcPattern *pb);
+FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
+
+FcBool
+FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os);
FcBool
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
/*
- * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.8 2002/06/02 19:51:36 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.7 2002/05/29 08:21:33 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
{
if (list)
{
- FcPatternElt *e = FcPatternFind (p, object, FcTrue);
+ FcPatternElt *e = FcPatternInsertElt (p, object);
if (!e)
return;
FcConfigPatternDel (FcPattern *p,
const char *object)
{
- FcPatternElt *e = FcPatternFind (p, object, FcFalse);
+ FcPatternElt *e = FcPatternFindElt (p, object);
if (!e)
return;
while (e->values)
FcConfigPatternCanon (FcPattern *p,
const char *object)
{
- FcPatternElt *e = FcPatternFind (p, object, FcFalse);
+ FcPatternElt *e = FcPatternFindElt (p, object);
if (!e)
return;
if (!e->values)
printf ("FcConfigSubstitute test ");
FcTestPrint (t);
}
- st[i].elt = FcPatternFind (p, t->field, FcFalse);
+ st[i].elt = FcPatternFindElt (p, t->field);
/*
* If there's no such field in the font,
* then FcQualAll matches while FcQualAny does not
* If there was a test, then replace the matched
* value with the new list of values
*/
- if (t && st[i].elt)
+ if (t)
{
FcValueList *thisValue = st[i].value;
FcValueList *nextValue = thisValue ? thisValue->next : 0;
/*
- * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.11 2002/05/31 04:42:42 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.12 2002/05/31 23:21:25 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
FcValueListDestroy (FcValueList *l);
FcPatternElt *
-FcPatternFind (FcPattern *p, const char *object, FcBool insert);
+FcPatternFindElt (const FcPattern *p, const char *object);
+
+FcPatternElt *
+FcPatternInsertElt (FcPattern *p, const char *object);
/* fcrender.c */
/*
- * $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.3 2002/05/21 17:06:22 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.4 2002/06/02 21:07:56 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
{
int s;
const char **objects;
+ int high, low, mid, c;
if (os->nobject == os->sobject)
{
os->objects = objects;
os->sobject = s;
}
- os->objects[os->nobject++] = object;
+ high = os->nobject - 1;
+ low = 0;
+ mid = 0;
+ c = 1;
+ while (low <= high)
+ {
+ mid = (low + high) >> 1;
+ c = strcmp (os->objects[mid], object);
+ if (c == 0)
+ return FcTrue;
+ if (c < 0)
+ low = mid + 1;
+ else
+ high = mid - 1;
+ }
+ if (c < 0)
+ mid++;
+ memmove (os->objects + mid + 1, os->objects + mid, os->nobject - mid);
+ os->objects[mid] = object;
+ os->nobject++;
return FcTrue;
}
return FcTrue;
}
-/*
- * FcTrue iff all objects in "p" match "font"
- */
-
static FcBool
-FcListPatternMatchAny (FcPattern *p,
- FcPattern *font)
+FcListPatternEqual (FcPattern *p1,
+ FcPattern *p2,
+ FcObjectSet *os)
{
int i;
- FcPatternElt *e;
+ FcPatternElt *e1, *e2;
- for (i = 0; i < p->num; i++)
+ for (i = 0; i < os->nobject; i++)
{
- e = FcPatternFind (font, p->elts[i].object, FcFalse);
- if (!e)
+ e1 = FcPatternFindElt (p1, os->objects[i]);
+ e2 = FcPatternFindElt (p2, os->objects[i]);
+ if (!e1 && !e2)
+ return FcTrue;
+ if (!e1 || !e2)
return FcFalse;
- if (!FcListValueListMatchAny (p->elts[i].values, e->values))
+ if (!FcListValueListEqual (e1->values, e2->values))
return FcFalse;
}
return FcTrue;
}
+/*
+ * FcTrue iff all objects in "p" match "font"
+ */
+
static FcBool
-FcListPatternEqual (FcPattern *p1,
- FcPattern *p2,
- FcObjectSet *os)
+FcListPatternMatchAny (FcPattern *p,
+ FcPattern *font)
{
int i;
- FcPatternElt *e1, *e2;
+ FcPatternElt *e;
- for (i = 0; i < os->nobject; i++)
+ for (i = 0; i < p->num; i++)
{
- e1 = FcPatternFind (p1, os->objects[i], FcFalse);
- e2 = FcPatternFind (p2, os->objects[i], FcFalse);
- if (!e1 && !e2)
- return FcTrue;
- if (!e1 || !e2)
+ e = FcPatternFindElt (font, p->elts[i].object);
+ if (!e)
return FcFalse;
- if (!FcListValueListEqual (e1->values, e2->values))
+ if (!FcListValueListMatchAny (p->elts[i].values, e->values))
return FcFalse;
}
return FcTrue;
for (n = 0; n < os->nobject; n++)
{
- e = FcPatternFind (font, os->objects[n], FcFalse);
+ e = FcPatternFindElt (font, os->objects[n]);
if (e)
h = h ^ FcListValueListHash (e->values);
}
for (o = 0; o < os->nobject; o++)
{
- e = FcPatternFind (font, os->objects[o], FcFalse);
+ e = FcPatternFindElt (font, os->objects[o]);
if (e)
{
for (v = e->values; v; v = v->next)
/*
- * $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.8 2002/05/31 04:42:42 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.9 2002/06/02 21:07:56 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
for (i = 0; i < font->num; i++)
{
fe = &font->elts[i];
- pe = FcPatternFind (pat, fe->object, FcFalse);
+ pe = FcPatternFindElt (pat, fe->object);
if (pe)
{
if (!FcCompareValueList (pe->object, pe->values,
for (i = 0; i < pat->num; i++)
{
pe = &pat->elts[i];
- fe = FcPatternFind (font, pe->object, FcFalse);
+ fe = FcPatternFindElt (font, pe->object);
if (!fe)
FcPatternAdd (new, pe->object, pe->values->value, FcTrue);
}
/*
- * $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.5 2002/06/02 20:52:06 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.6 2002/06/02 21:07:57 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
const FcObjectType *o;
FcStrBufInit (&buf, buf_static, sizeof (buf_static));
- e = FcPatternFind (pat, FC_FAMILY, FcFalse);
+ e = FcPatternFindElt (pat, FC_FAMILY);
if (e)
{
if (!FcNameUnparseValueList (&buf, e->values, (FcChar8 *) FC_ESCAPE_FIXED))
goto bail0;
}
- e = FcPatternFind (pat, FC_SIZE, FcFalse);
+ e = FcPatternFindElt (pat, FC_SIZE);
if (e)
{
if (!FcNameUnparseString (&buf, (FcChar8 *) "-", 0))
!strcmp (o->object, FC_FILE))
continue;
- e = FcPatternFind (pat, o->object, FcFalse);
+ e = FcPatternFindElt (pat, o->object);
if (e)
{
if (!FcNameUnparseString (&buf, (FcChar8 *) ":", 0))
/*
- * $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.5 2002/05/29 22:07:33 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.6 2002/05/31 23:21:25 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
free (p);
}
-FcPatternElt *
-FcPatternFind (FcPattern *p, const char *object, FcBool insert)
+static int
+FcPatternPosition (const FcPattern *p, const char *object)
{
- int i;
- int s;
- FcPatternElt *e;
-
- int low, high;
+ int low, high, mid, c;
- /* match existing */
low = 0;
- high = p->num;
-
- while (low + 1 < high)
+ high = p->num - 1;
+ c = 1;
+ mid = 0;
+ while (low <= high)
{
- i = (low + high) >> 1;
- s = strcmp (object, p->elts[i].object);
- if (s == 0)
- return &p->elts[i];
- if (s > 0)
- low = i;
+ mid = (low + high) >> 1;
+ c = strcmp (p->elts[mid].object, object);
+ if (c == 0)
+ return mid;
+ if (c < 0)
+ low = mid + 1;
else
- high = i;
- }
-
- i = low;
- while (i < high)
- {
- s = strcmp (object, p->elts[i].object);
- if (s == 0)
- return &p->elts[i];
- if (s < 0)
- break;
- i++;
+ high = mid - 1;
}
+ if (c < 0)
+ mid++;
+ return -(mid + 1);
+}
- if (!insert)
+FcPatternElt *
+FcPatternFindElt (const FcPattern *p, const char *object)
+{
+ int i = FcPatternPosition (p, object);
+ if (i < 0)
return 0;
+ return &p->elts[i];
+}
- /* grow array */
- if (p->num + 1 >= p->size)
+FcPatternElt *
+FcPatternInsertElt (FcPattern *p, const char *object)
+{
+ int i;
+ FcPatternElt *e;
+
+ i = FcPatternPosition (p, object);
+ if (i < 0)
{
- s = p->size + 16;
- if (p->elts)
- e = (FcPatternElt *) realloc (p->elts, s * sizeof (FcPatternElt));
- else
- e = (FcPatternElt *) malloc (s * sizeof (FcPatternElt));
- if (!e)
- return FcFalse;
- p->elts = e;
- if (p->size)
- FcMemFree (FC_MEM_PATELT, p->size * sizeof (FcPatternElt));
- FcMemAlloc (FC_MEM_PATELT, s * sizeof (FcPatternElt));
- while (p->size < s)
+ i = -i - 1;
+
+ /* grow array */
+ if (p->num + 1 >= p->size)
{
- p->elts[p->size].object = 0;
- p->elts[p->size].values = 0;
- p->size++;
+ int s = p->size + 16;
+ if (p->elts)
+ e = (FcPatternElt *) realloc (p->elts, s * sizeof (FcPatternElt));
+ else
+ e = (FcPatternElt *) malloc (s * sizeof (FcPatternElt));
+ if (!e)
+ return FcFalse;
+ p->elts = e;
+ if (p->size)
+ FcMemFree (FC_MEM_PATELT, p->size * sizeof (FcPatternElt));
+ FcMemAlloc (FC_MEM_PATELT, s * sizeof (FcPatternElt));
+ while (p->size < s)
+ {
+ p->elts[p->size].object = 0;
+ p->elts[p->size].values = 0;
+ p->size++;
+ }
}
+
+ /* move elts up */
+ memmove (p->elts + i + 1,
+ p->elts + i,
+ sizeof (FcPatternElt) *
+ (p->num - i));
+
+ /* bump count */
+ p->num++;
+
+ p->elts[i].object = object;
+ p->elts[i].values = 0;
}
- /* move elts up */
- memmove (p->elts + i + 1,
- p->elts + i,
- sizeof (FcPatternElt) *
- (p->num - i));
-
- /* bump count */
- p->num++;
-
- p->elts[i].object = object;
- p->elts[i].values = 0;
-
return &p->elts[i];
}
FcBool
-FcPatternEqual (FcPattern *pa, FcPattern *pb)
+FcPatternEqual (const FcPattern *pa, const FcPattern *pb)
{
int i;
return FcTrue;
}
+FcBool
+FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os)
+{
+ FcPatternElt *ea, *eb;
+ int i;
+
+ for (i = 0; i < os->nobject; i++)
+ {
+ ea = FcPatternFindElt (pa, os->objects[i]);
+ eb = FcPatternFindElt (pb, os->objects[i]);
+ if (ea)
+ {
+ if (!eb)
+ return FcFalse;
+ if (!FcValueListEqual (ea->values, eb->values))
+ return FcFalse;
+ }
+ else
+ {
+ if (eb)
+ return FcFalse;
+ }
+ }
+ return FcTrue;
+}
+
FcBool
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
{
new->value = value;
new->next = 0;
- e = FcPatternFind (p, object, FcTrue);
+ e = FcPatternInsertElt (p, object);
if (!e)
goto bail2;
FcPatternElt *e;
int i;
- e = FcPatternFind (p, object, FcFalse);
+ e = FcPatternFindElt (p, object);
if (!e)
return FcFalse;
FcPatternElt *e;
FcValueList *l;
- e = FcPatternFind (p, object, FcFalse);
+ e = FcPatternFindElt (p, object);
if (!e)
return FcResultNoMatch;
for (l = e->values; l; l = l->next)