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
Fix unicode paths for Font() and saved images #649
Conversation
Nice one :) Here is a test... >>> import pygame
>>> pygame.font.init()
>>> from pygame.tests.test_utils import example_path
>>> import os
>>> import tempfile
>>> import shutil
>>> tmpdirname = tempfile.mkdtemp()
>>> try:
... newfontpath = os.path.join(tmpdirname, u"运城国际学校.ttf")
... pgfont = example_path('data/sans.ttf')
... shutil.copy(pgfont, newfontpath)
... pygame.font.Font(newfontpath, 20)
... finally:
... shutil.rmtree(tmpdirname) I guess we can't use the python io.open for this? |
I guess it's possible: /* Open a file. Call _wfopen() on Windows, or encode the path to the filesystem
encoding and call fopen() otherwise.
Return the new file object on success. Raise an exception and return NULL
on error.
The file descriptor is created non-inheritable.
When interrupted by a signal (open() fails with EINTR), retry the syscall,
except if the Python signal handler raises an exception.
Release the GIL to call _wfopen() or fopen(). The caller must hold
the GIL. */
FILE*
_Py_fopen_obj(PyObject *path, const char *mode) https://github.com/python/cpython/blob/master/Python/fileutils.c |
There's an issue with the CI: |
Hrmm. I guess that is distutils Windows code not able to handle that filename. Seems to pass on travis Linux, and Mac. |
51323b4
to
c8100ec
Compare
086aebc
to
81fbaf8
Compare
SDL expects UTF8 strings
fopen()
doesn't work for unicode paths on Windows. As a result, saving surfaces to images and loading fonts could fail.Fixes #645 and #196.