@@ -682,30 +682,21 @@ def __init__(self, family=None, style=None, variant=None, weight=None,
682
682
stretch = None , size = None ,
683
683
fname = None , # if set, it's a hardcoded filename to use
684
684
math_fontfamily = None ):
685
- self ._family = _normalize_font_family (rcParams ['font.family' ])
686
- self ._slant = rcParams ['font.style' ]
687
- self ._variant = rcParams ['font.variant' ]
688
- self ._weight = rcParams ['font.weight' ]
689
- self ._stretch = rcParams ['font.stretch' ]
690
- self ._size = rcParams ['font.size' ]
691
- self ._file = None
692
- self .set_math_fontfamily (math_fontfamily )
693
-
694
- if isinstance (family , str ):
695
- # Treat family as a fontconfig pattern if it is the only
696
- # parameter provided.
697
- if (style is None and variant is None and weight is None and
698
- stretch is None and size is None and fname is None ):
699
- self .set_fontconfig_pattern (family )
700
- return
701
-
702
685
self .set_family (family )
703
686
self .set_style (style )
704
687
self .set_variant (variant )
705
688
self .set_weight (weight )
706
689
self .set_stretch (stretch )
707
690
self .set_file (fname )
708
691
self .set_size (size )
692
+ self .set_math_fontfamily (math_fontfamily )
693
+ # Treat family as a fontconfig pattern if it is the only parameter
694
+ # provided. Even in that case, call the other setters first to set
695
+ # attributes not specified by the pattern to the rcParams defaults.
696
+ if (isinstance (family , str )
697
+ and style is None and variant is None and weight is None
698
+ and stretch is None and size is None and fname is None ):
699
+ self .set_fontconfig_pattern (family )
709
700
710
701
@classmethod
711
702
def _from_any (cls , arg ):
@@ -736,7 +727,7 @@ def __hash__(self):
736
727
self .get_variant (),
737
728
self .get_weight (),
738
729
self .get_stretch (),
739
- self .get_size_in_points (),
730
+ self .get_size (),
740
731
self .get_file (),
741
732
self .get_math_fontfamily ())
742
733
return hash (l )
@@ -764,7 +755,6 @@ def get_style(self):
764
755
Return the font style. Values are: 'normal', 'italic' or 'oblique'.
765
756
"""
766
757
return self ._slant
767
- get_slant = get_style
768
758
769
759
def get_variant (self ):
770
760
"""
@@ -795,9 +785,6 @@ def get_size(self):
795
785
"""
796
786
return self ._size
797
787
798
- def get_size_in_points (self ):
799
- return self ._size
800
-
801
788
def get_file (self ):
802
789
"""
803
790
Return the filename of the associated font.
@@ -824,8 +811,9 @@ def set_family(self, family):
824
811
"""
825
812
if family is None :
826
813
family = rcParams ['font.family' ]
827
- self ._family = _normalize_font_family (family )
828
- set_name = set_family
814
+ if isinstance (family , str ):
815
+ family = [family ]
816
+ self ._family = family
829
817
830
818
def set_style (self , style ):
831
819
"""
@@ -835,7 +823,6 @@ def set_style(self, style):
835
823
style = rcParams ['font.style' ]
836
824
_api .check_in_list (['normal' , 'italic' , 'oblique' ], style = style )
837
825
self ._slant = style
838
- set_slant = set_style
839
826
840
827
def set_variant (self , variant ):
841
828
"""
@@ -967,6 +954,12 @@ def copy(self):
967
954
"""Return a copy of self."""
968
955
return copy .copy (self )
969
956
957
+ # Aliases
958
+ set_name = set_family
959
+ get_slant = get_style
960
+ set_slant = set_style
961
+ get_size_in_points = get_size
962
+
970
963
971
964
class _JSONEncoder (json .JSONEncoder ):
972
965
def default (self , o ):
@@ -1040,12 +1033,6 @@ def json_load(filename):
1040
1033
return json .load (fh , object_hook = _json_decode )
1041
1034
1042
1035
1043
- def _normalize_font_family (family ):
1044
- if isinstance (family , str ):
1045
- family = [family ]
1046
- return family
1047
-
1048
-
1049
1036
class FontManager :
1050
1037
"""
1051
1038
On import, the `FontManager` singleton instance creates a list of ttf and
0 commit comments