8000 Simplify implementation of FontProperties.copy(). by anntzer · Pull Request #12770 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Simplify implementation of FontProperties.copy(). #12770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/matplotlib/font_manager.py
913F
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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.
Expand Down Expand Up @@ -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):
Expand Down
0