@@ -529,7 +529,7 @@ font_getlength(FontObject *self, PyObject *args) {
529
529
int horizontal_dir ; /* is primary axis horizontal? */
530
530
int mask = 0 ; /* is FT_LOAD_TARGET_MONO enabled? */
531
531
int color = 0 ; /* is FT_LOAD_COLOR enabled? */
532
- const char * mode = NULL ;
532
+ const char * mode_name = NULL ;
533
533
const char * dir = NULL ;
534
534
const char * lang = NULL ;
535
535
PyObject * features = Py_None ;
@@ -538,15 +538,16 @@ font_getlength(FontObject *self, PyObject *args) {
538
538
/* calculate size and bearing for a given string */
539
539
540
540
if (!PyArg_ParseTuple (
541
- args , "O|zzOz:getlength" , & string , & mode , & dir , & features , & lang
541
+ args , "O|zzOz:getlength" , & string , & mode_name , & dir , & features , & lang
542
542
)) {
543
543
return NULL ;
544
544
}
545
545
546
546
horizontal_dir = dir && strcmp (dir , "ttb" ) == 0 ? 0 : 1 ;
547
547
548
- mask = mode && strcmp (mode , "1" ) == 0 ;
549
- color = mode && strcmp (mode , "RGBA" ) == 0 ;
548
+ const ModeID mode = findModeID (mode_name );
549
+ mask = mode == IMAGING_MODE_1 ;
550
+ color = mode == IMAGING_MODE_RGBA ;
550
551
551
552
count = text_layout (string , self , dir , features , lang , & glyph_info , mask , color );
552
553
if (PyErr_Occurred ()) {
@@ -758,7 +759,7 @@ font_getsize(FontObject *self, PyObject *args) {
758
759
int horizontal_dir ; /* is primary axis horizontal? */
759
760
int mask = 0 ; /* is FT_LOAD_TARGET_MONO enabled? */
760
761
int color = 0 ; /* is FT_LOAD_COLOR enabled? */
761
- const char * mode = NULL ;
762
+ const char * mode_name = NULL ;
762
763
const char * dir = NULL ;
763
764
const char * lang = NULL ;
764
765
const char * anchor = NULL ;
@@ -768,15 +769,23 @@ font_getsize(FontObject *self, PyObject *args) {
768
769
/* calculate size and bearing for a given string */
769
770
770
771
if (!PyArg_ParseTuple (
771
- args , "O|zzOzz:getsize" , & string , & mode , & dir , & features , & lang , & anchor
772
+ args ,
773
+ "O|zzOzz:getsize" ,
774
+ & string ,
775
+ & mode_name ,
776
+ & dir ,
777
+ & features ,
778
+ & lang ,
779
+ & anchor
772
780
)) {
773
781
return NULL ;
774
782
}
775
783
776
784
horizontal_dir = dir && strcmp (dir , "ttb" ) == 0 ? 0 : 1 ;
777
785
778
- mask = mode && strcmp (mode , "1" ) == 0 ;
779
- color = mode && strcmp (mode , "RGBA" ) == 0 ;
786
+ const ModeID mode = findModeID (mode_name );
787
+ mask = mode == IMAGING_MODE_1 ;
788
+ color = mode == IMAGING_MODE_RGBA ;
780
789
781
790
count = text_layout (string , self , dir , features , lang , & glyph_info , mask , color );
782
791
if (PyErr_Occurred ()) {
@@ -842,7 +851,7 @@ font_render(FontObject *self, PyObject *args) {
842
851
float stroke_width = 0 ;
843
852
PY_LONG_LONG foreground_ink_long = 0 ;
844
853
unsigned int foreground_ink ;
845
- const char * mode = NULL ;
854
+ const char * mode_name = NULL ;
846
855
const char * dir = NULL ;
847
856
const char * lang = NULL ;
848
857
const char * anchor = NULL ;
@@ -862,7 +871,7 @@ font_render(FontObject *self, PyObject *args) {
862
871
"OO|zzOzfzLffO:render" ,
863
872
& string ,
864
873
& fill ,
865
- & mode ,
874
+ & mode_name ,
866
875
& dir ,
867
876
& features ,
868
877
& lang ,
@@ -875,8 +884,9 @@ font_render(FontObject *self, PyObject *args) {
875
884
return NULL ;
876
885
}
877
886
878
- mask = mode && strcmp (mode , "1" ) == 0 ;
879
- color = mode && strcmp (mode , "RGBA" ) == 0 ;
887
+ const ModeID mode = findModeID (mode_name );
888
+ mask = mode == IMAGING_MODE_1 ;
889
+ color = mode == IMAGING_MODE_RGBA ;
880
890
881
891
foreground_ink = foreground_ink_long ;
882
892
0 commit comments