diff --git a/examples/monitor.py b/examples/monitor.py index 55c5e9c..b900adc 100644 --- a/examples/monitor.py +++ b/examples/monitor.py @@ -90,7 +90,7 @@ def label( if position not in ["A", "B", "X", "Y"]: raise ValueError(f"Invalid label position {position}") - text_w, text_h = self._draw.textsize(text, font=self.font) + _, _, text_w, text_h = self._draw.textbbox((0, 0), text, font=self.font) text_h = 11 text_w += margin * 2 text_h += margin * 2 @@ -143,7 +143,7 @@ def text_in_rect(self, text, font, rect, line_spacing=1.1, textcolor=(0, 0, 0)): while ( len(words) > 0 - and font.getsize(" ".join(line + [words[0]]))[0] <= width + and font.getbbox(" ".join(line + [words[0]]))[2] <= width ): line.append(words.pop(0)) @@ -161,7 +161,7 @@ def text_in_rect(self, text, font, rect, line_spacing=1.1, textcolor=(0, 0, 0)): bounds = [x2, y, x1, y + len(lines) * line_height] for line in lines: - line_width = font.getsize(line)[0] + line_width = font.getbbox(line)[2] x = int(x1 + (width / 2) - (line_width / 2)) bounds[0] = min(bounds[0], x) bounds[2] = max(bounds[2], x + line_width) @@ -222,7 +222,7 @@ def render_channel(self, channel): self.icon(icon_channel, (x, label_y), (200, 200, 200) if active else (64, 64, 64)) # TODO: replace number text with graphic - tw, th = self.font.getsize(str(channel.channel)) + _, _, tw, th = self.font.getbbox(str(channel.channel)) self._draw.text( (x + int(math.ceil(8 - (tw / 2.0))), label_y + 1), str(channel.channel), @@ -479,7 +479,7 @@ def render(self): self.icon(icon_channel, (label_x, label_y), (200, 200, 200)) - tw, th = self.font.getsize(str(self.channel.channel)) + _, _, tw, th = self.font.getbbox(str(self.channel.channel)) self._draw.text( (label_x + int(math.ceil(8 - (tw / 2.0))), label_y + 1), str(self.channel.channel),