在 LibGDX 中更改 Textbutton 的文本大小

Change text size of Textbutton in LibGDX

我是 Libgdx 的新手,我已经搜索了 3 个小时以找到一种方法来更改文本按钮中的文本大小,但我找不到任何方法。我应该怎么做才能做到这一点。

    Table rootTable = new Table();
    rootTable.setFillParent(true);
    rootTable.setDebug(true, true);

    Table menuTable = new Table();
    rootTable.add(menuTable).expand().center().right();

    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

    TextButton singlePlayer = new TextButton("Single Player",skin);
    TextButton multiPlayer = new TextButton("Multi Player", skin);
    TextButton options = new TextButton("Options", skin);
    TextButton exit = new TextButton("Exit", skin);

    int x = Gdx.graphics.getHeight();
    int unit = x / 6;

    float scale = unit / singlePlayer.getHeight();

    float width = singlePlayer.getWidth() * scale;

    menuTable.add( singlePlayer ).size( width,unit).right().row();
    menuTable.add( multiPlayer ).size( width,unit).right().row();
    menuTable.add( options ).size( width,unit).right().row();
    menuTable.add( exit ).size( width,unit).right().row();

使用textButton.getLabel().setFontScale(x, y).

使用FreeTypeFontGenerator设置字体然后更新按钮:

private void UpdateButton(float xf, float width, float height) {
    if (xf > grayButton.getX() + grayButton.getWidth() / 2) {
        width += 20;
        height += 20;
    } else {
        width -= 20;
        height -= 20;
    }
    params.size = (int) ((int) width / 4.0);
    fontB = generator.generateFont(params);
    grayButtonStyle.font = fontB;
    grayButton.remove();
    grayButton = new TextButton("abcABC", grayButtonStyle);
    grayButton.setSize(width, height);
    grayButton.setPosition((screenWidth - width) / 2, (screenHeight - height) / 2);
    grayButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            UpdateButton(Gdx.input.getX(), grayButton.getWidth(), grayButton.getHeight());
        }
    });
    stage.addActor(grayButton);
}