Skip to content

Commit

Permalink
fix: Character loss during text layout. (#317)
Browse files Browse the repository at this point in the history
Character loss during text layout.
  • Loading branch information
hellmor committed Oct 31, 2023
1 parent 7df4f95 commit 8ad7169
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/gui/uiComponents/TextFieldLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,18 @@ export class TextFieldLayout {
let parseText = (): void => {
let curLine: TextFieldLine = null;
let totalLength: number = text.length;
let autoWrap = false;
for (let i = 0; i < totalLength; i++) {
if (curLine == null) curLine = makeLine();
curLine ||= makeLine();
let char = text.charAt(i);
if (char == '\n' || autoWrap) {
//换行符
if (char == '\n' || char == '\t') {
//wrap symbol
curLine = null;
autoWrap = false;
} else {
makeQuad(char, curLine);
autoWrap = curLine.width + unitSize >= maxTextWidthReal;
let autoWrap = curLine.width + halfUnitSize >= maxTextWidthReal;
if (autoWrap) {
curLine = makeLine();
}
}
}
};
Expand Down

0 comments on commit 8ad7169

Please sign in to comment.