@@ -621,9 +621,10 @@ const char *PyFT2Font_get_kerning__doc__ =
621621
622622static PyObject *PyFT2Font_get_kerning (PyFT2Font *self, PyObject *args, PyObject *kwds)
623623{
624- int left, right, mode, result;
624+ FT_UInt left, right, mode;
625+ int result;
625626
626- if (!PyArg_ParseTuple (args, " iii :get_kerning" , &left, &right, &mode)) {
627+ if (!PyArg_ParseTuple (args, " III :get_kerning" , &left, &right, &mode)) {
627628 return NULL ;
628629 }
629630
@@ -643,12 +644,15 @@ static PyObject *PyFT2Font_set_text(PyFT2Font *self, PyObject *args, PyObject *k
643644{
644645 PyObject *textobj;
645646 double angle = 0.0 ;
646- FT_UInt32 flags = FT_LOAD_FORCE_AUTOHINT;
647+ FT_Int32 flags = FT_LOAD_FORCE_AUTOHINT;
647648 std::vector<double > xys;
648649 const char *names[] = { " string" , " angle" , " flags" , NULL };
649650
651+ /* This makes a technically incorrect assumption that FT_Int32 is
652+ int. In theory it can also be long, if the size of int is less
653+ than 32 bits. This is very unlikely on modern platforms. */
650654 if (!PyArg_ParseTupleAndKeywords (
651- args, kwds, " O|dI :set_text" , (char **)names, &textobj, &angle, &flags)) {
655+ args, kwds, " O|di :set_text" , (char **)names, &textobj, &angle, &flags)) {
652656 return NULL ;
653657 }
654658
@@ -712,11 +716,14 @@ const char *PyFT2Font_load_char__doc__ =
712716static PyObject *PyFT2Font_load_char (PyFT2Font *self, PyObject *args, PyObject *kwds)
713717{
714718 long charcode;
715- FT_UInt32 flags = FT_LOAD_FORCE_AUTOHINT;
719+ FT_Int32 flags = FT_LOAD_FORCE_AUTOHINT;
716720 const char *names[] = { " charcode" , " flags" , NULL };
717721
722+ /* This makes a technically incorrect assumption that FT_Int32 is
723+ int. In theory it can also be long, if the size of int is less
724+ than 32 bits. This is very unlikely on modern platforms. */
718725 if (!PyArg_ParseTupleAndKeywords (
719- args, kwds, " k|I :load_char" , (char **)names, &charcode, &flags)) {
726+ args, kwds, " l|i :load_char" , (char **)names, &charcode, &flags)) {
720727 return NULL ;
721728 }
722729
@@ -747,11 +754,14 @@ const char *PyFT2Font_load_glyph__doc__ =
747754static PyObject *PyFT2Font_load_glyph (PyFT2Font *self, PyObject *args, PyObject *kwds)
748755{
749756 FT_UInt glyph_index;
750- FT_UInt32 flags = FT_LOAD_FORCE_AUTOHINT;
757+ FT_Int32 flags = FT_LOAD_FORCE_AUTOHINT;
751758 const char *names[] = { " glyph_index" , " flags" , NULL };
752759
760+ /* This makes a technically incorrect assumption that FT_Int32 is
761+ int. In theory it can also be long, if the size of int is less
762+ than 32 bits. This is very unlikely on modern platforms. */
753763 if (!PyArg_ParseTupleAndKeywords (
754- args, kwds, " I|I :load_glyph" , (char **)names, &glyph_index, &flags)) {
764+ args, kwds, " I|i :load_glyph" , (char **)names, &glyph_index, &flags)) {
755765 return NULL ;
756766 }
757767
@@ -901,7 +911,7 @@ static PyObject *PyFT2Font_get_glyph_name(PyFT2Font *self, PyObject *args, PyObj
901911 unsigned int glyph_number;
902912 char buffer[128 ];
903913
904- if (!PyArg_ParseTuple (args, " i :get_glyph_name" , &glyph_number)) {
914+ if (!PyArg_ParseTuple (args, " I :get_glyph_name" , &glyph_number)) {
905915 return NULL ;
906916 }
907917
0 commit comments