From f7c5f6b05eedd39d6b96b840003ed9360546e0b5 Mon Sep 17 00:00:00 2001 From: Max G Date: Sun, 17 Mar 2019 20:32:32 +0100 Subject: [PATCH] Added broad multiline alignment support --- Calendar/TextDesign.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Calendar/TextDesign.py b/Calendar/TextDesign.py index a09d1d6..3b2cde4 100644 --- a/Calendar/TextDesign.py +++ b/Calendar/TextDesign.py @@ -40,16 +40,16 @@ class TextDesign (DesignEntity): ImageDraw.Draw(self.__image__).text(pos, self.text, fill=self.color, font=self.__font__) def __truncate_text__ (self): - if self.__font__.getsize(self.text)[0] <= self.size[0]: #does not need truncating + if self.__font__.getsize_multiline(self.text)[0] <= self.size[0]: #does not need truncating return - error = truncateerror_fontsize * self.__font__.getsize("A")[0] - suffix_length = self.__font__.getsize(self.truncate_suffix)[0] - while len(self.text) > 1 and self.__font__.getsize(self.text)[0] + suffix_length >= self.size[0] - error: + error = truncateerror_fontsize * self.__font__.getsize_multiline("A")[0] + suffix_length = self.__font__.getsize_multiline(self.truncate_suffix)[0] + while len(self.text) > 1 and self.__font__.getsize_multiline(self.text)[0] + suffix_length >= self.size[0] - error: self.text = self.text[0:-1] self.text += self.truncate_suffix def __pos_from_alignment__ (self): - width, height = self.__font__.getsize(self.text) + width, height = self.__font__.getsize_multiline(self.text) x, y = 0, 0 if self.vertical_alignment == "center":