FcFontList broken when presented a charset - was comparing inclusion in the

wrong direction
This commit is contained in:
Keith Packard 2003-04-24 15:29:33 +00:00
parent 7d5c134a0a
commit f45d39b1fd
2 changed files with 19 additions and 4 deletions

View File

@ -578,12 +578,12 @@ FcConfigCompareValue (const FcValue m_o,
case FcTypeCharSet: case FcTypeCharSet:
switch (op) { switch (op) {
case FcOpContains: case FcOpContains:
/* m contains v if v is a subset of m */ /* v contains m if m is a subset of v */
ret = FcCharSetIsSubset (v.u.c, m.u.c); ret = FcCharSetIsSubset (m.u.c, v.u.c);
break; break;
case FcOpNotContains: case FcOpNotContains:
/* m contains v if v is a subset of m */ /* v contains m if m is a subset of v */
ret = !FcCharSetIsSubset (v.u.c, m.u.c); ret = !FcCharSetIsSubset (m.u.c, v.u.c);
break; break;
case FcOpEqual: case FcOpEqual:
ret = FcCharSetEqual (m.u.c, v.u.c); ret = FcCharSetEqual (m.u.c, v.u.c);

View File

@ -596,6 +596,9 @@ FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
{ {
an = a->numbers[ai]; an = a->numbers[ai];
bn = b->numbers[bi]; bn = b->numbers[bi];
/*
* Check matching pages
*/
if (an == bn) if (an == bn)
{ {
FcChar32 *am = a->leaves[ai]->map; FcChar32 *am = a->leaves[ai]->map;
@ -604,6 +607,9 @@ FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
if (am != bm) if (am != bm)
{ {
int i = 256/32; int i = 256/32;
/*
* Does am have any bits not in bm?
*/
while (i--) while (i--)
if (*am++ & ~*bm++) if (*am++ & ~*bm++)
return FcFalse; return FcFalse;
@ -611,6 +617,9 @@ FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
ai++; ai++;
bi++; bi++;
} }
/*
* Does a have any pages not in b?
*/
else if (an < bn) else if (an < bn)
return FcFalse; return FcFalse;
else else
@ -618,6 +627,9 @@ FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
int low = bi + 1; int low = bi + 1;
int high = b->num - 1; int high = b->num - 1;
/*
* Search for page 'an' in 'b'
*/
while (low <= high) while (low <= high)
{ {
int mid = (low + high) >> 1; int mid = (low + high) >> 1;
@ -637,6 +649,9 @@ FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
bi++; bi++;
} }
} }
/*
* did we look at every page?
*/
return ai >= a->num; return ai >= a->num;
} }