-
-
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
Using font_variant on a font whose path is defined by BytesIO fails #6209
Comments
https://pillow.readthedocs.io/en/stable/reference/ImageFont.html#PIL.ImageFont.truetype
While I'm not able to replicate your problem (when I try, I receive an error at |
@14ROVI did that answer your question? What I'm trying to say is that the situation you describe shouldn't work at all, not just fail for variants. This is not the intended use. If you would like us to investigate why it's working for you at all, please let us know what font you are using. |
@radarhere Thank you for investigating. BytesIO is a file like object which supports the reading and writing needed for loading the font hence loading the font initally works. However, when trying to use With this example you may ask why do it this way to which i respond not in this example but if you have to load resources off of the internet or some other method where you dont have a file path, it would be nicer to not have to bother. I hope this explains it better. please let me know if ive missed the point of |
Ah, ok, I didn't have a correct understanding of your situation. I thought you were passing in the path using Rather than seeking to the beginning (it is theoretically possible that the file-like object passed in wasn't at zero the first time), my solution would be to just re-use the bytes already read. I've created #6234 to resolve this. |
What did you do?
Opened a font using
then tried to edit the font using font_variant.
However, by doing a bit more code i managed to get it to work
Aditionally
I assume this is something todo with font_variant parsing in
font.path
to the init of a new font object and asBytesIO
is already read, it can't be read again. To fix this it could have a check if its a file like object and seek to the begining again?What did you expect to happen?
I expected the font to be successfully changed
What actually happened?
It raised the error
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: