|
41 | 41 | from matplotlib import afm, cbook, ft2font, rcParams |
42 | 42 | from matplotlib.fontconfig_pattern import ( |
43 | 43 | parse_fontconfig_pattern, generate_fontconfig_pattern) |
| 44 | +from matplotlib.rcsetup import _validators |
44 | 45 |
|
45 | 46 | _log = logging.getLogger(__name__) |
46 | 47 |
|
@@ -694,7 +695,6 @@ def __init__(self, |
694 | 695 | self._stretch = rcParams['font.stretch'] |
695 | 696 | self._size = rcParams['font.size'] |
696 | 697 | self._file = None |
697 | | - self._mathtext_fontset = rcParams['mathtext.fontset'] |
698 | 698 |
|
699 | 699 | if isinstance(family, str): |
700 | 700 | # Treat family as a fontconfig pattern if it is the only |
@@ -950,19 +950,15 @@ def set_mathtext_fontset(self, fontset): |
950 | 950 | See Also |
951 | 951 | -------- |
952 | 952 | .text.set_mathtext_fontset |
953 | | - |
954 | | - TO DO: make the same validations as made when atributing a fontset |
955 | | - to the rcParams[] |
956 | 953 | """ |
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 | + |
966 | 962 | def copy(self): |
967 | 963 | """Return a copy of self.""" |
968 | 964 | new = type(self)() |
|
0 commit comments