Add a new attribute `ignore-blanks' to <test>.
When this is set to "true", any blanks in the string will be ignored
on comparison. This takes effects for compare="eq" or "not_eq" only.
Also changed the behavior of the comparison on <alias> too.
FreeType very confused as it forces all widths to match.
Undo this magic by disabling the width forcing code -->
<match target="font">
- <test name="family"><string>GulimChe</string></test>
+ <test name="family" compare="eq" ignore-blanks="true"><string>GulimChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
- <test name="family"><string>DotumChe</string></test>
+ <test name="family" compare="eq" ignore-blanks="true"><string>DotumChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
- <test name="family"><string>BatangChe</string></test>
+ <test name="family" compare="eq" ignore-blanks="true"><string>BatangChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
- <test name="family"><string>GungsuhChe</string></test>
+ <test name="family" compare="eq" ignore-blanks="true"><string>GungsuhChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
</fontconfig>
-->
<match target="font">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Bitstream Vera Sans</string>
</test>
<test name="pixelsize" compare="less">
</match>
<match target="font">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Bitstream Vera Serif</string>
</test>
<test name="pixelsize" compare="less">
</match>
<match target="font">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Bitstream Vera Sans Mono</string>
</test>
<test name="pixelsize" compare="less">
<!-- We can't hint CJK fonts well, so turn off hinting for CJK fonts. -->
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Kochi Mincho</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Kochi Gothic</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Sazanami Mincho</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Sazanami Gothic</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Baekmuk Batang</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Baekmuk Dotum</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Baekmuk Gulim</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Baekmuk Headline</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>AR PL Mingti2L Big5</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>AR PL ShanHeiSun Uni</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>AR PL KaitiM Big5</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>AR PL ZenKai Uni</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>AR PL SungtiL GB</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>AR PL KaitiM GB</string>
</test>
<edit name="hinting" mode="assign">
</edit>
</match>
<match target="font">
- <test name="family" compare="eq">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>ZYSong18030</string>
</test>
<edit name="hinting" mode="assign">
<family>Zapf Dingbats</family>
<accept><family>Dingbats</family></accept>
</alias>
- <!-- workaround for Bug#19128 -->
- <alias binding="same">
- <family>ZapfDingbats</family>
- <accept><family>Dingbats</family></accept>
- </alias>
<match target="pattern">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Symbol</string>
</test>
<edit name="family" mode="append" binding="same">
<!-- Register the fonts that we actually do have -->
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Elham</string>
</test>
<edit name="foundry">
</match>
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Homa</string>
</test>
<edit name="foundry">
</match>
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Koodak</string>
</test>
<edit name="foundry">
</match>
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Nazli</string>
</test>
<edit name="foundry">
</match>
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Roya</string>
</test>
<edit name="foundry">
</match>
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Terafik</string>
</test>
<edit name="foundry">
</match>
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Titr</string>
</test>
<edit name="foundry">
<!-- Delicious 'heavy' variant says its Medium weight -->
<match target="scan">
- <test name="family">
+ <test name="family" compare="eq" ignore-blanks="true">
<string>Delicious</string>
</test>
<test name="style">
"not_contains". 'qual' may either be the default, "any", in which case the match
succeeds if any value associated with the property matches the test value, or
"all", in which case all of the values associated with the property must
-match the test value. When used in a <match target="font"> element,
+match the test value. 'ignore-blanks' takes a boolean value. if 'ignore-blanks' is set "true", any blanks in the string will be ignored on its comparison. this takes effects only when compare="eq" or compare="not_eq".
+When used in a <match target="font"> element,
the target= attribute in the <test> element selects between matching
the original pattern or the font. "default" selects whichever target the
outer <match> element has selected.
qual (any|all|first|not_first) "any"
name CDATA #REQUIRED
target (pattern|font|default) "default"
+ ignore-blanks (#PCDATA) "false"
compare (eq|not_eq|less|less_eq|more|more_eq|contains|not_contains) "eq">
<!--
FcBool
FcConfigCompareValue (const FcValue *left_o,
- FcOp op,
+ FcOp op_,
const FcValue *right_o)
{
FcValue left = FcValueCanonicalize(left_o);
FcValue right = FcValueCanonicalize(right_o);
FcBool ret = FcFalse;
+ FcOp op = FC_OP_GET_OP (op_);
+ int flags = FC_OP_GET_FLAGS (op_);
left = FcConfigPromote (left, right);
right = FcConfigPromote (right, left);
switch (op) {
case FcOpEqual:
case FcOpListing:
- ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
+ if (flags & FcOpFlagIgnoreBlanks)
+ ret = FcStrCmpIgnoreBlanksAndCase (left.u.s, right.u.s) == 0;
+ else
+ ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
break;
case FcOpContains:
ret = FcStrStrIgnoreCase (left.u.s, right.u.s) != 0;
break;
case FcOpNotEqual:
- ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) != 0;
+ if (flags & FcOpFlagIgnoreBlanks)
+ ret = FcStrCmpIgnoreBlanksAndCase (left.u.s, right.u.s) != 0;
+ else
+ ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) != 0;
break;
case FcOpNotContains:
ret = FcStrStrIgnoreCase (left.u.s, right.u.s) == 0;
FcResult r;
FcMatrix *m;
FcChar8 *str;
+ FcOp op = FC_OP_GET_OP (e->op);
- switch (e->op) {
+ switch (op) {
case FcOpInteger:
v.type = FcTypeInteger;
v.u.i = e->u.ival;
{
switch (vl.type) {
case FcTypeDouble:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeDouble;
v.u.d = vl.u.d + vr.u.d;
}
break;
case FcTypeBool:
- switch (e->op) {
+ switch (op) {
case FcOpOr:
v.type = FcTypeBool;
v.u.b = vl.u.b || vr.u.b;
}
break;
case FcTypeString:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeString;
str = FcStrPlus (vl.u.s, vr.u.s);
}
break;
case FcTypeMatrix:
- switch (e->op) {
+ switch (op) {
case FcOpTimes:
v.type = FcTypeMatrix;
m = malloc (sizeof (FcMatrix));
}
break;
case FcTypeCharSet:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeCharSet;
v.u.c = FcCharSetUnion (vl.u.c, vr.u.c);
}
break;
case FcTypeLangSet:
- switch (e->op) {
+ switch (op) {
case FcOpPlus:
v.type = FcTypeLangSet;
v.u.l = FcLangSetUnion (vl.u.l, vr.u.l);
while (e)
{
/* Compute the value of the match expression */
- if (e->op == FcOpComma)
+ if (FC_OP_GET_OP (e->op) == FcOpComma)
{
value = FcConfigEvaluate (p, e->u.tree.left);
e = e->u.tree.right;
if (!l)
return 0;
FcMemAlloc (FC_MEM_VALLIST, sizeof (FcValueList));
- if (e->op == FcOpComma)
+ if (FC_OP_GET_OP (e->op) == FcOpComma)
{
l->value = FcConfigEvaluate (p, e->u.tree.left);
l->next = FcConfigValues (p, e->u.tree.right, binding);
break;
}
}
- switch (e->op) {
+ switch (FC_OP_GET_OP (e->op)) {
case FcOpAssign:
/*
* If there was a test, then replace the matched
printf ("\n");
}
+#define FcOpFlagsPrint(_o_) \
+ { \
+ int f = FC_OP_GET_FLAGS (_o_); \
+ if (f & FcOpFlagIgnoreBlanks) \
+ printf ("(ignore blanks)"); \
+ }
+
void
-FcOpPrint (FcOp op)
+FcOpPrint (FcOp op_)
{
+ FcOp op = FC_OP_GET_OP (op_);
+
switch (op) {
case FcOpInteger: printf ("Integer"); break;
case FcOpDouble: printf ("Double"); break;
case FcOpQuest: printf ("Quest"); break;
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
- case FcOpEqual: printf ("Equal"); break;
- case FcOpNotEqual: printf ("NotEqual"); break;
+ case FcOpEqual: printf ("Equal"); FcOpFlagsPrint (op_); break;
+ case FcOpNotEqual: printf ("NotEqual"); FcOpFlagsPrint (op_); break;
case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break;
case FcOpCeil: printf ("Ceil"); break;
case FcOpRound: printf ("Round"); break;
case FcOpTrunc: printf ("Trunc"); break;
- case FcOpListing: printf ("Listing"); break;
+ case FcOpListing: printf ("Listing"); FcOpFlagsPrint (op_); break;
case FcOpInvalid: printf ("Invalid"); break;
}
}
FcExprPrint (const FcExpr *expr)
{
if (!expr) printf ("none");
- else switch (expr->op) {
+ else switch (FC_OP_GET_OP (expr->op)) {
case FcOpInteger: printf ("%d", expr->u.ival); break;
case FcOpDouble: printf ("%g", expr->u.dval); break;
case FcOpString: printf ("\"%s\"", expr->u.sval); break;
case FcOpComma:
FcExprPrint (expr->u.tree.left);
printf (" ");
- switch (expr->op) {
+ switch (FC_OP_GET_OP (expr->op)) {
case FcOpAssign: printf ("Assign"); break;
case FcOpAssignReplace: printf ("AssignReplace"); break;
case FcOpPrependFirst: printf ("PrependFirst"); break;
case FcOpAppendLast: printf ("AppendLast"); break;
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
- case FcOpEqual: printf ("Equal"); break;
- case FcOpNotEqual: printf ("NotEqual"); break;
+ case FcOpEqual: printf ("Equal"); FcOpFlagsPrint (expr->op); break;
+ case FcOpNotEqual: printf ("NotEqual"); FcOpFlagsPrint (expr->op); break;
case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break;
case FcOpMoreEqual: printf ("MoreEqual"); break;
case FcOpContains: printf ("Contains"); break;
- case FcOpListing: printf ("Listing"); break;
+ case FcOpListing: printf ("Listing"); FcOpFlagsPrint (expr->op); break;
case FcOpNotContains: printf ("NotContains"); break;
case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break;
FcOpInvalid
} FcOp;
+typedef enum _FcOpFlags {
+ FcOpFlagIgnoreBlanks = 1 << 0
+} FcOpFlags;
+
+#define FC_OP_GET_OP(_x_) ((_x_) & 0xffff)
+#define FC_OP_GET_FLAGS(_x_) (((_x_) & 0xffff0000) >> 16)
+#define FC_OP(_x_,_f_) (FC_OP_GET_OP (_x_) | ((_f_) << 16))
+
typedef struct _FcExpr {
FcOp op;
union {
* where it requires an exact match)
*/
if (FcConfigCompareValue (&fnt->value,
- FcOpListing,
+ FC_OP (FcOpListing, FcOpFlagIgnoreBlanks),
&pat->value))
break;
}
{
if (!e)
return;
- switch (e->op) {
+ switch (FC_OP_GET_OP (e->op)) {
case FcOpInteger:
break;
case FcOpDouble:
if (!expr)
return;
- switch (expr->op) {
+ switch (FC_OP_GET_OP (expr->op)) {
case FcOpInteger:
case FcOpDouble:
FcTypecheckValue (parse, FcTypeDouble, type);
FcTest *t = FcTestCreate (parse, FcMatchPattern,
FcQualAny,
(FcChar8 *) FC_FAMILY,
- FcOpEqual,
+ FC_OP (FcOpEqual, FcOpFlagIgnoreBlanks),
family);
if (test)
{
FcOp compare;
FcExpr *expr;
FcTest *test;
+ const FcChar8 *iblanks_string;
+ int flags = 0;
kind_string = FcConfigGetAttribute (parse, "target");
if (!kind_string)
return;
}
}
+ iblanks_string = FcConfigGetAttribute (parse, "ignore-blanks");
+ if (iblanks_string)
+ {
+ FcBool f = FcFalse;
+
+ if (!FcNameBool (iblanks_string, &f))
+ {
+ FcConfigMessage (parse,
+ FcSevereWarning,
+ "invalid test ignore-blanks \"%s\"", iblanks_string);
+ }
+ if (f)
+ flags |= FcOpFlagIgnoreBlanks;
+ }
expr = FcPopBinary (parse, FcOpComma);
if (!expr)
{
FcConfigMessage (parse, FcSevereWarning, "missing test expression");
return;
}
- test = FcTestCreate (parse, kind, qual, name, compare, expr);
+ test = FcTestCreate (parse, kind, qual, name, FC_OP (compare, flags), expr);
if (!test)
{
FcConfigMessage (parse, FcSevereError, "out of memory");