diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java | 2 | ||||
-rw-r--r-- | mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java index bd04ab42..341a0282 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java @@ -48,7 +48,7 @@ public class Text extends AnnotatedExportOnlyWidget { @Export(attributeName = "text") public final BindableAttribute<String> text = new BindableAttribute<>(String.class, ""); - private final ParentDelegatingTextStyle textStyle = new ParentDelegatingTextStyle(); + private final ParentDelegatingTextStyle textStyle = ParentDelegatingTextStyle.ofDefault(); private final RichText richText = new RichText(new TextSpan(textStyle, ""), BreakWord.WORD, true,RichText.TextAlign.LEFT); @Override public List<Widget> build(DomElement buildContext) { diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java index 614158fe..cc651a9d 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java @@ -159,15 +159,19 @@ public class RichText extends Widget implements Layouter, Renderer { public double getMaxIntrinsicHeight(DomElement buildContext, double width) { LinkedList<FlatTextSpan> flatTextSpans = new LinkedList<>(); rootSpan.flattenTextSpan(flatTextSpans::add); - double remaining = width; + double remaining = width == 0 ? Double.POSITIVE_INFINITY : width; double maxHeight = 0; double sumHeight = 0; while (!flatTextSpans.isEmpty()) { FlatTextSpan first = flatTextSpans.pollFirst(); - BrokenWordData brokenWordData = first.breakWord(remaining, width, breakWord); + BrokenWordData brokenWordData = first.breakWord(remaining, width == 0 ? Double.POSITIVE_INFINITY : width, breakWord); remaining -= brokenWordData.getFirstWidth(); + if (brokenWordData.getFirst().value.length == 0 && first.value.length != 0 && remaining == width) { + return 0; + } + maxHeight = Math.max(maxHeight, first.getHeight()); if (brokenWordData.getSecond() != null) { @@ -175,7 +179,7 @@ public class RichText extends Widget implements Layouter, Renderer { } if (brokenWordData.isBroken()) { - remaining = width; + remaining = width == 0 ? Double.POSITIVE_INFINITY : width; sumHeight += maxHeight; maxHeight = 0; } |