@@ -142,7 +142,7 @@ def draw_image(self, gc, x, y, im):
142
142
def draw_text (self , gc , x , y , s , prop , angle , ismath ):
143
143
x , y = int (x ), int (y )
144
144
145
- if x < 0 or y < 0 : # window has shrunk and text is off the edge
145
+ if x < 0 or y < 0 : # window has shrunk and text is off the edge
146
146
return
147
147
148
148
if angle not in (0 ,90 ):
@@ -157,6 +157,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
157
157
else :
158
158
layout , inkRect , logicalRect = self ._get_pango_layout (s , prop )
159
159
l , b , w , h = inkRect
160
+ if (x + w > self .width or y + h > self .height ):
161
+ return
162
+
160
163
self .gdkDrawable .draw_layout (gc .gdkGC , x , y - h - b , layout )
161
164
162
165
@@ -225,7 +228,8 @@ def _draw_rotated_text(self, gc, x, y, s, prop, angle):
225
228
x = int (x - h )
226
229
y = int (y - w )
227
230
228
- if x < 0 or y < 0 : # window has shrunk and text is off the edge
231
+ if (x < 0 or y < 0 or : # window has shrunk and text is off the edge
232
+ x + w > self .width or y + h > self .height ):
229
233
return
230
234
231
235
key = (x ,y ,s ,angle ,hash (prop ))
0 commit comments