diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 56091ac..0f4dcb9 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -72,8 +72,9 @@ typedef int FcBool; #define _FC_STRINGIFY(s) _FC_STRINGIFY_(s) #define FC_CACHE_VERSION _FC_STRINGIFY(FC_CACHE_VERSION_NUMBER) -#define FcTrue 1 #define FcFalse 0 +#define FcTrue 1 +#define FcDontCare 2 #define FC_FAMILY "family" /* String */ #define FC_STYLE "style" /* String */ diff --git a/src/fccfg.c b/src/fccfg.c index 4f38af1..e5bc04c 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -796,14 +796,18 @@ FcConfigCompareValue (const FcValue *left_o, case FcTypeBool: switch ((int) op) { case FcOpEqual: - case FcOpContains: - case FcOpListing: ret = left.u.b == right.u.b; break; + case FcOpContains: + case FcOpListing: + ret = left.u.b == right.u.b || left.u.b == FcDontCare; + break; case FcOpNotEqual: - case FcOpNotContains: ret = left.u.b != right.u.b; break; + case FcOpNotContains: + ret = !(left.u.b == right.u.b || left.u.b == FcDontCare); + break; default: break; } diff --git a/src/fcdbg.c b/src/fcdbg.c index 40e0d66..29ff44a 100644 --- a/src/fcdbg.c +++ b/src/fcdbg.c @@ -46,7 +46,10 @@ _FcValuePrintFile (FILE *f, const FcValue v) fprintf (f, "\"%s\"", v.u.s); break; case FcTypeBool: - fprintf (f, "%s", v.u.b ? "True" : "False"); + fprintf (f, + v.u.b == FcTrue ? (FcChar8 *) "True" : + v.u.b == FcFalse ? (FcChar8 *) "False" : + (FcChar8 *) "DontCare", 0); break; case FcTypeMatrix: fprintf (f, "[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy); diff --git a/src/fcmatch.c b/src/fcmatch.c index f217539..d5eaea7 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -154,8 +154,12 @@ FcCompareBool (const FcValue *v1, const FcValue *v2, FcValue *bestValue) if (v2->type != FcTypeBool || v1->type != FcTypeBool) return -1.0; - *bestValue = FcValueCanonicalize (v2); - return (double) v2->u.b != v1->u.b; + if (v2->u.b != FcDontCare) + *bestValue = FcValueCanonicalize (v2); + else + *bestValue = FcValueCanonicalize (v1); + + return (double) ((v2->u.b ^ v1->u.b) == 1); } static double diff --git a/src/fcname.c b/src/fcname.c index 77e74bc..79e413e 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -258,6 +258,11 @@ FcNameBool (const FcChar8 *v, FcBool *result) *result = FcFalse; return FcTrue; } + if (c0 == 'd' || c0 == 'x' || c0 == '2') + { + *result = FcDontCare; + return FcTrue; + } if (c0 == 'o') { c1 = v[1]; @@ -272,6 +277,11 @@ FcNameBool (const FcChar8 *v, FcBool *result) *result = FcFalse; return FcTrue; } + if (c1 == 'r') + { + *result = FcDontCare; + return FcTrue; + } } return FcFalse; } @@ -514,7 +524,10 @@ FcNameUnparseValue (FcStrBuf *buf, case FcTypeString: return FcNameUnparseString (buf, v.u.s, escape); case FcTypeBool: - return FcNameUnparseString (buf, v.u.b ? (FcChar8 *) "True" : (FcChar8 *) "False", 0); + return FcNameUnparseString (buf, + v.u.b == FcTrue ? (FcChar8 *) "True" : + v.u.b == FcFalse ? (FcChar8 *) "False" : + (FcChar8 *) "DontCare", 0); case FcTypeMatrix: sprintf ((char *) temp, "%g %g %g %g", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);