changed multiline text spacing from pixels to em

the spacing is now a float, which will be multiplied with the width of a
letter "m" in the chosen font.
This commit is contained in:
allo 2014-04-08 19:16:22 +02:00
parent 6a58a1c93e
commit 3aa718002c

View File

@ -279,6 +279,10 @@ class ImageDraw:
spacing=0, align="left"):
widths, heights = [], []
max_width = 0
# spacing in em (multiples of the width of a "m")
if spacing != 0:
m_width, m_height = self.textsize("m", font)
spacing = float(spacing) * m_width
lines = text.split("\n")
for line in lines:
line_width, line_height = self.textsize(line, font)