Skip to content

Commit 38c59be

Browse files
seifemarcelstoer
authored andcommitted
fix wrapping in drawStringMaxWidth()
if no "break point (space or dash) was found, a character was lost in the word wrapping routine
1 parent 216812c commit 38c59be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/OLEDDisplay.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ void OLEDDisplay::drawStringMaxWidth(int16_t xMove, int16_t yMove, uint16_t maxL
663663

664664
// Always try to break on a space or dash
665665
if (text[i] == ' ' || text[i]== '-') {
666-
preferredBreakpoint = i;
666+
preferredBreakpoint = i + 1;
667667
widthAtBreakpoint = strWidth;
668668
}
669669

@@ -673,7 +673,7 @@ void OLEDDisplay::drawStringMaxWidth(int16_t xMove, int16_t yMove, uint16_t maxL
673673
widthAtBreakpoint = strWidth;
674674
}
675675
drawStringInternal(xMove, yMove + (lineNumber++) * lineHeight , &text[lastDrawnPos], preferredBreakpoint - lastDrawnPos, widthAtBreakpoint);
676-
lastDrawnPos = preferredBreakpoint + 1;
676+
lastDrawnPos = preferredBreakpoint;
677677
// It is possible that we did not draw all letters to i so we need
678678
// to account for the width of the chars from `i - preferredBreakpoint`
679679
// by calculating the width we did not draw yet.

0 commit comments

Comments
 (0)