8000 Merge pull request #15249 from anntzer/fallback_to_default · matplotlib/matplotlib@770d59d · GitHub
[go: up one dir, main page]

Skip to content

Commit 770d59d

Browse files
authored
Merge pull request #15249 from anntzer/fallback_to_default
In findfont(fallback_to_default=False), throw if default font is missing
2 parents 56cfb43 + 8a543b5 commit 770d59d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,11 +1284,8 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
12841284
default_prop.set_family(self.defaultFamily[fontext])
12851285
return self.findfont(default_prop, fontext, directory, False)
12861286
else:
1287-
# This is a hard fail -- we can't find anything reasonable,
1288-
# so just return the DejaVuSans.ttf
1289-
_log.warning('findfont: Could not match %s. Returning %s.',
1290-
prop, self.defaultFont[fontext])
1291-
result = self.defaultFont[fontext]
1287+
raise ValueError(f"Failed to find font {prop}, and fallback "
1288+
f"to the default font was disabled")
12921289
else:
12931290
_log.debug('findfont: Matching %s to %s (%r) with score of %f.',
12941291
prop, best_font.name, best_font.fname, best_score)

0 commit comments

Comments
 (0)
0