jupylet
jupylet copied to clipboard
AttributeError: 'FreeTypeFont' object has no attribute 'getsize' with Pillow 10
right in example 02-hello-jupylet
. This issue I found also in tensorflow, see this URL, where it was successfully resolved. I think, ipyleaflet can go this way, too (using old, deprecated getsize
if it is available, or getbbox
if it is not.
what version of python, and jupylet ?
python 3.11
in conda
environment, latest jupylet
from github/master
, this is only the question of Pillow
version (here I have version 10.0.1). The solution is simply to modify the function draw_chr
in file label.py
as follows:
@functools.lru_cache(maxsize=2048)
def draw_chr(c, path, size):
font = load_font(path, size)
if hasattr(font, 'getsize'):
w, h = font.getsize(c)
else:
w, h = font.getbbox(c)[2:4]
im = PIL.Image.new('L', (w, h))
di = PIL.ImageDraw.Draw(im)
di.text((0, 0), c, fill='white', font=font)
return np.array(im)
coming up - I pushed your fix to github along with other overdue changes (before a new release) - please pull and check it is fixed on your system - gave you the credit here https://github.com/nir/jupylet#whats-new-in-version-091.
thanks!
oh, but please install it into a clean virtual environment
All OK.
fix released with jupylet 0.9.1
thanks!
I think, you can close this issue now.