-
-
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
Unknown file format error on some woff2
fonts on ImageFont.truetype()
#6554
Unknown file format error on some woff2
fonts on ImageFont.truetype()
#6554
Comments
woff
and woff2
files on ImageFont.truetype()
woff
and woff2
fonts on ImageFont.truetype()
Thanks for your detailed example. Looking at the output you've provided at https://github.com/mirusu400/pillow-woff-issue#result, it would seem that this is not failing for any of the woff files, only woff2. The font that you have trouble after fetching from a URL is also woff2. When I try and run your repository code on my machine, all of the fonts pass. So let me ask this - what version of freetype2 are you using? Support for woff2 was only added in freetype2 2.10.2 >>> from PIL import features
>>> features.version_module("freetype2")
'2.12.1' |
Some anon posts lots of fonts which have errors: https://anonfiles.com/sc07oe67y1/fonts_error_zip This all fonts have same OSErrors. Also here is my Python 3.9.13 (main, May 24 2022, 21:28:31)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import features
>>> features.version_module("freetype2")
'2.12.1' Edit: There are mixed Edit2: It seems all of |
woff
and woff2
fonts on ImageFont.truetype()
woff2
fonts on ImageFont.truetype()
Did you install Pillow from the wheel, or did you build it from source? I found
And brotli is currently disabled in our macOS wheel builds. |
I installed it from pip(wheel). Also, I tried at Windows environment, still not works. Here is my info about window environment: Windows 10 21H2 19044.1889
Pillow==9.2.0
Python 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)] on win32
>>> from PIL import features
>>> features.version_module("freetype2")
'2.12.1' |
Same problem and output with different Linux distributions in Docker: FROM python:3.11-rc-bullseye
RUN set -ex \
&& apt-get update \
&& apt-get install -y -V libpng16-16 libpng-dev libbrotli1 libbrotli-dev libfreetype6 libfreetype-dev \
&& python -m pip install --upgrade pip \
&& pip install --no-cache-dir Pillow
FROM python:3.11-rc-buster
RUN set -ex \
&& apt-get update \
&& apt-get install -y -V libpng16-16 libpng-dev libbrotli1 libbrotli-dev libfreetype6 libfreetype6-dev \
&& python -m pip install --upgrade pip \
&& pip install --no-cache-dir Pillow FROM python:3.11-rc-alpine
RUN set -ex \
&& apk update \
&& apk add --upgrade brotli brotli-dev freetype freetype-dev \
&& python -m pip install --upgrade pip \
&& pip install --no-cache-dir Pillow
|
python-pillow/pillow-wheels#320 has been created to add brotli to our macOS and Linux wheels. |
I've added brotli to the #6562 changes for Windows wheels. |
Pillow 9.3.0 has now been released, so brotli should be included in the latest wheels now. |
Hi @radarhere ! I got same error when build docker to deploy on aws layer lambda When run python test.py with FONT_NAME="Karla-Regular.woff2" (sample.ttf work fine) And I try to change dockerfile with from RUN pip3 install --no-cache-dir Pillow to // .whl file from https://github.com/python-pillow/pillow-wheels/releases/tag/10.0.0
COPY build/Pillow-10.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl .
RUN pip3 install Pillow-10.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl It's still return error bash-4.2# python test.py
Traceback (most recent call last):
File "/var/task/test.py", line 6, in <module>
font = ImageFont.truetype(
File "/var/lang/lib/python3.10/site-packages/PIL/ImageFont.py", line 791, in truetype
return freetype(font)
File "/var/lang/lib/python3.10/site-packages/PIL/ImageFont.py", line 788, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/var/lang/lib/python3.10/site-packages/PIL/ImageFont.py", line 226, in __init__
self.font = core.getfont(
OSError: unknown file format |
Could you provide a link to the file or the file itself? |
Hi @homm And my Dockerfile |
I've created python-pillow/pillow-wheels#405 to resolve this. In the meantime, I put together a wheel with GitHub Actions - this should work for you. |
Pillow 10.0.1 has now been released, so that wheel should now also be available through pip. |
What did you do?
I'm trying to convert woff and woff2 fonts to
ImageFont
What did you expect to happen?
Return a
FreeTypeFont
objectWhat actually happened?
It raises
OSError
error, terminates program.What are your OS, Python and Pillow versions?
Here are some sample code represents my issue:
I don't know detailed reason this happen, So I created a repo about this issue.
https://github.com/mirusu400/pillow-woff-issue
Here are some samples about having ImageFont issue.
The text was updated successfully, but these errors were encountered: