0

as the title says i have a small problem with fot-size in eclipse. i created a font using "BMfont", and i implemented it in my game, but when i tested it on a smaller device it was way too big, is there a code i can use to make it adjust automatically. im using Libgdx ,any help is appreciated.

my code

@Override
public void show() {
    stage = new Stage();

    Gdx.input.setInputProcessor(stage);

    atlas = new TextureAtlas("ui/button.pack");
    skin = new Skin(atlas);

    table = new Table(skin);
    table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    white = new BitmapFont(Gdx.files.internal("font/white.fnt"), false);
    black = new BitmapFont(Gdx.files.internal("font/black.fnt"), false);
    //maakt buttons
    TextButtonStyle textButtonStyle = new TextButtonStyle();
    textButtonStyle.up = skin.getDrawable("button.up");
    textButtonStyle.down = skin.getDrawable("button.down");
    textButtonStyle.pressedOffsetX = 1;
    textButtonStyle.pressedOffsetY = -1;
    textButtonStyle.font = black;


    buttonExit = new TextButton("EXIT", textButtonStyle);
    buttonExit.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
        }
    });

    buttonExit.pad(20);




    //maakt header
    LabelStyle headingStyle = new LabelStyle(white, Color.WHITE);


    heading = new Label(Papermadness.TITLE, headingStyle);
    heading.setFontScale(3);

    table.add(heading);
    table.row();
    table.add(buttonExit);
    //table.debug();
    stage.addActor(table);


}

2 Answers2

0

You have to check the display's density and multiply by the desired font size, so that the font is the same size across all devices.

See the link below:

https://gamedev.stackexchange.com/questions/24638/resolution-independence-in-libgdx

Community
  • 1
  • 1
  • thanks for your reply and the link, but they are using generator.generateFont, while i am using external fonts i creatd myself with Bmfont generator. – user3058036 Jun 27 '14 at 10:44
0

I think you should use youeBitmapFont.setScale() and you should get screen size Gdx.graphics.getWidth() and multiple with some number

Vahe Muradyan
  • 1,115
  • 1
  • 11
  • 22