summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrwastl <mrwastl@users.sourceforge.net>2011-06-21 23:51:39 +0200
committermrwastl <mrwastl@users.sourceforge.net>2011-06-21 23:51:39 +0200
commit99a603c7e73df46d1f7c4c5bef0825b90450e69e (patch)
tree5706a282148ac17ac8afa8508cee7ff079a67096
parent9405da4eb53ad02d2176ce285d03c0c445b81f12 (diff)
downloadgraphlcd-base-99a603c7e73df46d1f7c4c5bef0825b90450e69e.tar.gz
graphlcd-base-99a603c7e73df46d1f7c4c5bef0825b90450e69e.tar.bz2
try to fix wrapping bugs in WrapText()
-rw-r--r--glcdgraphics/font.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/glcdgraphics/font.c b/glcdgraphics/font.c
index 29027d0..2c6e3fa 100644
--- a/glcdgraphics/font.c
+++ b/glcdgraphics/font.c
@@ -585,24 +585,24 @@ void cFont::WrapText(int Width, int Height, std::string & Text,
if (Text[pos] == '\n')
{
Lines.push_back(trim(Text.substr(start, pos - start)));
- start = pos + 1;
- posLast = pos + 1;
+ start = pos /*+ 1*/;
+ posLast = pos /*+ 1*/;
textWidth = 0;
lineCount++;
}
- else if (textWidth > Width && (lineCount + 1) < maxLines)
+ else if (textWidth >= Width && (lineCount + 1) < maxLines)
{
if (posLast > start)
{
Lines.push_back(trim(Text.substr(start, posLast - start)));
- start = posLast + 1;
+ start = posLast /*+ 1*/;
posLast = start;
textWidth = this->Width(Text.substr(start, pos - start + 1)) + spaceBetween;
}
else
{
Lines.push_back(trim(Text.substr(start, pos - start)));
- start = pos + 1;
+ start = pos /*+ 1*/;
posLast = start;
textWidth = this->Width(Text[pos]) + spaceBetween;
}
@@ -622,19 +622,19 @@ void cFont::WrapText(int Width, int Height, std::string & Text,
if (Height == 0 || lineCount < maxLines)
{
- if (textWidth > Width && (lineCount + 1) < maxLines)
+ if (textWidth >= Width && (lineCount + 1) < maxLines)
{
if (posLast > start)
{
Lines.push_back(trim(Text.substr(start, posLast - start)));
- start = posLast + 1;
+ start = posLast /*+ 1*/;
posLast = start;
textWidth = this->Width(Text.substr(start, pos - start + 1)) + spaceBetween;
}
else
{
Lines.push_back(trim(Text.substr(start, pos - start)));
- start = pos + 1;
+ start = pos /*+ 1*/;
posLast = start;
textWidth = this->Width(Text[pos]) + spaceBetween;
}