diff --git a/adafruit_framebuf.py b/adafruit_framebuf.py index 76f8dd0..37134cb 100755 --- a/adafruit_framebuf.py +++ b/adafruit_framebuf.py @@ -403,6 +403,12 @@ def text(self, string, x, y, color, *, font_name="font5x8.bin", size=1): Does not break on line going off screen. """ + # determine our effective width/height, taking rotation into account + frame_width = self.width + frame_height = self.height + if self.rotation == 1 or self.rotation == 3: + frame_width, frame_height = frame_height, frame_width + for chunk in string.split("\n"): if not self._font or self._font.font_name != font_name: # load the font! @@ -413,9 +419,9 @@ def text(self, string, x, y, color, *, font_name="font5x8.bin", size=1): char_x = x + (i * (width + 1)) * size if ( char_x + (width * size) > 0 - and char_x < self.width + and char_x < frame_width and y + (height * size) > 0 - and y < self.height + and y < frame_height ): self._font.draw_char(char, char_x, y, self, color, size=size) y += height * size