diff --git a/src/main/java/eu/m724/Renderer.java b/src/main/java/eu/m724/Renderer.java index 5290154..afe52aa 100644 --- a/src/main/java/eu/m724/Renderer.java +++ b/src/main/java/eu/m724/Renderer.java @@ -51,25 +51,28 @@ public class Renderer { int textHeight = (int) bounds.getHeight(); y += textHeight; + int textLength = text.length(); + String[] lines; if (textWidth > tileSize) { // TODO ideally this should be splitting by word int linesAmount = (int) Math.ceil((double) textWidth / tileSize); if (linesAmount * textHeight > tileSize) { - int removeChars = (int) (text.length() - (text.length() / ((double) textWidth / tileSize)) * (tileSize / textHeight)); - System.out.printf("Warning: text can't fit in a tile (%d > %d). Remove %d characters. \"%s\"\n", linesAmount * textHeight, tileSize, removeChars, text); + double tsd = tileSize; + int removeChars = (int) (textLength - (textLength / (textWidth / tsd)) * (tsd / textHeight)); + System.out.printf("Warning: text doesn't fit in a tile (%d > %d). Remove %d characters. \"%s\"\n", linesAmount * textHeight, tileSize, removeChars, text); } lines = new String[linesAmount]; - int partLength = text.length() / linesAmount; + int partLength = textLength / linesAmount; for (int i=0; i