Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ad0009f

Browse filesBrowse files
authored
Merge pull request #12770 from anntzer/fontproperties-copy
Simplify implementation of FontProperties.copy().
2 parents 86a4bc7 + 258b132 commit ad0009f
Copy full SHA for ad0009f

File tree

Expand file treeCollapse file tree

1 file changed

+4
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-8
lines changed

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ def __init__(self,
567567
stretch= None,
568568
size = None,
569569
fname = None, # if set, it's a hardcoded filename to use
570-
_init = None, # used only by copy()
571570
):
572571
self._family = _normalize_font_family(rcParams['font.family'])
573572
self._slant = rcParams['font.style']
@@ -577,11 +576,6 @@ def __init__(self,
577576
self._size = rcParams['font.size']
578577
self._file = None
579578

580-
# This is used only by copy()
581-
if _init is not None:
582-
self.__dict__.update(_init.__dict__)
583-
return
584-
585579
if isinstance(family, str):
586580
# Treat family as a fontconfig pattern if it is the only
587581
# parameter provided.
@@ -812,8 +806,10 @@ def set_fontconfig_pattern(self, pattern):
812806
getattr(self, "set_" + key)(val)
813807

814808
def copy(self):
815-
"""Return a deep copy of self"""
816-
return FontProperties(_init=self)
809+
"""Return a copy of self."""
810+
new = type(self)()
811+
vars(new).update(vars(self))
812+
return new
817813

818814

819815
class JSONEncoder(json.JSONEncoder):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.