Skip to content

Commit 0a7c0d2

Browse files
authored
Merge pull request matplotlib#11461 from fredrik-1/text_alias_change
Fixed bug in rendering font property kwargs list
2 parents e09dece + 999d69d commit 0a7c0d2

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

lib/matplotlib/artist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ def get_aliases(self):
10801080
if not self.is_alias(func):
10811081
continue
10821082
docstring = func.__doc__
1083-
fullname = docstring[10:]
1083+
fullname = docstring.replace('`', '')[10:]
10841084
aliases.setdefault(fullname[4:], {})[name[4:]] = None
10851085
return aliases
10861086

lib/matplotlib/text.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ def _get_textbox(text, renderer):
107107

108108

109109
@cbook._define_aliases({
110-
"family": ["fontfamily"],
110+
"fontfamily": ["family"],
111111
"fontproperties": ["font_properties"],
112112
"horizontalalignment": ["ha"],
113113
"multialignment": ["ma"],
114-
"name": ["fontname"],
115-
"size": ["fontsize"],
116-
"stretch": ["fontstretch"],
117-
"style": ["fontstyle"],
118-
"variant": ["fontvariant"],
114+
"fontname": ["name"],
115+
"fontsize": ["size"],
116+
"fontstretch": ["stretch"],
117+
"fontstyle": ["style"],
118+
"fontvariant": ["variant"],
119119
"verticalalignment": ["va"],
120-
"weight": ["fontweight"],
120+
"fontweight": ["weight"],
121121
})
122122
class Text(Artist):
123123
"""Handle storing and drawing of text in window or data coordinates."""
@@ -764,27 +764,27 @@ def get_fontproperties(self):
764764
"Return the :class:`~font_manager.FontProperties` object"
765765
return self._fontproperties
766766

767-
def get_family(self):
767+
def get_fontfamily(self):
768768
"Return the list of font families used for font lookup"
769769
return self._fontproperties.get_family()
770770

771-
def get_name(self):
771+
def get_fontname(self):
772772
"Return the font name as string"
773773
return self._fontproperties.get_name()
774774

775-
def get_style(self):
775+
def get_fontstyle(self):
776776
"Return the font style as string"
777777
return self._fontproperties.get_style()
778778

779-
def get_size(self):
779+
def get_fontsize(self):
780780
"Return the font size as integer"
781781
return self._fontproperties.get_size_in_points()
782782

783-
def get_variant(self):
783+
def get_fontvariant(self):
784784
"Return the font variant as a string"
785785
return self._fontproperties.get_variant()
786786

787-
def get_weight(self):
787+
def get_fontweight(self):
788788
"Get the font weight as string or number"
789789
return self._fontproperties.get_weight()
790790

@@ -967,7 +967,7 @@ def set_linespacing(self, spacing):
967967
self._linespacing = spacing
968968
self.stale = True
969969

970-
def set_family(self, fontname):
970+
def set_fontfamily(self, fontname):
971971
"""
972972
Set the font family. May be either a single string, or a list of
973973
strings in decreasing priority. Each string may be either a real font
@@ -982,7 +982,7 @@ def set_family(self, fontname):
982982
self._fontproperties.set_family(fontname)
983983
self.stale = True
984984

985-
def set_variant(self, variant):
985+
def set_fontvariant(self, variant):
986986
"""
987987
Set the font variant, either 'normal' or 'small-caps'.
988988
@@ -993,7 +993,7 @@ def set_variant(self, variant):
993993
self._fontproperties.set_variant(variant)
994994
self.stale = True
995995

996-
def set_style(self, fontstyle):
996+
def set_fontstyle(self, fontstyle):
997997
"""
998998
Set the font style.
999999
@@ -1004,7 +1004,7 @@ def set_style(self, fontstyle):
10041004
self._fontproperties.set_style(fontstyle)
10051005
self.stale = True
10061006

1007-
def set_size(self, fontsize):
1007+
def set_fontsize(self, fontsize):
10081008
"""
10091009
Set the font size. May be either a size string, relative to
10101010
the default font size, or an absolute font size in points.
@@ -1017,7 +1017,7 @@ def set_size(self, fontsize):
10171017
self._fontproperties.set_size(fontsize)
10181018
self.stale = True
10191019

1020-
def set_weight(self, weight):
1020+
def set_fontweight(self, weight):
10211021
"""
10221022
Set the font weight.
10231023
@@ -1030,7 +1030,7 @@ def set_weight(self, weight):
10301030
self._fontproperties.set_weight(weight)
10311031
self.stale = True
10321032

1033-
def set_stretch(self, stretch):
1033+
def set_fontstretch(self, stretch):
10341034
"""
10351035
Set the font stretch (horizontal condensation or expansion).
10361036
@@ -1182,8 +1182,12 @@ def get_usetex(self):
11821182
else:
11831183
return self._usetex
11841184

1185-
def set_name(self, fontname): # One-way alias only: the getter differs.
1186-
"""alias for set_family"""
1185+
def set_fontname(self, fontname):
1186+
"""
1187+
alias for set_family
1188+
1189+
One-way alias only: the getter differs.
1190+
"""
11871191
return self.set_family(fontname)
11881192

11891193

0 commit comments

Comments
 (0)