I encountered an issue while trying to use the ttf2header.py script from the FabGL project with Pillow version 10.4.0. Specifically, I get the following error:
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
It seems that the getsize method was removed in newer versions of Pillow (starting from version 10.0.0). The recommended replacement is the textbbox method, which provides the bounding box of the text. By replacing the getsize call with textbbox, the issue is resolved.
Here’s an example fix:
bbox = f.getbbox(chr(i), stroke_width=stroke)
w = bbox[2] - bbox[0] # Calculate width
h = bbox[3] - bbox[1] # Calculate height
Would it be possible to update the script to support the latest versions of Pillow?
Hello,
I encountered an issue while trying to use the ttf2header.py script from the FabGL project with Pillow version 10.4.0. Specifically, I get the following error:
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
It seems that the getsize method was removed in newer versions of Pillow (starting from version 10.0.0). The recommended replacement is the textbbox method, which provides the bounding box of the text. By replacing the getsize call with textbbox, the issue is resolved.
Here’s an example fix:
bbox = f.getbbox(chr(i), stroke_width=stroke) w = bbox[2] - bbox[0] # Calculate width h = bbox[3] - bbox[1] # Calculate height
Would it be possible to update the script to support the latest versions of Pillow?
Thank you for your work on this project!
Best regards, Andrew