Commit da1c9f7a authored by Akira TAGOH's avatar Akira TAGOH
Browse files

Fix score evaluation for multiple values in properties

Sometimes fonts has multiple values in family and sub-family in order to unify
other variants into one. they basically make difference in sub-family though,
they also still have standalone family and sub-family. in that case, sub-family is
likely to be Regular.

fontconfig couldn't recognize the difference between :family=Foo:style=Regular
and :family=Foo Caption:style=Regular for example because fontconfig didn't
give different score on matching result for the position of multiple values in
a cache.
Thus, when querying a font like :family=Foo:style=Regular may results
:family=Foo Caption:style=Regular. (see the test case for more details)

To fix this situation, giving different score according to the position
of multiple values in a cache as well as the position of multiple values
in a query.

Fixes fontconfig/fontconfig#283
parent d62d984e
Pipeline #348978 passed with stage
in 10 minutes and 27 seconds
......@@ -433,7 +433,7 @@ FcCompareValueList (FcObject object,
*result = FcResultTypeMismatch;
return FcFalse;
}
v = v * 1000 + j;
v = v * 1000 + j * 100 + k;
if (v < best)
{
if (bestValue)
......
......@@ -47,6 +47,7 @@ TESTDATA = \
test-45-generic.json \
test-60-generic.json \
test-90-synthetic.json \
test-style-match.json \
$(NULL)
if FREETYPE_PCF_LONG_FAMILY_NAMES
......
......@@ -48,3 +48,9 @@ for i in \
echo $RUNNER $TESTDIR/../conf.d/$i $TESTDIR/$test_json
$RUNNER $TESTDIR/../conf.d/$i $TESTDIR/$test_json
done
for i in \
test-style-match.json \
; do
echo $RUNNER $TESTDIR/$i ...
$RUNNER $TESTDIR/../conf.d/10-autohint.conf $TESTDIR/$i
done
......@@ -166,6 +166,21 @@ build_pattern (json_object *obj)
continue;
}
}
} else if (fc_o && fc_o->type == FcTypeString) {
for (i = 0; i < n; i++)
{
o = json_object_array_get_idx (iter.val, i);
type = json_object_get_type (o);
if (type != json_type_string) {
fprintf (stderr, "E: unable to convert to string\n");
continue;
}
v.type = FcTypeString;
v.u.s = (const FcChar8 *) json_object_get_string (o);
FcPatternAdd (pat, iter.key, v, FcTrue);
v.type = FcTypeVoid;
}
continue;
} else {
FcLangSet* ls = FcLangSetCreate ();
if (!ls) {
......@@ -232,7 +247,8 @@ build_pattern (json_object *obj)
fprintf (stderr, "W: unexpected object to build a pattern: (%s %s)", iter.key, json_type_to_name (json_object_get_type (iter.val)));
continue;
}
FcPatternAdd (pat, iter.key, v, FcTrue);
if (v.type != FcTypeVoid)
FcPatternAdd (pat, iter.key, v, FcTrue);
if (destroy_v)
FcValueDestroy (v);
}
......
{
"fonts": [
{
"family": [ "Foo", "Foo Caption" ],
"style": [ "Caption", "Regular" ],
"file": "/path/to/Foo-Capt.ttf",
"fontversion": 133365
},
{
"family": "Foo",
"style": "Regular",
"file": "/path/to/Foo-Regular.ttf",
"fontversion": 133365
}
],
"tests": [
{
"method": "match",
"query": {
"family": "Foo",
"style": "Regular"
},
"result": {
"family": "Foo",
"style": "Regular",
"file": "/path/to/Foo-Regular.ttf",
"fontversion": 133365
}
}
]
}
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