@@ -605,6 +605,8 @@ font_getsize(FontObject* self, PyObject* args)
605605 FT_Face face ;
606606 int xoffset , yoffset ;
607607 int horizontal_dir ;
608+ int mask = 0 ;
609+ int load_flags ;
608610 const char * dir = NULL ;
609611 const char * lang = NULL ;
610612 size_t i , count ;
@@ -614,11 +616,11 @@ font_getsize(FontObject* self, PyObject* args)
614616 /* calculate size and bearing for a given string */
615617
616618 PyObject * string ;
617- if (!PyArg_ParseTuple (args , "O|zOz :getsize" , & string , & dir , & features , & lang )) {
619+ if (!PyArg_ParseTuple (args , "O|izOz :getsize" , & string , & mask , & dir , & features , & lang )) {
618620 return NULL ;
619621 }
620622
621- count = text_layout (string , self , dir , features , lang , & glyph_info , 0 );
623+ count = text_layout (string , self , dir , features , lang , & glyph_info , mask );
622624 if (PyErr_Occurred ()) {
623625 return NULL ;
624626 }
@@ -637,7 +639,11 @@ font_getsize(FontObject* self, PyObject* args)
637639 /* Note: bitmap fonts within ttf fonts do not work, see #891/pr#960
638640 * Yifu Yu<root@jackyyf.com>, 2014-10-15
639641 */
640- error = FT_Load_Glyph (face , index , FT_LOAD_DEFAULT |FT_LOAD_NO_BITMAP );
642+ load_flags = FT_LOAD_NO_BITMAP ;
643+ if (mask ) {
644+ load_flags |= FT_LOAD_TARGET_MONO ;
645+ }
646+ error = FT_Load_Glyph (face , index , load_flags );
641647 if (error ) {
642648 return geterror (error );
643649 }
0 commit comments