有谁知道如何在libGDX中使用TTF字体?我环顾四周,看过有关StbTrueTypeFont的事情,但它似乎没有出现在最新版本中.
编辑:我发现了StbTrueType字体的东西,jar文件位于extensions目录中.我已将它添加到我的项目中.现在我只需要弄清楚如何使用它.任何例子?
我目前正在尝试扩展字体,但我收到错误"方法setScale(float,float)未定义类型BitmapFont"这是我得到错误的代码部分,特别是在第2行和第4行.
font = new BitmapFont(Gdx.files.internal("text.fnt"));
font.setScale (.25f, -.25f);
shadow = new BitmapFont(Gdx.files.internal("shadow.fnt"));
shadow.setScale (.25f -.25f);
Run Code Online (Sandbox Code Playgroud)
我在这里创建了变量
public static BitmapFont font;
public static BitmapFont shadow;
Run Code Online (Sandbox Code Playgroud)
当我检查使用setScale函数的其他示例时,这似乎是使用的格式.有关为什么会发生这种情况的任何想法?
我正在尝试渲染平滑的可缩放位图字体。检查此问题后,使用距离场字体提到的答案之一。
我正在按照LibGDX wiki 文章中关于距离归档字体的方式进行操作。但是我无法让它工作。字体变得模糊。

这是我用来生成此输出的代码
public class FontRenderTest implements ApplicationListener {
private Texture texture;
private SpriteBatch spriteBatch;
private BitmapFont font;
@Override
public void create() {
spriteBatch = new SpriteBatch();
Texture texture = new Texture(Gdx.files.internal("Raleway.png"), true); // true enables mipmaps
texture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Linear); // linear filtering in nearest mipmap image
font = new BitmapFont(Gdx.files.internal("Raleway.fnt"), new TextureRegion(texture), false);
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
spriteBatch.begin();
font.draw(spriteBatch, "This is hazy !!", 100, 150); …Run Code Online (Sandbox Code Playgroud)