0

我试图让我的行每 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);
4

1 回答 1

2

我使用的框架 Slick2d 有一个不支持 \n 换行符的 TrueTypeFont 类。

于 2012-12-05T08:19:41.263 回答