Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
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)