@@ -267,15 +267,15 @@ def text(self, xy, text, fill=None, font=None, anchor=None):
267
267
self .draw .draw_bitmap (xy , mask , ink )
268
268
269
269
def multiline_text (self , xy , text , fill = None , font = None , anchor = None ,
270
- spacing = 0 , align = "left" ):
271
- widths , heights = [], []
270
+ spacing = 4 , align = "left" ):
271
+ widths = []
272
272
max_width = 0
273
273
lines = self ._multiline_split (text )
274
+ line_spacing = self .textsize ('A' , font = font )[1 ] + spacing
274
275
for line in lines :
275
276
line_width , line_height = self .textsize (line , font )
276
277
widths .append (line_width )
277
278
max_width = max (max_width , line_width )
278
- heights .append (line_height )
279
279
left , top = xy
280
280
for idx , line in enumerate (lines ):
281
281
if align == "left" :
@@ -287,7 +287,7 @@ def multiline_text(self, xy, text, fill=None, font=None, anchor=None,
287
287
else :
288
288
assert False , 'align must be "left", "center" or "right"'
289
289
self .text ((left , top ), line , fill , font , anchor )
290
- top += heights [ idx ] + spacing
290
+ top += line_spacing
291
291
left = xy [0 ]
292
292
293
293
##
@@ -305,11 +305,11 @@ def multiline_textsize(self, text, font=None, spacing=0):
305
305
max_width = 0
306
306
height = 0
307
307
lines = self ._multiline_split (text )
308
+ line_spacing = self .textsize ('A' , font = font )[1 ] + spacing
308
309
for line in lines :
309
310
line_width , line_height = self .textsize (line , font )
310
- height += line_height + spacing
311
311
max_width = max (max_width , line_width )
312
- return max_width , height
312
+ return max_width , len ( lines ) * line_spacing
313
313
314
314
315
315
##
0 commit comments