aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/FlatTextSpan.java29
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];