What did you do?
I upgrade Pillow from 9.5.0 to 10.2.0 and adjust sources according to the documentation regarding migration from font.getsize() to font.getbbox().
What did you expect to happen?
I expect same results.
What actually happened?
At least for height I got ohter results as before.
Upgrading from 9.5.0 to 10.2.0 it appears that former deprecated function font.getsize() is not replacable with font.getbbox() like described in the documentation.
What are your OS, Python and Pillow versions?
- OS: Windows
- Python: 3.11
- Pillow: 9.5,0 and 10.2.0
from PIL import ImageFont
PATH_TO_TTF = "FreeMono.ttf"
def get_size_from_deprecated_function(font, s):
return font.getsize(s)
def get_size_from_new_documented_use(font, s):
left, top, right, bottom = font.getbbox(s)
width, height = right - left, bottom - top
size = width, height
return size
def compare_deprecated_with_new_documented_usage():
font = ImageFont.truetype(PATH_TO_TTF, 15)
string_to_test = 'a'
size_old = get_size_from_deprecated_function(font, string_to_test)
size_new = get_size_from_new_documented_use(font, string_to_test)
print('old: ', size_old)
print('new: ', size_new)
if size_old == size_new:
print('okay')
else:
print('not okay')
compare_deprecated_with_new_documented_usage()
What did you do?
I upgrade Pillow from 9.5.0 to 10.2.0 and adjust sources according to the documentation regarding migration from font.getsize() to font.getbbox().
What did you expect to happen?
I expect same results.
What actually happened?
At least for height I got ohter results as before.
Upgrading from 9.5.0 to 10.2.0 it appears that former deprecated function font.getsize() is not replacable with font.getbbox() like described in the documentation.
What are your OS, Python and Pillow versions?