Skip to content

Commit

Permalink
Merge pull request #15 from BastiaanOlij/fix_text_wrap
Browse files Browse the repository at this point in the history
Reset width in wrapText on newline
  • Loading branch information
BastiaanOlij authored Nov 6, 2023
2 parents da9fe12 + 68edfcd commit 6a2cd99
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions oDrawingCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,22 @@ qstring oDrawingCanvas::wrapText(const qchar *pText, qdim pMaxWidth) {
} else {
while (pText[pos] != 0) {
if (pText[pos] == (qchar)'\r') {
width = addWord(retval, word, prefix, width, pMaxWidth);
addWord(retval, word, prefix, width, pMaxWidth);
word = "";
prefix = "";

retval += (qchar)'\n'; // prevent expensive UTF-8 => UTF-32 conversion
width = 0; // we are on a new line, so reset width
} else if (pText[pos] == (qchar)'\n') {
if (pText[pos + 1] == (qchar)'\r') { // windows newline?
pos++;
};
width = addWord(retval, word, prefix, width, pMaxWidth);
addWord(retval, word, prefix, width, pMaxWidth);
word = "";
prefix = "";

retval += (qchar)'\n'; // prevent expensive UTF-8 => UTF-32 conversion
width = 0; // we are on a new line, so reset width
} else if (pText[pos] == (qchar)' ') {
if (word.length() > 0) {
width = addWord(retval, word, prefix, width, pMaxWidth);
Expand Down

0 comments on commit 6a2cd99

Please sign in to comment.