From 54e78333dd4748b7d560046257263efbe3892fd2 Mon Sep 17 00:00:00 2001 From: Xargana Date: Fri, 16 May 2025 19:25:02 +0300 Subject: [PATCH] wtf --- display/font_manager.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/display/font_manager.py b/display/font_manager.py index fa1ca29..882829a 100644 --- a/display/font_manager.py +++ b/display/font_manager.py @@ -7,25 +7,20 @@ class FontManager: def set_font_size(self, size): self.font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", size) -def draw_multiline_text(self, draw, text, x, y, width, height): - lines = [] - words = text.split(" ") - line = "" - for word in words: - test = f"{line} {word}".strip() - bbox = self.font.getbbox(test) - test_width = bbox[2] - bbox[0] - if test_width <= width: - line = test - else: - lines.append(line) - line = word - lines.append(line) - - draw.rectangle((0, 0, width, height), outline=0, fill=0) - for idx, line in enumerate(lines): - draw.text((x, y + idx * self.font.size), line, font=self.font, fill=255) - + def draw_multiline_text(self, draw, text, x, y, width, height): + lines = [] + words = text.split(" ") + line = "" + for word in words: + test = f"{line} {word}".strip() + bbox = self.font.getbbox(test) + test_width = bbox[2] - bbox[0] + if test_width <= width: + line = test + else: + lines.append(line) + line = word + lines.append(line) draw.rectangle((0, 0, width, height), outline=0, fill=0) for idx, line in enumerate(lines):