Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/matplotlib/backends/backend_gdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def draw_image(self, gc, x, y, im):
def draw_text(self, gc, x, y, s, prop, angle, ismath):
x, y = int(x), int(y)

if x <0 or y <0: # window has shrunk and text is off the edge
if x < 0 or y < 0: # window has shrunk and text is off the edge
return

if angle not in (0,90):
Expand All @@ -157,6 +157,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
else:
layout, inkRect, logicalRect = self._get_pango_layout(s, prop)
l, b, w, h = inkRect
if (x + w > self.width or y + h > self.height):
return

self.gdkDrawable.draw_layout(gc.gdkGC, x, y-h-b, layout)


Expand Down Expand Up @@ -225,7 +228,8 @@ def _draw_rotated_text(self, gc, x, y, s, prop, angle):
x = int(x-h)
y = int(y-w)

if x < 0 or y < 0: # window has shrunk and text is off the edge
if (x < 0 or y < 0 or: # window has shrunk and text is off the edge
x + w > self.width or y + h > self.height):
return

key = (x,y,s,angle,hash(prop))
Expand Down