-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
invalid ppem value with 0.15.1 but not with 0.14.0 #217
Comments
I get the same exception with v0.14.0. > cd python-barcode
> mkvirtualenv python-barcode
> pip install -e '.[images]'
> cat test.py
from __future__ import annotations
import barcode
from barcode.writer import ImageWriter
num = "ABC123456"
checksum = False
CODE39 = barcode.get_barcode_class("code39")
options = {
"font_size": 0,
"text_distance": 0.0,
"module_height": 24.0,
"quiet_zone": 0.0,
}
options["center_text"] = False
ean = CODE39(str(num), writer=ImageWriter(), add_checksum=checksum)
ean.save("tmp/sticker_code39_" + num, options=options)
> python test.py
Traceback (most recent call last):
File "/home/hugo/src/github.com/WhyNotHugo/python-barcode/test.py", line 17, in <module>
ean.save("tmp/sticker_code39_" + num, options=options)
File "/home/hugo/src/github.com/WhyNotHugo/python-barcode/barcode/base.py", line 65, in save
output = self.render(options)
^^^^^^^^^^^^^^^^^^^^
File "/home/hugo/src/github.com/WhyNotHugo/python-barcode/barcode/codex.py", line 74, in render
return super().render(options, text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hugo/src/github.com/WhyNotHugo/python-barcode/barcode/base.py", line 105, in render
raw = self.writer.render(code)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hugo/src/github.com/WhyNotHugo/python-barcode/barcode/writer.py", line 265, in render
self._callbacks["paint_text"](xpos, ypos)
File "/home/hugo/src/github.com/WhyNotHugo/python-barcode/barcode/writer.py", line 439, in _paint_text
font = ImageFont.truetype(self.font_path, font_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hugo/.local/state/virtualenvs/python-barcode/lib/python3.11/site-packages/PIL/ImageFont.py", line 797, in truetype
return freetype(font)
^^^^^^^^^^^^^^
File "/home/hugo/.local/state/virtualenvs/python-barcode/lib/python3.11/site-packages/PIL/ImageFont.py", line 794, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hugo/.local/state/virtualenvs/python-barcode/lib/python3.11/site-packages/PIL/ImageFont.py", line 226, in __init__
self.font = core.getfont(
^^^^^^^^^^^^^
OSError: invalid ppem value |
With which Pillow version ? That my venv (when its OK) for my test i changed only versions of python-barcode and Pillow between the first try and the second one
|
I'm getting similar results writing a Code128 barcode to PNG. I've tested these version combinations:
Here's the error (this one is python-barcode 0.15.1 and Pilllow 10.1.0, but the traceback is the same):
|
I don't see anything specific in the changelog: https://pillow.readthedocs.io/en/stable/releasenotes/10.0.0.html The documentation for the function that we're using doesn't specify if I think that the correct fix here is to update |
FWIW: |
Hi,
If i try this with python 3.9.16
With python-barcode 0140 and Pillow 9.5.0 => OK
With python-barcode 0.15.1 and Pillow 10.0.0 (same with 10.0.1) => ERR : invalid ppem value
I didn't see in your documentation what had changed.
Thanks
The text was updated successfully, but these errors were encountered: