Skip to content

Commit 4039615

Browse files
authored
Merge pull request #179 from Neradoc/wrap_text_to_pixels-no-bad-char
Ignore characters that are not printable in wrap_text_to_pixels
2 parents 0b209f9 + 6a3e7bf commit 4039615

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adafruit_display_text/__init__.py

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ def measure(text):
5656
font.load_glyphs(string)
5757

5858
def measure(text):
59-
return sum(font.get_glyph(ord(c)).shift_x for c in text)
59+
total_len = 0
60+
for char in text:
61+
this_glyph = font.get_glyph(ord(char))
62+
if this_glyph:
63+
total_len += this_glyph.shift_x
64+
return total_len
6065

6166
lines = []
6267
partial = [indent0]

0 commit comments

Comments
 (0)