diff options
author | Akira TAGOH <akira@tagoh.org> | 2021-10-08 18:29:48 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2021-10-08 18:30:09 +0900 |
commit | 2d17232a45c55cdb8d082a3bcf13d423928fcd5e (patch) | |
tree | c360b903a72a308359040f7a4ea612f0397ceacf /src | |
parent | 889097353ecd7b061ae7cf677e3db56db77a135f (diff) | |
download | fontconfig-2d17232a45c55cdb8d082a3bcf13d423928fcd5e.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/fcmatch.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/fcmatch.c b/src/fcmatch.c index 80d5687..cf0876c 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -86,7 +86,7 @@ FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue) const FcChar8 *v1_string = FcValueString (v1); const FcChar8 *v2_string = FcValueString (v2); int n; - size_t len; + size_t len1, len2, mlen; *bestValue = FcValueCanonicalize (v2); @@ -95,9 +95,11 @@ FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue) return 1.0; 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 |