-
-
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
ImageFont and non latin characters in a path to font #3145
Comments
Can't reproduce on MacOS either. |
Info from duplicate #3480: Reproducible with Chinese characters with:
But not in CentOS. |
Looks like FreeType's
Lines 268 to 302 in 080bfd3
And "cannot open resource" is a FreeType error: FT_ERRORDEF_( Cannot_Open_Resource, 0x01,
"cannot open resource" )
From https://stackoverflow.com/a/10075289/724176:
Both of these are similar issues and contain suggestions to load the file and instead pass it to
And Pillow already does something like this.
If a path is passed in, it uses I've not tested this on Windows (and it still works on Mac), please try something like this: from PIL import ImageFont
from io import BytesIO
FONT_PATH = "方正黄草简体.ttf"
def open_filename(filename):
font = ImageFont.truetype(filename)
return font
def open_data(filename):
with open(filename, "rb") as f:
font_bytes = BytesIO(f.read())
font = ImageFont.truetype(font_bytes)
return font
# print(open_filename(FONT_PATH))
print(open_data(FONT_PATH)) Does that help? One of the threads above suggests not to use However, perhaps it could be done on Windows when the filename contains Unicode/non-ASCII. |
@hugovk , it works on my Windows machine. Thanks~ |
I've created PR #3785 to resolve this. |
What did you do?
If
fname
contains only Latin characters, then everything works.What versions of Pillow and Python are you using?
Pillow 5.0.1
Windows 7, Windows 10.
In Linux is OK.
The text was updated successfully, but these errors were encountered: