我正在制作一个可帮助我记住正在学习的泰语单词的应用程序。
但是我无法正确显示文本。
我使用此示例创建了一个基本场景。到目前为止,这就是我所拥有的。
public class ThaiWords extends ApplicationAdapter {
OrthographicCamera cam;
SpriteBatch batch;
BitmapFont thaiFont;
@Override
public void create () {
FreeTypeFontGenerator generator;
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 18;
parameter.characters = "ก";
generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/garuda.ttf"));
thaiFont = generator.generateFont(parameter);
generator.dispose();
batch = new SpriteBatch();
cam = new OrthographicCamera();
cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.update();
}
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(cam.combined);
batch.begin();
thaiFont.draw(batch, "ก", 0, 66);
batch.end();
}
@Override
public void resize (int width, int height) {
cam.setToOrtho(false, width, height);
}
}
为了进行测试,我只想显示“ก”字符。上面的代码产生一个“?” 象征。
我直接从libGDX目录下载了garuda.tff字体。
我真的不确定我缺少什么!我什至试图在运行时之前生成位图,但是却产生了黑屏。
任何建议将是巨大的!
编辑:我在Android Studio上注意到,当我关闭并重新打开项目时,实际代码从“ก”更改为“?”。这可能是编码问题,但我不知道如何解决。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句