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