Skip to content

Commit

Permalink
Reset width in wrapText on newline
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiaanOlij committed Oct 31, 2023
1 parent da9fe12 commit 68edfcd
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 68edfcd

Please sign in to comment.