From 38003c06344cfc2a9ea0b7c15bd1b7006915ca6d Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 1 Nov 2020 19:42:16 +0100 Subject: [PATCH] Resolve mathtext.fontset at FontProperties creation time. ... instead of delaying it until rendering time. This makes it consistent with the behavior of `rcParams["font.family"]`. (While lazy resolution may be useful too, it seems better to be consistent with family, whose behavior is constrained by backcompat, whereas mathtext_fontfamily has not been released yet.) --- lib/matplotlib/font_manager.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 29a2facb7f22..8d89f7b113ba 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -897,8 +897,6 @@ def get_math_fontfamily(self): The default font is :rc:`mathtext.fontset`. """ - if self._math_fontfamily is None: - return rcParams['mathtext.fontset'] return self._math_fontfamily def set_math_fontfamily(self, fontfamily): @@ -921,13 +919,12 @@ def set_math_fontfamily(self, fontfamily): .text.Text.get_math_fontfamily """ if fontfamily is None: - self._math_fontfamily = None - return - - valid_fonts = _validators['mathtext.fontset'].valid.values() - # _check_in_list() Validates the parameter math_fontfamily as - # if it were passed to rcParams['mathtext.fontset'] - _api.check_in_list(valid_fonts, math_fontfamily=fontfamily) + fontfamily = rcParams['mathtext.fontset'] + else: + valid_fonts = _validators['mathtext.fontset'].valid.values() + # _check_in_list() Validates the parameter math_fontfamily as + # if it were passed to rcParams['mathtext.fontset'] + _api.check_in_list(valid_fonts, math_fontfamily=fontfamily) self._math_fontfamily = fontfamily def copy(self):