Add FcPatternFilter() (#13016)

This commit is contained in:
Behdad Esfahbod 2008-08-13 02:50:35 -04:00
parent e6f14d3c51
commit 41fc0fe68d
3 changed files with 52 additions and 0 deletions

View File

@ -77,6 +77,18 @@ Returns whether <parameter>pa</parameter> and <parameter>pb</parameter> have exa
objects in <parameter>os</parameter>. 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 @RET@ FcChar32
@FUNC@ FcPatternHash @FUNC@ FcPatternHash
@TYPE1@ const FcPattern * @ARG1@ p @TYPE1@ const FcPattern * @ARG1@ p

View File

@ -740,6 +740,9 @@ FcPatternDuplicate (const FcPattern *p);
FcPublic void FcPublic void
FcPatternReference (FcPattern *p); FcPatternReference (FcPattern *p);
FcPublic FcPattern *
FcPatternFilter (FcPattern *p, const FcObjectSet *os);
FcPublic void FcPublic void
FcValueDestroy (FcValue v); FcValueDestroy (FcValue v);

View File

@ -997,6 +997,43 @@ FcPatternAppend (FcPattern *p, FcPattern *s)
return FcTrue; 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 #define OBJECT_HASH_SIZE 31
static struct objectBucket { static struct objectBucket {
struct objectBucket *next; struct objectBucket *next;