Skip to content

Commit

Permalink
update text.d
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Mar 25, 2024
1 parent 0f6ad88 commit 134ea07
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pixelperfectengine/src/pixelperfectengine/graphics/text.d
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public class TextTempl(BitmapType = Bitmap8Bit) {
}

}
if (currentWord.length) { //Flush any remaining words to current chunk. BUG: is not reached for some reason.
if (currentWord.length) { //Flush any remaining words to current chunk. BUG: is not reached for some reason. NOTE: Likely isn't the reason for the no-flush error and is not needed.
if (currentLineLength + currentWordLength <= width) { //Check if there's enough space in the line for the current word, if no, then start a new line.
currentLineLength += currentWordLength;
currentChunk._text ~= currentWord;
Expand All @@ -332,20 +332,21 @@ public class TextTempl(BitmapType = Bitmap8Bit) {
currentWord.length = 0;
currentWordLength = 0;
}

curr = curr.next;
if (curr) {
curr = curr.next; //Step to the next textchunk
if (curr) { //If exists, do some checks
if ((curr.flags & Flags.newLine) || (curr.flags & Flags.newParagraph)) { //Force text breakage, put text chunk into the array.
result ~= currentLine;
currentLine = new TextTempl!(BitmapType)(null, curr.formatting, null, 0, curr.icon);
currentChunk = currentLine;
currentLineLength = 0;
currentWord.length = 0;
currentWord.length = 0;
currentWordLength = 0;
} else {
} else { //No new line needed, just create new chunk.
currentChunk = new TextTempl!(BitmapType)(null, curr.formatting, null, 0, curr.icon);
currentLine.addToEnd(currentChunk);
}
} else if (result[$-1] !is currentLine) { //end of text reached, flush any text if needed
result ~= currentLine;
}
}
if (!result.length) return [currentLine];
Expand Down

0 comments on commit 134ea07

Please sign in to comment.