Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38003c0

Browse files
committed
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.)
1 parent 5ba3911 commit 38003c0

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

lib/matplotlib/font_manager.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -897,8 +897,6 @@ def get_math_fontfamily(self):
897897
898898
The default font is :rc:`mathtext.fontset`.
899899
"""
900-
if self._math_fontfamily is None:
901-
return rcParams['mathtext.fontset']
902900
return self._math_fontfamily
903901

904902
def set_math_fontfamily(self, fontfamily):
@@ -921,13 +919,12 @@ def set_math_fontfamily(self, fontfamily):
921919
.text.Text.get_math_fontfamily
922920
"""
923921
if fontfamily is None:
924-
self._math_fontfamily = None
925-
return
926-
927-
valid_fonts = _validators['mathtext.fontset'].valid.values()
928-
# _check_in_list() Validates the parameter math_fontfamily as
929-
# if it were passed to rcParams['mathtext.fontset']
930-
_api.check_in_list(valid_fonts, math_fontfamily=fontfamily)
922+
fontfamily = rcParams['mathtext.fontset']
923+
else:
924+
valid_fonts = _validators['mathtext.fontset'].valid.values()
925+
# _check_in_list() Validates the parameter math_fontfamily as
926+
# if it were passed to rcParams['mathtext.fontset']
927+
_api.check_in_list(valid_fonts, math_fontfamily=fontfamily)
931928
self._math_fontfamily = fontfamily
932929

933930
def copy(self):

0 commit comments

Comments
 (0)