Skip to content

Commit

Permalink
Fix hanging sign text size and line height.
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaik committed Sep 9, 2023
1 parent 5dc625c commit 2014a14
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions chunky/src/java/se/llbit/chunky/entity/SignEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 3 additions & 6 deletions chunky/src/java/se/llbit/chunky/resources/SignTexture.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 2014a14

Please sign in to comment.