From 1f7f8178603cd69861e276cb585ab7c598659d80 Mon Sep 17 00:00:00 2001 From: Tarun Menta Date: Thu, 9 Jan 2025 12:34:42 +0530 Subject: [PATCH] Updates for new Pillow + Update Deps --- setup.py | 4 ++-- synthtiger/layers/text_layer.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 5077a6b..41b6d59 100644 --- a/setup.py +++ b/setup.py @@ -37,9 +37,9 @@ def read_long_description(): "blend-modes", "fonttools", "imgaug", - "numpy", + "numpy==1.26", "opencv-python", - "pillow>=8.2.0", + "pillow>=11.0.0", "pygame", "python-bidi", "pytweening", diff --git a/synthtiger/layers/text_layer.py b/synthtiger/layers/text_layer.py index e45d0af..d637afa 100644 --- a/synthtiger/layers/text_layer.py +++ b/synthtiger/layers/text_layer.py @@ -172,11 +172,13 @@ def _get_bbox(self, text, font, vertical): if not vertical: ascent, descent = font.getmetrics() - width = font.getsize(text, direction=direction)[0] + left, top, right, bottom = font.getbbox(text, direction=direction) + width = right - left height = ascent + descent bbox = [0, -ascent, width, height] else: - width, height = font.getsize(text, direction=direction) + left, top, right, bottom = font.getbbox(text, direction=direction) + width, height = right - left, bottom-top bbox = [-width // 2, 0, width, height] return bbox