We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
(Pillow) ~/b/Pillow (main) $ docker run -it -v "./Arial Bold.ttf:/a.ttf:ro" python:3.11 bash root@e1ff41aff78e:/# pip install 'pillow<10' Successfully installed pillow-9.5.0 root@e1ff41aff78e:/# python Python 3.11.6 (main, Nov 1 2023, 10:08:51) [GCC 12.2.0] on linux >>> from PIL import ImageFont >>> ImageFont.truetype("/a.ttf", size=0) <PIL.ImageFont.FreeTypeFont object at 0xffff9ef7d990> root@e1ff41aff78e:/# pip install 'pillow>=10' Successfully installed pillow-10.1.0 root@e1ff41aff78e:/# python Python 3.11.6 (main, Nov 1 2023, 10:08:51) [GCC 12.2.0] on linux >>> from PIL import ImageFont >>> ImageFont.truetype("/a.ttf", size=0) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.11/site-packages/PIL/ImageFont.py", line 797, in truetype return freetype(font) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/PIL/ImageFont.py", line 794, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/PIL/ImageFont.py", line 226, in __init__ self.font = core.getfont( ^^^^^^^^^^^^^ OSError: invalid ppem value >>>
Font creation for a zero or negative size should fail alright, but maybe with a less cryptic error. (size=-1 yields invalid argument.)
size=-1
invalid argument
With Pillow 9.x, font construction succeeds, but e.g. getbbox() or attempting to draw raises invalid argument.
getbbox()
Downstream bug: WhyNotHugo/python-barcode#217
The text was updated successfully, but these errors were encountered:
Improve error message when creating TrueType fonts of negative size
0f788b3
Fixes python-pillow#7583
Improve error message when creating TrueType fonts of invalid size
4ea5289
PIL
font_size
< 1
Successfully merging a pull request may close this issue.
What did you do?
What did you expect to happen? / What actually happened?
Font creation for a zero or negative size should fail alright, but maybe with a less cryptic error. (
size=-1
yieldsinvalid argument
.)With Pillow 9.x, font construction succeeds, but e.g.
getbbox()
or attempting to draw raisesinvalid argument
.What are your OS, Python and Pillow versions?
See also
Downstream bug: WhyNotHugo/python-barcode#217
The text was updated successfully, but these errors were encountered: