diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-07 21:21:39 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-07 21:21:39 +0900 |
commit | e0c1d208663c943fc63dbea6e8860df56135ea5e (patch) | |
tree | 20165f31062154baf79f6d25f52af4da4576edc8 /mod/src | |
parent | 62f2392a59a4025bc9e1dedae0c761e99b2dcaa3 (diff) | |
download | Skyblock-Dungeons-Guide-e0c1d208663c943fc63dbea6e8860df56135ea5e.tar.gz Skyblock-Dungeons-Guide-e0c1d208663c943fc63dbea6e8860df56135ea5e.tar.bz2 Skyblock-Dungeons-Guide-e0c1d208663c943fc63dbea6e8860df56135ea5e.zip |
-wrapping fix
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src')
-rw-r--r-- | mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/FlatTextSpan.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/FlatTextSpan.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/FlatTextSpan.java index 71f3ca0e..ae1a7e01 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/FlatTextSpan.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/FlatTextSpan.java @@ -58,6 +58,7 @@ public class FlatTextSpan { int endIdx = value.length; boolean lineBroken = false; + boolean wasNewLine = false; for (int i = 0; i < value.length; i++) { char character = value[i]; charWidth = textStyle.getFontRenderer().getWidth(character, textStyle); @@ -83,6 +84,7 @@ public class FlatTextSpan { if (character == '\n') { endIdx = i+1; lineBroken = true; + wasNewLine = true; break; } @@ -120,10 +122,14 @@ public class FlatTextSpan { char[] second = null; if (lineBroken) { int startRealWord = -1; - for (int i = endIdx; i< value.length; i++) { - if (value[i] == ' ') continue; - startRealWord = i; - break; + if (!wasNewLine) { + for (int i = endIdx; i < value.length; i++) { + if (value[i] == ' ') continue; + startRealWord = i; + break; + } + } else { + startRealWord = endIdx; } if (startRealWord != -1) { second = new char[value.length - startRealWord]; @@ -150,7 +156,7 @@ public class FlatTextSpan { double totalWidth = 0; double effectiveWidth = 0; boolean lineBroken =false; - + boolean wasNewLine = false; int endIdx = value.length; for (int i = 0; i < value.length; i++) { char character = value[i]; @@ -162,6 +168,7 @@ public class FlatTextSpan { // Force break. endIdx = i + 1; lineBroken = true; + wasNewLine = true; break; } @@ -180,10 +187,14 @@ public class FlatTextSpan { char[] second = null; if (lineBroken) { int startRealWord = -1; - for (int i = endIdx; i< value.length; i++) { - if (value[i] == ' ') continue; - startRealWord = i; - break; + if (!wasNewLine) { + for (int i = endIdx; i < value.length; i++) { + if (value[i] == ' ') continue; + startRealWord = i; + break; + } + } else { + startRealWord = endIdx; } if (startRealWord != -1) { second = new char[value.length - startRealWord]; |