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

Fix for pillow 10 #128

Closed
gene-git opened this issue Oct 17, 2023 · 0 comments
Closed

Fix for pillow 10 #128

gene-git opened this issue Oct 17, 2023 · 0 comments

Comments

@gene-git
Copy link

gene-git commented Oct 17, 2023

The file examples/qrcode_text/png_text.py
Fails with missing method:


    fw, fh = font.getsize(line)
             ^^^^^^^^^^^^
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

This patch fixes it.

--- a/png_text.py	2023-10-17 12:33:47.469268721 -0400
+++ b/png_text.py	2023-10-17 12:34:17.220677606 -0400
@@ -89,7 +89,9 @@
     lines = text.splitlines()
     # Calculate the additional space required for the text
     for line in lines:
-        fw, fh = font.getsize(line)
+        (left, top, right, bottom) = font.getbbox(line)
+        fw = right - left
+        fh = bottom - top
         if fw > width:
             width = fw + font_size
         height += fh + line_spacing

@heuer heuer closed this as completed in 184c7ec Oct 17, 2023
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