How can I scale a Bitmapfont object in LibGDX? It seems the method setScale is no longer available.
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 generator for resizing your fonts
If you still want use bitmapFont Tenfour04 is correct
Use bitmapFont.getData().setScale(float x, float y)
.
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 generator for resizing your fonts
If you still want use bitmapFont Tenfour04 is correct
As Fish mentioned, it is recommended to use freetype generator as following:
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:
fontParameter.size = 18;
BitmapFont font = fontGenerator.generateFont(fontParameter);
It is also needed to include libgdx-freetype.so in armeabi folder of your project.
You can assign Font Size to FreeTypeFontParameter while loading font
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Lobster.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 50; // font size
BitmapFont lobster= generator.generateFont(parameter);
generator.dispose();
© 2022 - 2024 — McMap. All rights reserved.