Bug 33644 - Fontconfig doesn't match correctly in <test>

Warn if the multiple values is set to <test>, including the case of
in <alias> because the behavior isn't intuitive since so many users
is asking for a help to get things working for their expectation.

Use multiple <match>s or <alias>es for OR operator and
multiple <test>s for AND operator.
This commit is contained in:
Akira TAGOH 2012-05-21 13:43:20 +09:00
parent 794fb0bd6a
commit 2837c63876
2 changed files with 28 additions and 0 deletions

View File

@ -627,6 +627,29 @@ This is an example of a system-wide configuration file
&lt;family&gt;monospace&lt;/family&gt; &lt;family&gt;monospace&lt;/family&gt;
&lt;prefer&gt;&lt;family&gt;Andale Mono&lt;/family&gt;&lt;/prefer&gt; &lt;prefer&gt;&lt;family&gt;Andale Mono&lt;/family&gt;&lt;/prefer&gt;
&lt;/alias&gt; &lt;/alias&gt;
&lt;--
The example of the requirements of OR operator;
If the 'family' contains 'Courier New' OR 'Courier'
add 'monospace' as the alternative
--&gt;
&lt;match target="pattern"&gt;
&lt;test name="family" mode="eq"&gt;
&lt;string&gt;Courier New&lt;/string&gt;
&lt;/test&gt;
&lt;edit name="family" mode="prepend"&gt;
&lt;string&gt;monospace&lt;/string&gt;
&lt;/edit&gt;
&lt;/match&gt;
&lt;match target="pattern"&gt;
&lt;test name="family" mode="eq"&gt;
&lt;string&gt;Courier&lt;/string&gt;
&lt;/test&gt;
&lt;edit name="family" mode="prepend"&gt;
&lt;string&gt;monospace&lt;/string&gt;
&lt;/edit&gt;
&lt;/match&gt;
&lt;/fontconfig&gt; &lt;/fontconfig&gt;
</programlisting> </programlisting>
</refsect2> </refsect2>

View File

@ -1590,6 +1590,7 @@ FcParseAlias (FcConfigParse *parse)
case FcVStackFamily: case FcVStackFamily:
if (family) if (family)
{ {
FcConfigMessage (parse, FcSevereWarning, "Having multiple <family> in <alias> isn't supported and may not works as expected");
new = FcExprCreateOp (parse->config, vstack->u.expr, FcOpComma, family); new = FcExprCreateOp (parse->config, vstack->u.expr, FcOpComma, family);
if (!new) if (!new)
FcConfigMessage (parse, FcSevereError, "out of memory"); FcConfigMessage (parse, FcSevereError, "out of memory");
@ -2204,6 +2205,10 @@ FcParseTest (FcConfigParse *parse)
FcConfigMessage (parse, FcSevereWarning, "missing test expression"); FcConfigMessage (parse, FcSevereWarning, "missing test expression");
return; return;
} }
if (expr->op == FcOpComma)
{
FcConfigMessage (parse, FcSevereWarning, "Having multiple values in <test> isn't supported and may not works as expected");
}
test = FcTestCreate (parse, kind, qual, name, FC_OP (compare, flags), expr); test = FcTestCreate (parse, kind, qual, name, FC_OP (compare, flags), expr);
if (!test) if (!test)
{ {