From 49b81cb22436b4b60f534beb467afe6fcde1bcf1 Mon Sep 17 00:00:00 2001 From: Akshay Arora Date: Mon, 11 Dec 2023 23:02:27 +0530 Subject: [PATCH] PIL text provider: use `get_bbox` when `get_size` is not available. Allows latest versions of pillow to work along with older ones. (#8503) --- kivy/core/text/text_pil.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kivy/core/text/text_pil.py b/kivy/core/text/text_pil.py index 6549166b4..3d53d3d0a 100644 --- a/kivy/core/text/text_pil.py +++ b/kivy/core/text/text_pil.py @@ -34,11 +34,16 @@ class LabelPIL(LabelBase): def get_extents(self, text): font = self._select_font() - w, h = font.getsize(text) + try: + w, h = font.getsize(text) + except AttributeError: + left, top, right, bottom = font.getbbox(text) + w = right - left + h = bottom return w, h def get_cached_extents(self): - return self._select_font().getsize + return self.get_extents def _render_begin(self): # create a surface, context, font...