@@ -141,7 +141,7 @@ def draw_image(self, gc, x, y, im):
141141 def draw_text (self , gc , x , y , s , prop , angle , ismath ):
142142 x , y = int (x ), int (y )
143143
144- if x < 0 or y < 0 : # window has shrunk and text is off the edge
144+ if x < 0 or y < 0 : # window has shrunk and text is off the edge
145145 return
146146
147147 if angle not in (0 ,90 ):
@@ -156,6 +156,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
156156 else :
157157 layout , inkRect , logicalRect = self ._get_pango_layout (s , prop )
158158 l , b , w , h = inkRect
159+ if (x + w > self .width or y + h > self .height ):
160+ return
161+
159162 self .gdkDrawable .draw_layout (gc .gdkGC , x , y - h - b , layout )
160163
161164
@@ -224,7 +227,8 @@ def _draw_rotated_text(self, gc, x, y, s, prop, angle):
224227 x = int (x - h )
225228 y = int (y - w )
226229
227- if x < 0 or y < 0 : # window has shrunk and text is off the edge
230+ if (x < 0 or y < 0 or # window has shrunk and text is off the edge
231+ x + w > self .width or y + h > self .height ):
228232 return
229233
230234 key = (x ,y ,s ,angle ,hash (prop ))
0 commit comments