summaryrefslogtreecommitdiff
path: root/wasp
diff options
context:
space:
mode:
Diffstat (limited to 'wasp')
-rw-r--r--wasp/draw565.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/wasp/draw565.py b/wasp/draw565.py
index f82a345..c84b1ec 100644
--- a/wasp/draw565.py
+++ b/wasp/draw565.py
@@ -370,15 +370,19 @@ class Draw565(object):
if i >= len(s):
break
ch = s[i]
+ (_, h, w) = font.get_ch(ch)
+ l += w + 1
+ if l > width:
+ break
+
+ # Break the line immediately if requested
if ch == '\n':
end = i+1
break
+
+ # Remember the right-most place we can cleanly break the line
if ch == ' ':
end = i+1
- (_, h, w) = font.get_ch(ch)
- l += w + 1
- if l > width:
- break
if end <= start:
end = i
chunks.append(end)