Closed CrisN4N closed 3 years ago
Hello. You must use a custom serializer to use Freetype in skin JSON's. Please see the wiki page: https://github.com/raeleus/skin-composer/wiki/Creating-FreeType-Fonts#using-a-custom-serializer There is also information in the app when you create the freetype font. Thanks.
@raeleus Thanks
I created simple skin with TTF font.
After export i got: Skin:
I used this code to load textures and skin:
In result, i have error:
com.badlogic.gdx.utils.SerializationException: Error reading file: Skin.json at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:104) at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:89) at com.secret.Secret.create(Secret.java:73) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:151) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:128) Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: Skin.json at com.badlogic.gdx.utils.Json.fromJson(Json.java:758) at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:102) ... 4 more Caused by: com.badlogic.gdx.utils.SerializationException: Class cannot be created (missing no-arg constructor): com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator at com.badlogic.gdx.utils.Json.newInstance(Json.java:1158) at com.badlogic.gdx.utils.Json.readValue(Json.java:970) at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:436) at com.badlogic.gdx.utils.Json.readValue(Json.java:928) at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.readNamedObjects(Skin.java:485) at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:474) at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:468) at com.badlogic.gdx.utils.Json.readValue(Json.java:962) at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:436) at com.badlogic.gdx.utils.Json.fromJson(Json.java:756) ... 5 more Caused by: com.badlogic.gdx.utils.reflect.ReflectionException: Could not instantiate instance of class: com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator at com.badlogic.gdx.utils.reflect.ClassReflection.newInstance(ClassReflection.java:95) at com.badlogic.gdx.utils.Json.newInstance(Json.java:1140) ... 14 more Caused by: java.lang.InstantiationException: com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator at java.lang.Class.newInstance(Class.java:427) at com.badlogic.gdx.utils.reflect.ClassReflection.newInstance(ClassReflection.java:93) ... 15 more Caused by: java.lang.NoSuchMethodException: com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.<init>() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.newInstance(Class.java:412) ... 16 more
I can see, that Class cannot be created (missing no-arg constructor): com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator, so... how i can use it?