0
\$\begingroup\$

So I'm following along with some tutorials for creating an application with LibGDX, and when I go to print parts of the UI to the screen, the text is all bunched up. How do I increase the spacing, or is it due to something else I've done?

enter image description here

....
    game = gam;
    stage = new Stage(new StretchViewport(800, 400));
    Gdx.input.setInputProcessor(stage);
    uiSkin = new Skin(Gdx.files.internal("uiskin.json"), new TextureAtlas(Gdx.files.internal("uiskin.atlas")));
    Label nameLabel = new Label("Name:", uiSkin);
    TextField nameText = new TextField("", uiSkin);
    Label addressLabel = new Label("Address:", uiSkin);
    TextField addressText = new TextField("", uiSkin);

    table = new Table();
    table.add(nameLabel).expandX();
    table.add(nameText).width(200);
    table.row();
    table.add(addressLabel);
    table.add(addressText).width(200);
    table.setFillParent(true);
    stage.addActor(table);
    table.setDebug(true);
\$\endgroup\$
1
\$\begingroup\$

Okay, feeling silly now. It was due to the fact that I set such an odd aspect ratio when I initialised my Stage. I passed in half the width and height of the phone screen instead, and it comes up a lot neater.

\$\endgroup\$
3
  • \$\begingroup\$ Your viewport size ratio should match the one of the device screen :) \$\endgroup\$
    – Vaillancourt
    Nov 23 '16 at 13:15
  • \$\begingroup\$ I haven't been able to mark my own answer as accepted cause I don't have enough points to do so until after 2 days, but the problem has been solved \$\endgroup\$
    – Strawhare
    Nov 25 '16 at 12:38
  • \$\begingroup\$ All right :) Don't forget to come back and accept it! \$\endgroup\$
    – Vaillancourt
    Nov 25 '16 at 12:38
0
\$\begingroup\$

For later questions, to answer them directly - there are parameters in fonts that are responsible for line height and it's spacing in LibGDX.

You can find it in your .fnt file and BitmapFontData.

.fnt file:

enter image description here

BitmapFontData:

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Spacing seems to be totally ignored. I tried setting it to 2000 even and it didn't change at all. \$\endgroup\$
    – Hasen
    Jun 10 '20 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.