libGDX版本1.6.1
使用ttf文件显示字体时显示不正确
private BitmapFont mFont;
private FreeTypeFontGenerator mFontGenerator;
private FreeTypeFontGenerator.FreeTypeBitmapFontData mFontData;
private FreeTypeFontGenerator.FreeTypeFontParameter mFontParameter;
//初始化文字对象
mFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
mFontParameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
mFontParameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS+"hello 你好吗";
mFontParameter.size = 40;
mFontParameter.color = Color.RED;
mFont = mFontGenerator.generateFont(mFontParameter);
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1); //设置背景白色
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
mBatch.begin();
//文字
mFont.draw(mBatch,"hello 你好吗",450,100);
mBatch.end();
}