Fix score estimation for postscriptname

Before this fix:
$ fc-match :postscriptname=LiberationSans
LiberationSansNarrow.ttf: "Liberation Sans Narrow" "Regular"

After this fix:
$ fc-match :postscriptname=LiberationSans
LiberationSans-Regular.ttf: "Liberation Sans" "Regular"

See https://bugzilla.redhat.com/show_bug.cgi?id=1946871
This commit is contained in:
Akira TAGOH 2021-10-08 18:29:48 +09:00
parent 889097353e
commit 2d17232a45
1 changed files with 5 additions and 3 deletions

View File

@ -86,7 +86,7 @@ FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
const FcChar8 *v1_string = FcValueString (v1); const FcChar8 *v1_string = FcValueString (v1);
const FcChar8 *v2_string = FcValueString (v2); const FcChar8 *v2_string = FcValueString (v2);
int n; int n;
size_t len; size_t len1, len2, mlen;
*bestValue = FcValueCanonicalize (v2); *bestValue = FcValueCanonicalize (v2);
@ -95,9 +95,11 @@ FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
return 1.0; return 1.0;
n = FcStrMatchIgnoreCaseAndDelims (v1_string, v2_string, (const FcChar8 *)" -"); n = FcStrMatchIgnoreCaseAndDelims (v1_string, v2_string, (const FcChar8 *)" -");
len = strlen ((const char *)v1_string); len1 = strlen ((const char *)v1_string);
len2 = strlen ((const char *)v2_string);
mlen = FC_MAX (len1, len2);
return (double)(len - n) / (double)len; return (double)(mlen - n) / (double)mlen;
} }
static double static double