/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package Test;
/**
*
* @author Administrator
*/
import com.atr.jme.font.TrueTypeFont;
import com.atr.jme.font.TrueTypeMesh;
import com.atr.jme.font.asset.TrueTypeKeyMesh;
import com.atr.jme.font.asset.TrueTypeLoader;
import com.atr.jme.font.shape.TrueTypeContainer;
import com.atr.jme.font.util.StringContainer;
import com.atr.jme.font.util.Style;
import com.jme3.app.SimpleApplication;
import com.jme3.math.ColorRGBA;
/**
* 测试TTF字体
*
* @author icyboxs
*
*/
public class HelloTTF extends SimpleApplication {
public static void main(String[] args) {
// 启动程序
HelloTTF app = new HelloTTF();
app.start();
}
@Override
public void simpleInitApp() {
assetManager.registerLoader(TrueTypeLoader.class, "ttf");
TrueTypeKeyMesh ttk = new TrueTypeKeyMesh("Interface/heiti.ttf",
Style.Plain, 16);
TrueTypeFont ttf = (TrueTypeMesh)assetManager.loadAsset(ttk);
TrueTypeContainer ttc = ttf.getFormattedText(new StringContainer(ttf, "Hello\nWorld"), ColorRGBA.Blue);
rootNode.attachChild(ttc);
}
}
java.lang.NoClassDefFoundError: com/google/typography/font/sfntly/FontFactory
at com.atr.jme.font.asset.TrueTypeLoaderMesh.load(TrueTypeLoaderMesh.java:38)
at com.atr.jme.font.asset.TrueTypeLoader.load(TrueTypeLoader.java:41)
at com.atr.jme.font.asset.TrueTypeLoader.load(TrueTypeLoader.java:35)
at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
at Test.HelloTTF.simpleInitApp(HelloTTF.java:46)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:139)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: com.google.typography.font.sfntly.FontFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 10 more