heuer/segno

Fix for pillow 10

Closed this issue · 0 comments

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