Programming in Java with LibGDX. I am creating a BitmapFont from the FreeType library.
I want to reference the generated font "public static BitmapFont fooFont" in a .json file:
{
"com.baglogic.gdx.graphics.g2d.BitmapFont": {
"font": {???},
},
"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
"default": {"up": "buttonUp", "down": "buttonDown", "font": font},
},
"com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": {
"default": {"font": font}
}
}
How would I reference fooFont from my class Assets at the ??? variable?
Edit:
After reading over some other posts
Here is some more of my code, along with changes---
from Assets.java:
public static void createSkins() {
if(menuSkin == null) {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/fooFont.TTF"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.color = Color.RED;
fontOCRA_red = generator.generateFont(parameter);
generator.dispose();
menuSkin = new Skin();
menuSkin.addRegions(menuAtlas);
menuSkin.add("fooFont", fooFont);
menuSkin.load(Gdx.files.internal("data/styles.json"));
}
if(gameSkin == null) {
gameSkin = new Skin(Gdx.files.internal("data/styles.json"), gameAtlas);
}
}
from styles.json:
{
"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
"default": {
"up": "buttonBG", "down": "buttonBG_flipped", "checked": "buttonBG", "font": fooFont
},
},
"com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": {
"default": {
"font": fooFont
}
}
}
The error I am currently getting states:
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: buttonBG
but I am fairly certain that is what was done in the menuSkin.addRegions and add lines from Assets.java, and the textureatlas does show the "buttonBG" item in the correct .pack file. Moving the order around shows that it does not have any of the textureregions or the bitmapfont registered. Is there another reason why it might not register the items?