8000 WIP: Fix font selection by tacaswell · Pull Request #8800 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

WIP: Fix font selection #8800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve the method of judging weight
  • Loading branch information
cy18 authored and tacaswell committed Jun 26, 2017
commit 30e824829c3c27e775f57fe502be2361ad5aab86
4 changes: 3 additions & 1 deletion lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ def ttfFontProperty(font):
else:
variant = 'normal'

weight = next((w for w in weight_dict if sfnt4.find(w) >= 0), None)
sorted_weights = sorted(weight_dict.keys(), key=lambda k: len(k),
reverse=True)
weight = next((w for w in sorted_weights if sfnt4.find(w) >= 0), None)
if not weight:
if font.style_flags & ft2font.BOLD:
weight = 700
Expand Down
0