FabGL icon indicating copy to clipboard operation
FabGL copied to clipboard

Issue with ttf2header.py and Pillow 10.4.0

Open BuslAV opened this issue 1 year ago • 0 comments

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

BuslAV avatar Oct 11 '24 09:10 BuslAV