Seanoseanohay Seanoseanohay - 4 months ago 31
Java Question

Putting Freetypefont into libgdx skin

In my uiskin.json I have this { default-font: { file: text/default.fnt } }

This is fine for when I have the default.fnt in my text folder in the assets folder...

However I want to use a Freetypefont.

How do I create a Freetypefont and load it into the uiskin file?


It is not possible to do it beforehand, since you are going to generate it at runtime.

My workaround would be to keep the default font as it is and replace it at runtime via code. You can use Skin.add(...) for that.

BitmapFont newDefaultFont = FreeTypeFontGenerator...;
skin.add("default-font", newDefaultFont, BitmapFont.class);