From 2014a1475f96e54006cf1adb2e101cc167cccb93 Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Sun, 10 Sep 2023 01:19:52 +0200 Subject: [PATCH] Fix hanging sign text size and line height. --- .../java/se/llbit/chunky/entity/HangingSignEntity.java | 4 ++-- chunky/src/java/se/llbit/chunky/entity/SignEntity.java | 4 ++-- .../se/llbit/chunky/entity/WallHangingSignEntity.java | 4 ++-- .../src/java/se/llbit/chunky/entity/WallSignEntity.java | 2 +- .../src/java/se/llbit/chunky/resources/SignTexture.java | 9 +++------ 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java index ebcc70ca5d..ccd621f15f 100644 --- a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java @@ -267,8 +267,8 @@ public HangingSignEntity(Vector3 position, JsonArray[] frontText, JsonArray[] ba this.backText = backText; this.angle = rotation; this.attached = attached; - this.frontTexture = frontText != null ? new SignTexture(frontText, signTexture, 14, 10, 2 / 64., 1 - 24 / 32., 16 / 64., 1 - 14 / 32.) : null; - this.backTexture = backText != null ? new SignTexture(backText, signTexture, 14, 10, 18 / 64., 1 - 24 / 32., 32 / 64., 1 - 14 / 32.) : null; + this.frontTexture = frontText != null ? new SignTexture(frontText, signTexture, 14, 10, 2 / 64., 1 - 24 / 32., 16 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; + this.backTexture = backText != null ? new SignTexture(backText, signTexture, 14, 10, 18 / 64., 1 - 24 / 32., 32 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java index 2330ce6fda..e4915f1920 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java @@ -193,8 +193,8 @@ public SignEntity(Vector3 position, JsonArray[] frontText, JsonArray[] backText, this.frontText = frontText; this.backText = backText; this.angle = direction; - this.frontTexture = frontText != null ? new SignTexture(frontText, signTexture, 24, 12, 2 / 64., 18 / 32., 26 / 64., 30 / 32.) : null; - this.backTexture = backText != null ? new SignTexture(backText, signTexture, 24, 12, 28 / 64., 18 / 32., 52 / 64., 30 / 32.) : null; + this.frontTexture = frontText != null ? new SignTexture(frontText, signTexture, 24, 12, 2 / 64., 18 / 32., 26 / 64., 30 / 32., 4, 1, 10) : null; + this.backTexture = backText != null ? new SignTexture(backText, signTexture, 24, 12, 28 / 64., 18 / 32., 52 / 64., 30 / 32., 4, 1, 10) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java index 7df68570e8..104c53425e 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java @@ -246,8 +246,8 @@ public WallHangingSignEntity(Vector3 position, JsonArray[] frontText, JsonArray[ this.frontText = frontText; this.backText = backText; this.orientation = direction; - this.frontTexture = frontText != null ? new SignTexture(frontText, signTexture, 14, 10, 2 / 64., 1 - 24 / 32., 16 / 64., 1 - 14 / 32.) : null; - this.backTexture = backText != null ? new SignTexture(backText, signTexture, 14, 10, 18 / 64., 1 - 24 / 32., 32 / 64., 1 - 14 / 32.) : null; + this.frontTexture = frontText != null ? new SignTexture(frontText, signTexture, 14, 10, 2 / 64., 1 - 24 / 32., 16 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; + this.backTexture = backText != null ? new SignTexture(backText, signTexture, 14, 10, 18 / 64., 1 - 24 / 32., 32 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java index fd89f1e4a0..224799a123 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java @@ -108,7 +108,7 @@ public WallSignEntity(Vector3 position, JsonArray[] text, int direction, String Texture signTexture = SignEntity.textureFromMaterial(material); this.orientation = direction; this.text = text; - this.frontTexture = text != null ? new SignTexture(text, signTexture, 24, 12, 2 / 64., 18 / 32., 26 / 64., 30 / 32.) : null; + this.frontTexture = text != null ? new SignTexture(text, signTexture, 24, 12, 2 / 64., 18 / 32., 26 / 64., 30 / 32., 4, 1, 10) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/resources/SignTexture.java b/chunky/src/java/se/llbit/chunky/resources/SignTexture.java index dd3f139c99..f56a6bd3b4 100644 --- a/chunky/src/java/se/llbit/chunky/resources/SignTexture.java +++ b/chunky/src/java/se/llbit/chunky/resources/SignTexture.java @@ -25,7 +25,6 @@ import se.llbit.math.Vector4; public class SignTexture extends Texture { - private static final int FONT_PIXELS_PER_PIXEL = 4; private final double hh, ww, u0, v0; private final Texture signTexture; private final PalettizedBitmapImage textColor; @@ -40,12 +39,10 @@ static private boolean hasVisibleCharacter(JsonArray line) { return false; } - public SignTexture(JsonArray[] text, Texture signTexture, int signWidth, int signHeight, double x0, double y0, double x1, double y1) { + public SignTexture(JsonArray[] text, Texture signTexture, int signWidth, int signHeight, double x0, double y0, double x1, double y1, double fontSize, int ymargin, int lineHeight) { this.signTexture = signTexture; - int ymargin = 1; - int lineHeight = 10; - int width = signWidth * FONT_PIXELS_PER_PIXEL; - int height = signHeight * FONT_PIXELS_PER_PIXEL; + int width = (int) Math.ceil(signWidth * fontSize); + int height = (int) Math.ceil(signHeight * fontSize); int ystart = ymargin; boolean allEmpty = true; for (JsonArray line : text) {