I’m trying to make my lines break every 20 characters, which i am using this code for:
for (Map.Entry<Integer, Character> keyWithLetter : keyMap.entrySet()) {
if (input.isKeyPressed(keyWithLetter.getKey())) {
String charCount = this.tekst.replaceAll("\\n", "");
if (charCount.length() % 20 == 0 && charCount.length() >= 20) {
this.tekst += "\n";
}
this.tekst += keyWithLetter.getValue();
}
}
It works fine with the standard font. However, when i change the font to Verdana, the linebreaks gets converted to spaces instead. What causes this?
Here’s the font:
Font awtFont = new Font("Verdana", Font.PLAIN, 13);
this.font = new TrueTypeFont(awtFont, true);
The framework i was using, Slick2d, have a TrueTypeFont class which doesn’t support the \n linebreak.