8000 Improve the method of judging weight · matplotlib/matplotlib@30e8248 · GitHub
[go: up one dir, main page]

Skip to content

Commit 30e8248

Browse files
cy18tacaswell
authored andcommitted
Improve the method of judging weight
1 parent 03dd8e4 commit 30e8248

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,9 @@ def ttfFontProperty(font):
435435
else:
436436
variant = 'normal'
437437

438-
weight = next((w for w in weight_dict if sfnt4.find(w) >= 0), None)
438+
sorted_weights = sorted(weight_dict.keys(), key=lambda k: len(k),
439+
reverse=True)
440+
weight = next((w for w in sorted_weights if sfnt4.find(w) >= 0), None)
439441
if not weight:
440442
if font.style_flags & ft2font.BOLD:
441443
weight = 700

0 commit comments

Comments
 (0)
0