Commit 2544bc53 authored by Behdad Esfahbod's avatar Behdad Esfahbod

Add FcDontCare value to FcBool

This can be used for FC_VARIABLE=FcDontCare for example, to opt into getting
variable fonts for clients that support using them.
parent c2fcde49
......@@ -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 */
......
......@@ -796,14 +796,18 @@ FcConfigCompareValue (const FcValue *left_o,
case FcTypeBool:
switch ((int) op) {
case FcOpEqual:
ret = left.u.b == right.u.b;
break;
case FcOpContains:
case FcOpListing:
ret = left.u.b == right.u.b;
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;
}
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment