-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageDraw.textbbox
doesn't work with the default font
#5506
Comments
ImageDraw.textbbox
Doesn't Work With the Default FontImageDraw.textbbox
doesn't work with the default font
From the docs (emphasis added) https://pillow.readthedocs.io/en/stable/reference/ImageDraw.html#PIL.ImageDraw.ImageDraw.textbbox:
The default ImageDraw font is in PIL font format, not TrueType. The default font also doesn't support anchors and all glyphs fit within their own bounding box, so if hasattr(font, "getbbox"):
bbox = draw.textbbox(...)
else:
w, h = draw.textsize(...)
bbox = (x, y, x + w, y + h) |
Alright, thanks I missed that it only worked for TrueType fonts. It would be nice if there was a check for that in |
I've created #5510 to add a specific error for that. |
What did you do?
I tried to use
ImageDraw.textbbox
without specifying a font.What did you expect to happen?
I expected
ImageDraw.textbbox
to work without specifying a font likeImageDraw.text
does.What actually happened?
It throws an
AttributeError
:It also does this when specifying
ImageFont.load_default()
manually as shown below. It does work when using another font, as shown below in the commented out line.What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: