objects in <parameter>os</parameter>.
@@
+@RET@ FcPattern *
+@FUNC@ FcPatternFilter
+@TYPE1@ FcPattern * @ARG1@ p
+@TYPE2@ const FcObjectSet * @ARG1@ os
+@PURPOSE@ Filter the objects of pattern
+@DESC@
+Returns a new pattern that only has those objects from
+<parameter>p</parameter> that are in <parameter>os</parameter>.
+If <parameter>os</parameter> is NULL, a duplicate of
+<parameter>p</parameter> is returned.
+@@
+
@RET@ FcChar32
@FUNC@ FcPatternHash
@TYPE1@ const FcPattern * @ARG1@ p
FcPublic void
FcPatternReference (FcPattern *p);
+FcPublic FcPattern *
+FcPatternFilter (FcPattern *p, const FcObjectSet *os);
+
FcPublic void
FcValueDestroy (FcValue v);
return FcTrue;
}
+FcPattern *
+FcPatternFilter (FcPattern *p, const FcObjectSet *os)
+{
+ int i;
+ FcPattern *ret;
+ FcPatternElt *e;
+ FcValueListPtr v;
+
+ if (!os)
+ return FcPatternDuplicate (p);
+
+ ret = FcPatternCreate ();
+ if (!ret)
+ return NULL;
+
+ for (i = 0; i < os->nobject; i++)
+ {
+ FcObject object = FcObjectFromName (os->objects[i]);
+ e = FcPatternObjectFindElt (p, object);
+ if (e)
+ {
+ for (v = FcPatternEltValues(e); v; v = FcValueListNext(v))
+ {
+ if (!FcPatternObjectAddWithBinding (ret, e->object,
+ FcValueCanonicalize(&v->value),
+ v->binding, FcTrue))
+ goto bail0;
+ }
+ }
+ }
+ return p;
+
+bail0:
+ FcPatternDestroy (ret);
+ return NULL;
+}
+
#define OBJECT_HASH_SIZE 31
static struct objectBucket {
struct objectBucket *next;