Add FcPatternFilter() (#13016)
This commit is contained in:
parent
e6f14d3c51
commit
41fc0fe68d
|
@ -77,6 +77,18 @@ Returns whether <parameter>pa</parameter> and <parameter>pb</parameter> have exa
|
|||
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
|
||||
|
|
|
@ -740,6 +740,9 @@ FcPatternDuplicate (const FcPattern *p);
|
|||
FcPublic void
|
||||
FcPatternReference (FcPattern *p);
|
||||
|
||||
FcPublic FcPattern *
|
||||
FcPatternFilter (FcPattern *p, const FcObjectSet *os);
|
||||
|
||||
FcPublic void
|
||||
FcValueDestroy (FcValue v);
|
||||
|
||||
|
|
37
src/fcpat.c
37
src/fcpat.c
|
@ -997,6 +997,43 @@ FcPatternAppend (FcPattern *p, FcPattern *s)
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue