@@ -141,7 +141,7 @@ def draw_image(self, gc, x, y, im):
141
141
def draw_text (self , gc , x , y , s , prop , angle , ismath ):
142
142
x , y = int (x ), int (y )
143
143
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
145
145
return
146
146
147
147
if angle not in (0 ,90 ):
@@ -156,6 +156,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
156
156
else :
157
157
layout , inkRect , logicalRect = self ._get_pango_layout (s , prop )
158
158
l , b , w , h = inkRect
159
+ if (x + w > self .width or y + h > self .height ):
160
+ return
161
+
159
162
self .gdkDrawable .draw_layout (gc .gdkGC , x , y - h - b , layout )
160
163
161
164
@@ -224,7 +227,8 @@ def _draw_rotated_text(self, gc, x, y, s, prop, angle):
224
227
x = int (x - h )
225
228
y = int (y - w )
226
229
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 ):
228
232
return
229
233
230
234
key = (x ,y ,s ,angle ,hash (prop ))
0 commit comments