@@ -609,6 +609,8 @@ font_getsize(FontObject* self, PyObject* args)
609609 FT_Face face ;
610610 int xoffset , yoffset ;
611611 int horizontal_dir ;
612+ int mask = 0 ;
613+ int load_flags ;
612614 const char * dir = NULL ;
613615 const char * lang = NULL ;
614616 size_t i , count ;
@@ -618,11 +620,11 @@ font_getsize(FontObject* self, PyObject* args)
618620 /* calculate size and bearing for a given string */
619621
620622 PyObject * string ;
621- if (!PyArg_ParseTuple (args , "O|zOz :getsize" , & string , & dir , & features , & lang )) {
623+ if (!PyArg_ParseTuple (args , "O|izOz :getsize" , & string , & mask , & dir , & features , & lang )) {
622624 return NULL ;
623625 }
624626
625- count = text_layout (string , self , dir , features , lang , & glyph_info , 0 );
627+ count = text_layout (string , self , dir , features , lang , & glyph_info , mask );
626628 if (PyErr_Occurred ()) {
627629 return NULL ;
628630 }
@@ -641,7 +643,11 @@ font_getsize(FontObject* self, PyObject* args)
641643 /* Note: bitmap fonts within ttf fonts do not work, see #891/pr#960
642644 * Yifu Yu<root@jackyyf.com>, 2014-10-15
643645 */
644- error = FT_Load_Glyph (face , index , FT_LOAD_DEFAULT |FT_LOAD_NO_BITMAP );
646+ load_flags = FT_LOAD_NO_BITMAP ;
647+ if (mask ) {
648+ load_flags |= FT_LOAD_TARGET_MONO ;
649+ }
650+ error = FT_Load_Glyph (face , index , load_flags );
645651 if (error ) {
646652 return geterror (error );
647653 }
0 commit comments