From f0f58cc17ba3cace309b5c8718813cab07ffb3a7 Mon Sep 17 00:00:00 2001 From: e2dk4r <43293320+e2dk4r@users.noreply.github.com> Date: Sun, 18 Aug 2024 08:02:24 +0300 Subject: [PATCH] Fix compatibility with pillow >= 10.0.0 https://pillow.readthedocs.io/en/stable/releasenotes/10.0.0.html#font-size-and-offset-methods --- fabulous/text.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fabulous/text.py b/fabulous/text.py index 32315d6..02572cf 100644 --- a/fabulous/text.py +++ b/fabulous/text.py @@ -115,7 +115,10 @@ def __init__(self, text, fsize=23, color="#0099ff", shadow=False, self.color = grapefruit.Color.NewFromHtml(color) self.font = ImageFont.truetype(resolve_font(font), fsize) skew = skew or 0 - size = tuple([n + 3 + skew for n in self.font.getsize(self.text)]) + if hasattr(font, 'getsize'): + size = tuple([n + 3 + skew for n in self.font.getsize(self.text)]) + else: + size = tuple([n + 3 + skew for n in self.font.getbbox(self.text)[2:4]]) self.img = Image.new("RGBA", size, (0, 0, 0, 0)) cvs = ImageDraw.Draw(self.img) if shadow: