私はこのコードを使用して、20文字ごとに行を改行しようとしています:
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();
}
}
標準フォントで問題なく動作します。ただし、フォントを Verdana に変更すると、改行が代わりにスペースに変換されます。これは何が原因ですか?
フォントは次のとおりです。
Font awtFont = new Font("Verdana", Font.PLAIN, 13);
this.font = new TrueTypeFont(awtFont, true);