Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- fix: Initial window size limits are now properly applied when the window is (almost) larger than the screen.
- fix: The default choice screen displays previously selected choices in a different color. If you saved at a choice, the colors wouldn't update when loading.
- fix: Debug adapter: Relative path handling used by breakpoints didn't always work on case-insensitive file systems.
- fix: Parts of lines would sometimes be cut off or missing from the text log due to a rounding error.

# v4.9.6
- fix: File permissions were broken for Linux/Mac builds when building on a file system which doesn't support permissions (e.g. NTFS on Windows)
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/nl/weeaboo/vn/impl/text/TextRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ public void setMaxSize(double w, double h) {
}

private int getLayoutMaxWidth() {
return (int)Math.floor(getMaxWidth());
return (int)Math.round(getMaxWidth());
}

private int getLayoutMaxHeight() {
return (int)Math.floor(getMaxHeight());
return (int)Math.round(getMaxHeight());
}

@Override
Expand Down Expand Up @@ -341,7 +341,7 @@ public void setRightToLeft(boolean rtl) {

@Override
public void setSize(double w, double h) {
setMaxSize((int)Math.floor(w), (int)Math.floor(h));
setMaxSize((int)Math.ceil(w), (int)Math.ceil(h));

super.setSize(w, h);
}
Expand Down
17 changes: 17 additions & 0 deletions core/src/test/java/nl/weeaboo/vn/impl/text/TextRendererTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import nl.weeaboo.test.RectAssert;
import nl.weeaboo.vn.core.VerticalAlign;
import nl.weeaboo.vn.impl.core.StaticEnvironment;
import nl.weeaboo.vn.layout.ILayoutElem;

public class TextRendererTest {

Expand Down Expand Up @@ -132,6 +133,17 @@ public void testLineBounds() {
assertLineBounds(0, Rect2D.EMPTY);
}

/**
* Calculation of max width/height for {@link ILayoutElem} purposes.
*/
@Test
public void testMaxWidth() {
textRenderer.setText("one\ntwo\nthree");
textRenderer.setSize(63.999, 12.34);

assertMaxSize(64.0, 13.0);
}

private void assertLineBounds(int lineIndex, Rect2D expectedBounds) {
Rect2D actualBounds = textRenderer.getLineBounds(lineIndex);
RectAssert.assertEquals(expectedBounds, actualBounds, 0.0);
Expand All @@ -154,4 +166,9 @@ private void assertFinalLineFullyVisible(boolean expected) {
Assert.assertEquals(expected, textRenderer.isFinalLineFullyVisible());
}

private void assertMaxSize(double expectedW, double expectedH) {
Assert.assertEquals(expectedW, textRenderer.getMaxWidth(), 0.0);
Assert.assertEquals(expectedH, textRenderer.getMaxHeight(), 0.0);
}

}