Search code examples
javaandroidlibgdxskin

Changing font size in skin


I am writing a game using libgdx, and I borrowed the skin.json (and related files) from a tutorial.

The font being used (default) was scaling in an ugly manner on denser screens, so I generated by own very large font - and in the game itself, I scale it to a reasonable size (basically I use BitmapFont.scale). The font I'm now using is 3 times as large as the previous one.

I changed the reference to which font to use in the skin.json file, and as a result, all my buttons, titles and other things have a massive font being shown.

Is there a way of scaling the font in the .json file? Or anywhere else in the code? Skin doesn't have a setFont() functionality, so I can't create a scaled BitmapFont and assign it)


Solution

  • Libgdx changed this back in April 2015 so that the set answer doesn't work anymore. Took a little bit to find the answer, so I thought I'd leave it here for others since this answer pops up first in Google.

    this.getSkin().getFont("default-font").getData().setScale(0.33f,0.33f);