8000 Make weighting by position in the list less magical · matplotlib/matplotlib@d129186 · GitHub
[go: up one dir, main page]

Skip to content

Commit d129186

Browse files
committed
Make weighting by position in the list less magical
1 parent 2ea3dcb commit d129186

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/font_manager.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,12 @@ def score_family(self, families, family2):
10661066
options = [x.lower() for x in options]
10671067
if family2 in options:
10681068
idx = options.index(family2)
1069-
return 0.1 * ((float(idx) / len(options)) + float(i))
1069+
return ((0.1 * (float(idx) / len(options))) *
1070+
(float(i) / float(len(families))))
10701071
elif family1 == family2:
1071-
return 0.1 * float(i)
1072+
# The score should be weighted by where in the
1073+
# list the font was found.
1074+
return float(i) / float(len(families))
10721075
return 1.0
10731076

10741077
def score_style(self, style1, style2):

0 commit comments

Comments
 (0)
0