Skip to content

Commit 5c84526

Browse files
committed
Added validation
1 parent 38c362b commit 5c84526

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

lib/matplotlib/font_manager.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from matplotlib import afm, cbook, ft2font, rcParams
4242
from matplotlib.fontconfig_pattern import (
4343
parse_fontconfig_pattern, generate_fontconfig_pattern)
44+
from matplotlib.rcsetup import _validators
4445

4546
_log = logging.getLogger(__name__)
4647

@@ -694,7 +695,6 @@ def __init__(self,
694695
self._stretch = rcParams['font.stretch']
695696
self._size = rcParams['font.size']
696697
self._file = None
697-
self._mathtext_fontset = rcParams['mathtext.fontset']
698698

699699
if isinstance(family, str):
700700
# Treat family as a fontconfig pattern if it is the only
@@ -950,19 +950,15 @@ def set_mathtext_fontset(self, fontset):
950950
See Also
951951
--------
952952
.text.set_mathtext_fontset
953-
954-
TO DO: make the same validations as made when atributing a fontset
955-
to the rcParams[]
956953
"""
957-
958-
#if fontset not in _validators()
959-
960-
self._mathtext_fontset = \
961-
rcParams["mathtext.fontset"] if fontset is None else fontset
962-
963-
964-
965-
954+
if fontset is None:
955+
self._mathtext_fontset = rcParams['mathtext.fontset']
956+
return
957+
#this function validates the parameter fontset just as if it were
958+
#passed to rcParams['mathtext.fontset']
959+
_validators['mathtext.fontset'](fontset)
960+
self._mathtext_fontset = fontset
961+
966962
def copy(self):
967963
"""Return a copy of self."""
968964
new = type(self)()

0 commit comments

Comments
 (0)