android - libGDX 显示ttf字体出错
大家讲道理
大家讲道理 2017-04-17 18:01:00
0
1
588

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();

}
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
Ty80

Finally, I found that there was a problem with the ttf file. I changed a few ttf files before it was displayed normally. I recommend a ttf website to everyone. It feels good http://font.chinaz.com/

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template