我有一个包含font:
的方法private void loadMenuFonts()
{
FontFactory.setAssetBasePath("font/");
final ITexture mainFontTexture = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
font = FontFactory.createStrokeFromAsset(activity.getFontManager(), mainFontTexture, activity.getAssets(), "font.ttf", 50, true, Color.WHITE, 2, Color.BLACK);
font.load();
}
我收到一封来自LogCat的错误:
02-16 21:59:37.288: E/AndroidRuntime(1984): FATAL EXCEPTION: UpdateThread 02-16 21:59:37.288: E/AndroidRuntime(1984): java.lang.RuntimeException: native typeface cannot be made 02-16 21:59:37.288: E/AndroidRuntime(1984): at android.graphics.Typeface.(Typeface.java:175) 02-16 21:59:37.288: E/AndroidRuntime(1984): at android.graphics.Typeface.createFromAsset(Typeface.java:149) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.opengl.font.FontFactory.createStrokeFromAsset(FontFactory.java:172) 02-16 21:59:37.288: E/AndroidRuntime(1984): at com.shark.ResourcesManager.loadMenuFonts(ResourcesManager.java:98) 02-16 21:59:37.288: E/AndroidRuntime(1984): at com.shark.ResourcesManager.loadMenuResources(ResourcesManager.java:59) 02-16 21:59:37.288: E/AndroidRuntime(1984): at com.shark.base.SceneManager.createMenuScene(SceneManager.java:76) 02-16 21:59:37.288: E/AndroidRuntime(1984): at com.shark.GameActivity$1.onTimePassed(GameActivity.java:87) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.engine.handler.timer.TimerHandler.onUpdate(TimerHandler.java:98) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.engine.handler.UpdateHandlerList.onUpdate(UpdateHandlerList.java:47) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.engine.Engine.onUpdateUpdateHandlers(Engine.java:597) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.engine.Engine.onUpdate(Engine.java:585) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.engine.LimitedFPSEngine.onUpdate(LimitedFPSEngine.java:56) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.engine.Engine.onTickUpdate(Engine.java:548) 02-16 21:59:37.288: E/AndroidRuntime(1984): at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
发生的错误是createStrokeFromAsset
。
有任何解决此问题的建议吗?
答案 0 :(得分:0)
检查是否
1-目录字体直接存在于目录资产中
2-一种truetype字体存在于目录字体中,名称为font.ttf
如果上面的文件和目录存在,则替换为其他rtf字体。
答案 1 :(得分:0)
我遇到了同样的错误,结果发现字体文件名为" font.TTF"不是" font.ttf"。在createStrokeFromAsset()
方法中更改此项对我有用。看起来你可能有类似的问题。