@@ -808,18 +808,19 @@ def set_family(self, family):
808
808
'fantasy', or 'monospace', or a real font name.
809
809
"""
810
810
if family is None :
811
- self ._family = None
812
- else :
813
- if is_string_like (family ):
814
- family = [family ]
815
- self ._family = family
811
+ family = rcParams ['font.family' ]
812
+ if is_string_like (family ):
813
+ family = [family ]
814
+ self ._family = family
816
815
set_name = set_family
817
816
818
817
def set_style (self , style ):
819
818
"""
820
819
Set the font style. Values are: 'normal', 'italic' or
821
820
'oblique'.
822
821
"""
822
+ if style is None :
823
+ style = rcParams ['font.style' ]
823
824
if style not in ('normal' , 'italic' , 'oblique' , None ):
824
825
raise ValueError ("style must be normal, italic or oblique" )
825
826
self ._slant = style
@@ -829,6 +830,8 @@ def set_variant(self, variant):
829
830
"""
830
831
Set the font variant. Values are: 'normal' or 'small-caps'.
831
832
"""
833
+ if variant is None :
834
+ variant = rcParams ['font.variant' ]
832
835
if variant not in ('normal' , 'small-caps' , None ):
833
836
raise ValueError ("variant must be normal or small-caps" )
834
837
self ._variant = variant
@@ -840,14 +843,15 @@ def set_weight(self, weight):
840
843
'regular', 'book', 'medium', 'roman', 'semibold', 'demibold',
841
844
'demi', 'bold', 'heavy', 'extra bold', 'black'
842
845
"""
843
- if weight is not None :
844
- try :
845
- weight = int (weight )
846
- if weight < 0 or weight > 1000 :
847
- raise ValueError ()
848
- except ValueError :
849
- if weight not in weight_dict :
850
- raise ValueError ("weight is invalid" )
846
+ if weight is None :
847
+ weight = rcParams ['font.weight' ]
848
+ try :
849
+ weight = int (weight )
850
+ if weight < 0 or weight > 1000 :
851
+ raise ValueError ()
852
+ except ValueError :
853
+ if weight not in weight_dict :
854
+ raise ValueError ("weight is invalid" )
851
855
self ._weight = weight
852
856
853
857
def set_stretch (self , stretch ):
@@ -857,14 +861,15 @@ def set_stretch(self, stretch):
857
861
'semi-expanded', 'expanded', 'extra-expanded' or
858
862
'ultra-expanded', or a numeric value in the range 0-1000.
859
863
"""
860
- if stretch is not None :
861
- try :
862
- stretch = int (stretch )
863
- if stretch < 0 or stretch > 1000 :
864
- raise ValueError ()
865
- except ValueError :
866
- if stretch not in stretch_dict :
867
- raise ValueError ("stretch is invalid" )
864
+ if stretch is None :
865
+ stretch = rcParams ['font.weight' ]
866
+ try :
867
+ stretch = int (stretch )
868
+ if stretch < 0 or stretch > 1000 :
869
+ raise ValueError ()
870
+ except ValueError :
871
+ if stretch not in stretch_dict :
872
+ raise ValueError ("stretch is invalid" )
868
873
self ._stretch = stretch
869
874
870
875
def set_size (self , size ):
@@ -873,12 +878,13 @@ def set_size(self, size):
873
878
'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'
874
879
or an absolute font size, e.g., 12.
875
880
"""
876
- if size is not None :
877
- try :
878
- size = float (size )
879
- except ValueError :
880
- if size is not None and size not in font_scalings :
881
- raise ValueError ("size is invalid" )
881
+ if size is None :
882
+ size = rcParams ['font.size' ]
883
+ try :
884
+ size = float (size )
885
+ except ValueError :
886
+ if size is not None and size not in font_scalings :
887
+ raise ValueError ("size is invalid" )
882
888
self ._size = size
883
889
884
890
def set_file (self , file ):
0 commit comments