Java 在 LibGDX 中缩放位图字体
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29907063/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Scale a Bitmapfont in LibGDX
提问by Pedro Romano Barbosa
How can I scale a Bitmapfont object in LibGDX? It seems the method setScale is no longer available.
如何在 LibGDX 中缩放 Bitmapfont 对象?似乎方法 setScale 不再可用。
采纳答案by Fish
It is not recommended to scale Bitmap font, because it looks pixlated when enlarged(which I believe is ugly)
不建议缩放位图字体,因为放大后看起来像素化(我认为这很丑陋)
It is recommended to use freetype generatorfor resizing your fonts
建议使用freetype 生成器来调整字体大小
If you still want use bitmapFont Tenfour04 is correct
如果你还想使用位图字体 Tenfour04 是正确的
回答by Tenfour04
Use bitmapFont.getData().setScale(float x, float y)
.
使用bitmapFont.getData().setScale(float x, float y)
.
回答by Nasser Tahani
As Fish mentioned, it is recommended to use freetype generator as following:
正如 Fish 提到的,建议使用 freetype 生成器,如下所示:
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/timesBold.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
Then change the font size in parameter and initialize BitmapFont:
然后改变参数中的字体大小并初始化BitmapFont:
fontParameter.size = 18;
BitmapFont font = fontGenerator.generateFont(fontParameter);
It is also needed to include libgdx-freetype.so in armeabi folder of your project.
还需要在项目的 armeabi 文件夹中包含 libgdx-freetype.so。