Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d674dd

Browse files
authored
Fix PyPy compatiblity issue
1 parent 6f25240 commit 3d674dd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/ft2font_wrapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,16 @@ static PyObject *PyFT2Font_set_text(PyFT2Font *self, PyObject *args, PyObject *k
637637
if (PyUnicode_Check(textobj)) {
638638
size = PyUnicode_GET_LENGTH(textobj);
639639
codepoints.resize(size);
640+
#if defined(PYPY_VERSION) && (PYPY_VERSION_NUM < 0x07030200)
641+
Py_UNICODE *unistr = PyUnicode_AsUnicode(textobj);
642+
for (size_t i = 0; i < size; ++i) {
643+
codepoints[i] = unistr[i];
644+
}
645+
#else
640646
for (size_t i = 0; i < size; ++i) {
641647
codepoints[i] = PyUnicode_ReadChar(textobj, i);
642648
}
649+
#endif
643650
} else if (PyBytes_Check(textobj)) {
644651
size = PyBytes_Size(textobj);
645652
codepoints.resize(size);

0 commit comments

Comments
 (0)