From d9f759eb4300da0df7064b7eef89faac39595809 Mon Sep 17 00:00:00 2001 From: caternuson Date: Thu, 18 Jun 2020 10:19:25 -0700 Subject: [PATCH] add glyph check --- adafruit_display_text/label.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index a8b64c9..a1f467f 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -141,8 +141,9 @@ def _create_background_box(self, lines, y_offset): ascender_max = descender_max = 0 for char in glyphs: this_glyph = self._font.get_glyph(ord(char)) - ascender_max = max(ascender_max, this_glyph.height + this_glyph.dy) - descender_max = max(descender_max, -this_glyph.dy) + if this_glyph: + ascender_max = max(ascender_max, this_glyph.height + this_glyph.dy) + descender_max = max(descender_max, -this_glyph.dy) box_width = self._boundingbox[2] + self._padding_left + self._padding_right x_box_offset = -self._padding_left