You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I use the getbbox to calculate the width and height of my string with a specific font. The string includes the \n character and it split the line into 2.
What did you expect to happen?
The string renders well and has a width of about 7xx pixels which is what I want. And I expect the getbbox function returns the same value.
What actually happened?
However, the result I got from getbbox is 1555 pixels which might be the width of no break line text.
What are your OS, Python, and Pillow versions?
OS: Windows 10 Enterprise
Python: Python 3.10.10
Pillow: 9.4.0
text="Age is an issue of mind over matter.\nIf you don't mind, it doesn't matter."_, _, text_width, text_height=FONT.getbbox(text)
# text_width = 1555
The size of the image is 1080*1080 so there is no way that the text width is 1555.
Thank you!
The text was updated successfully, but these errors were encountered:
Line breaking is handled only in ImageDraw and not in ImageFont; you should use ImageDraw.multiline_textbbox(). The thread around #5816 (comment) might interest you.
radarhere
changed the title
getbbox wrong calculate when string contains new line character (\n)
getbbox incorrect when string contains new line character
Mar 14, 2023
What did you do?
So I use the
getbbox
to calculate the width and height of my string with a specific font. The string includes the\n
character and it split the line into 2.What did you expect to happen?
The string renders well and has a width of about 7xx pixels which is what I want. And I expect the
getbbox
function returns the same value.What actually happened?
However, the result I got from
getbbox
is 1555 pixels which might be the width of no break line text.What are your OS, Python, and Pillow versions?
The size of the image is 1080*1080 so there is no way that the text width is 1555.
Thank you!
The text was updated successfully, but these errors were encountered: