Skip to content

Commit

Permalink
Fix bug with empty lines in node label
Browse files Browse the repository at this point in the history
  • Loading branch information
FeldrinH committed Nov 18, 2023
1 parent f876571 commit c89a51d
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public void setText(String text, Backend backend) {
this.width = 0.0;
this.height = 0.0;
for (int i = 0; i < lines.length; i++) {
TextLayout line = new TextLayout(lines[i], font, TextBox.defaultFontRenderContext);
// Note: We replace empty lines with a single space, because TextLayout will throw an exception when given an empty string.
TextLayout line = new TextLayout(lines[i].isEmpty() ? " " : lines[i], font, TextBox.defaultFontRenderContext);
this.text[i] = line;
this.width = Math.max(this.width, line.getBounds().getWidth());
this.height += line.getAscent() + line.getDescent();
Expand Down

0 comments on commit c89a51d

Please sign in to comment.