Changing font size in skin

南楼画角 提交于 2019-12-06 03:26:59

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);

Documentation says that any gets will return a handle to the actual object. So changes will persist.

So I changed the font in skin.json to point to my new font.

Then I used this code

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

To scale the 'default-font' (as defined in the skin.json) to the scale I wanted (in my case its 0.33f)

As of 2017 i had to use

skin.getFont("default-font").getData().setScale(0.5f);

for future users.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!