Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/2019-06-09-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Changes in font weight guessing
```````````````````````````````

Font weight guessing now first checks for the presence of the FT_STYLE_BOLD_FLAG
before trying to match substrings in the font name. In particular, this means
that Times New Roman Bold is now correctly detected as bold, not normal weight.
10 changes: 4 additions & 6 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,10 @@ def ttfFontProperty(font):
else:
variant = 'normal'

weight = next((w for w in weight_dict if sfnt4.find(w) >= 0), None)
if not weight:
if font.style_flags & ft2font.BOLD:
weight = 700
else:
weight = 400
if font.style_flags & ft2font.BOLD:
weight = 700
else:
weight = next((w for w in weight_dict if w in sfnt4), 400)

# Stretch can be absolute and relative
# Absolute stretches are: ultra-condensed, extra-condensed, condensed,
Expand Down