Skip to content
Open
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
5 changes: 3 additions & 2 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,8 +1614,9 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
break
if best_font is not None and (_normalize_weight(prop.get_weight()) !=
_normalize_weight(best_font.weight)):
_log.warning('findfont: Failed to find font weight %s, now using %s.',
prop.get_weight(), best_font.weight)
_log.warning(
'findfont: Failed to find font weight %s for %s, now using %s.',
prop.get_weight(), best_font.name, best_font.weight)

if best_font is None or best_score >= 10.0:
if fallback_to_default:
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/tests/test_font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,11 @@ def test_normalize_weights():


def test_font_match_warning(caplog):
findfont(FontProperties(family=["DejaVu Sans"], weight=750))
font = 'DejaVu Sans'
findfont(FontProperties(family=[font], weight=750))
expected = f'findfont: Failed to find font weight 750 for {font}, now using 700.'
logs = [rec.message for rec in caplog.records]
assert 'findfont: Failed to find font weight 750, now using 700.' in logs
assert expected in logs


def test_mutable_fontproperty_cache_invalidation():
Expand Down
Loading