@@ -145,7 +145,7 @@ def __init__(self,
145145 multialignment = None ,
146146 fontproperties = None , # defaults to FontProperties()
147147 rotation = None ,
148- linespacing = 1.2 ,
148+ linespacing = None ,
149149 ** kwargs
150150 ):
151151 """
@@ -169,6 +169,8 @@ def __init__(self,
169169 self ._fontproperties = fontproperties
170170 self ._bbox = None
171171 self ._renderer = None
172+ if linespacing is None :
173+ linespacing = 1.2 # Maybe use rcParam later.
172174 self ._linespacing = linespacing
173175 self .update (kwargs )
174176 #self.set_bbox(dict(pad=0))
@@ -205,20 +207,7 @@ def _get_multialignment(self):
205207
206208 def get_rotation (self ):
207209 'return the text angle as float'
208- #return 0
209-
210- # if self._rotation in ('horizontal', None):
211- # angle = 0.
212- # elif self._rotation == 'vertical':
213- # angle = 90.
214- # else:
215- # angle = float(self._rotation)
216- # return angle%360
217-
218- # Since the get_rotation logic was extracted
219- # into a function for TextWithDash, this
220- # method could now read as follows.
221- return get_rotation (self ._rotation )
210+ return get_rotation (self ._rotation ) # string_or_number -> number
222211
223212 def update_from (self , other ):
224213 'Copy properties from other to self'
@@ -251,18 +240,18 @@ def _get_layout(self, renderer):
251240 lines = self ._text .split ('\n ' )
252241
253242 whs = []
254- # Find full vertical extent, including ascenders and descenders:
243+ # Find full vertical extent of font,
244+ # including ascenders and descenders:
255245 tmp , heightt = renderer .get_text_width_height (
256- 'Tglp' , self ._fontproperties , ismath = False )
246+ 'lp' , self ._fontproperties , ismath = False )
247+ offsety = heightt * self ._linespacing
257248
258249 for line in lines :
259250 w ,h = renderer .get_text_width_height (
260251 line , self ._fontproperties , ismath = self .is_math_text ())
261-
262252 whs .append ( (w ,h ) )
263- offsety = heightt * self ._linespacing
264253 horizLayout .append ((line , thisx , thisy , w , h ))
265- thisy -= offsety # now translate down by text height, window coords
254+ thisy -= offsety
266255 width = max (width , w )
267256
268257 ymin = horizLayout [- 1 ][2 ]
@@ -627,6 +616,7 @@ def set_multialignment(self, align):
627616 def set_linespacing (self , spacing ):
628617 """
629618 Set the line spacing as a multiple of the font size.
619+ Default is 1.2.
630620
631621 ACCEPTS: float
632622 """
@@ -888,6 +878,7 @@ def __init__(self,
888878 multialignment = None ,
889879 fontproperties = None , # defaults to FontProperties()
890880 rotation = None ,
881+ linespacing = None ,
891882 dashlength = 0.0 ,
892883 dashdirection = 0 ,
893884 dashrotation = None ,
@@ -900,7 +891,9 @@ def __init__(self,
900891 verticalalignment = verticalalignment ,
901892 horizontalalignment = horizontalalignment ,
902893 multialignment = multialignment ,
903- fontproperties = fontproperties , rotation = rotation )
894+ fontproperties = fontproperties ,
895+ rotation = rotation ,
896+ linespacing = linespacing )
904897
905898 # The position (x,y) values for text and dashline
906899 # are bogus as given in the instantiation; they will
0 commit comments