Fix unicode paths for Font() and saved images #649
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)
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments.