Skip to content

Workaround for AttributeError: 'FreeTypeFont' object has no attribute 'getsize' #48

Description

@netmilk

The current version doesn't work. I'm no python expert at all, but downgrading Pillow worked for me as a workaround:

pip3 install Pillow==9.5.0

This is the error backtrace:

127.0.0.1 - - [14/Jan/2024 12:45:50] "POST /api/preview/text?return_format=base64 HTTP/1.1" 500 778
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 876, in _handle
    return route.call(**args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 1759, in wrapper
    rv = callback(*a, **ka)
         ^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 192, in print_text
    im = create_label_im(**context)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 119, in create_label_im
    linesize = im_font.getsize(text)
               ^^^^^^^^^^^^^^^
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
127.0.0.1 - - [14/Jan/2024 12:45:51] "POST /api/print/text HTTP/1.1" 500 755
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 876, in _handle
    return route.call(**args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/bottle.py", line 1759, in wrapper
    rv = callback(*a, **ka)
         ^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 152, in get_preview_image
    im = create_label_im(**context)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/netmilk/projects/brother_ql_web/./brother_ql_web.py", line 119, in create_label_im
    linesize = im_font.getsize(text)
               ^^^^^^^^^^^^^^^
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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