@@ -926,7 +926,7 @@ FT2Font::write_bitmap(const Py::Tuple & args) {
926926}
927927
928928char FT2Font::draw_rect__doc__[] =
929- " draw_bbox (x0, y0, x1, y1)\n "
929+ " draw_rect (x0, y0, x1, y1)\n "
930930" \n "
931931" Draw a rect to the image. It is your responsibility to set the dimensions\n "
932932" of the image, eg, with set_bitmap_size\n "
@@ -951,18 +951,52 @@ FT2Font::draw_rect(const Py::Tuple & args) {
951951 y0>iheight || y1>iheight )
952952 throw Py::ValueError (" Rect coords outside image bounds" );
953953
954- for (long i=x0; i<x1; ++i) {
954+ for (long i=x0; i<x1+ 1 ; ++i) {
955955 image.buffer [i + y0*iwidth] = 255 ;
956956 image.buffer [i + y1*iwidth] = 255 ;
957957 }
958958
959- for (long j=y0; j<y1; ++j) {
959+ for (long j=y0+ 1 ; j<y1; ++j) {
960960 image.buffer [x0 + j*iwidth] = 255 ;
961961 image.buffer [x1 + j*iwidth] = 255 ;
962962 }
963963 return Py::Object ();
964964}
965965
966+ char FT2Font::draw_rect_filled__doc__[] =
967+ " draw_rect_filled(x0, y0, x1, y1)\n "
968+ " \n "
969+ " Draw a filled rect to the image. It is your responsibility to set the\n "
970+ " dimensions of the image, eg, with set_bitmap_size\n "
971+ " \n "
972+ ;
973+ Py::Object
974+ FT2Font::draw_rect_filled (const Py::Tuple & args) {
975+ _VERBOSE (" FT2Font::draw_rect_filled" );
976+
977+ args.verify_length (4 );
978+
979+ long x0 = Py::Int (args[0 ]);
980+ long y0 = Py::Int (args[1 ]);
981+ long x1 = Py::Int (args[2 ]);
982+ long y1 = Py::Int (args[3 ]);
983+
984+ FT_Int iwidth = (FT_Int)image.width ;
985+ FT_Int iheight = (FT_Int)image.height ;
986+
987+ if ( x0<0 || y0<0 || x1<0 || y1<0 ||
988+ x0>iwidth || x1>iwidth ||
989+ y0>iheight || y1>iheight )
990+ throw Py::ValueError (" Rect coords outside image bounds" );
991+
992+ for (long j=y0; j<y1; ++j) {
993+ for (long i=x0; i<x1+1 ; ++i) {
994+ image.buffer [i + j*iwidth] = 255 ;
995+ }
996+ }
997+ return Py::Object ();
998+ }
999+
9661000char FT2Font::image_as_str__doc__[] =
9671001" width, height, s = image_as_str()\n "
9681002" \n "
@@ -1562,6 +1596,8 @@ FT2Font::init_type() {
15621596 FT2Font::load_char__doc__);
15631597 add_varargs_method (" draw_rect" ,&FT2Font::draw_rect,
15641598 FT2Font::draw_rect__doc__);
1599+ add_varargs_method (" draw_rect_filled" ,&FT2Font::draw_rect_filled,
1600+ FT2Font::draw_rect_filled__doc__);
15651601 add_varargs_method (" draw_glyph_to_bitmap" , &FT2Font::draw_glyph_to_bitmap,
15661602 FT2Font::draw_glyph_to_bitmap__doc__);
15671603 add_varargs_method (" draw_glyphs_to_bitmap" , &FT2Font::draw_glyphs_to_bitmap,
0 commit comments