Skip to content

Commit

Permalink
Merge pull request #179 from Neradoc/wrap_text_to_pixels-no-bad-char
Browse files Browse the repository at this point in the history
Ignore characters that are not printable in wrap_text_to_pixels
  • Loading branch information
FoamyGuy authored Dec 31, 2022
2 parents 0b209f9 + 6a3e7bf commit 4039615
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion adafruit_display_text/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def measure(text):
font.load_glyphs(string)

def measure(text):
return sum(font.get_glyph(ord(c)).shift_x for c in text)
total_len = 0
for char in text:
this_glyph = font.get_glyph(ord(char))
if this_glyph:
total_len += this_glyph.shift_x
return total_len

lines = []
partial = [indent0]
Expand Down

0 comments on commit 4039615

Please sign in to comment.