diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index aef7f92cea07..c87394e39419 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -567,7 +567,6 @@ def __init__(self, stretch= None, size = None, fname = None, # if set, it's a hardcoded filename to use - _init = None, # used only by copy() ): self._family = _normalize_font_family(rcParams['font.family']) self._slant = rcParams['font.style'] @@ -577,11 +576,6 @@ def __init__(self, self._size = rcParams['font.size'] self._file = None - # This is used only by copy() - if _init is not None: - self.__dict__.update(_init.__dict__) - return - if isinstance(family, str): # Treat family as a fontconfig pattern if it is the only # parameter provided. @@ -812,8 +806,10 @@ def set_fontconfig_pattern(self, pattern): getattr(self, "set_" + key)(val) def copy(self): - """Return a deep copy of self""" - return FontProperties(_init=self) + """Return a copy of self.""" + new = type(self)() + vars(new).update(vars(self)) + return new class JSONEncoder(json.JSONEncoder):