Skip to content

Issue with ttf2header.py and Pillow 10.4.0 #400

@BuslAV

Description

@BuslAV

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions