Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with ttf2header.py and Pillow 10.4.0 #400

Open
BuslAV opened this issue Oct 11, 2024 · 0 comments
Open

Issue with ttf2header.py and Pillow 10.4.0 #400

BuslAV opened this issue Oct 11, 2024 · 0 comments

Comments

@BuslAV
Copy link

BuslAV commented Oct 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant