@@ -808,18 +808,19 @@ def set_family(self, family):
808808 'fantasy', or 'monospace', or a real font name.
809809 """
810810 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
816815 set_name = set_family
817816
818817 def set_style (self , style ):
819818 """
820819 Set the font style. Values are: 'normal', 'italic' or
821820 'oblique'.
822821 """
822+ if style is None :
823+ style = rcParams ['font.style' ]
823824 if style not in ('normal' , 'italic' , 'oblique' , None ):
824825 raise ValueError ("style must be normal, italic or oblique" )
825826 self ._slant = style
@@ -829,6 +830,8 @@ def set_variant(self, variant):
829830 """
830831 Set the font variant. Values are: 'normal' or 'small-caps'.
831832 """
833+ if variant is None :
834+ variant = rcParams ['font.variant' ]
832835 if variant not in ('normal' , 'small-caps' , None ):
833836 raise ValueError ("variant must be normal or small-caps" )
834837 self ._variant = variant
@@ -840,14 +843,15 @@ def set_weight(self, weight):
840843 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold',
841844 'demi', 'bold', 'heavy', 'extra bold', 'black'
842845 """
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" )
851855 self ._weight = weight
852856
853857 def set_stretch (self , stretch ):
@@ -857,14 +861,15 @@ def set_stretch(self, stretch):
857861 'semi-expanded', 'expanded', 'extra-expanded' or
858862 'ultra-expanded', or a numeric value in the range 0-1000.
859863 """
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" )
868873 self ._stretch = stretch
869874
870875 def set_size (self , size ):
@@ -873,12 +878,13 @@ def set_size(self, size):
873878 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'
874879 or an absolute font size, e.g., 12.
875880 """
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" )
882888 self ._size = size
883889
884890 def set_file (self , file ):
0 commit comments