Update
Thanks to a comment from Jos van Egmond telling how to do this and still downloading Skin from AssetManager , I decided to update the answer, the Old answer (and an alternative way to do it) is still untouched below.
The new procedure will look like this:
- Download font files.
- Create an
ObjectMap<String, Object> and place your fonts on this map. - Create a
SkinParameter and give it an ObjectMap as a parameter. - Download
Skin through the AsserManager , as usual, using the created SkinParameter .
The code might look something like this:
load font1... load font2... ObjectMap<String, Object> fontMap = new ObjectMap<String, Object>(); fontMap.put("font1", font1); fontMap.put("font2", font2); SkinParameter parameter = new SkinParameter(fontMap); assetManager.load("file/location/of/your/skin", Skin.class, parameter);
Old
The current accepted answer is actually (view) incorrect. This blog post describes how to link to the generated BitmapFont in your Json file. The procedure looks something like this:
- Create an empty file using the default constructor.
- Add your fonts to your skin.
- Add your atlas to your skin.
- Upload your Json file to your skin.
The code might look something like this:
// Create a new skin using the default constructor and // add your fonts to it. Skin skin = new Skin(); skin.add("myFont", myFont, BitmapFont.class); // Remember that this texture atlas is NOT automatically disposed by the skin, // so keep a reference and dispose of it yourself. skin.addRegion(new TextureAtlas("file/location/of/your/atlas"); skin.load(Gdx.files.internal("file/location/of/your/skin"));
Now you can do something similar in your Json skin:
..., font: "myFont", ...
Although this is a workaround, it also means that you cannot (at least I did not find a way) load your skin through AssetManager . You can still download TextureAtlas through the manager.
Charanor
source share