I fixed my problem. It was a very simple mistake. I forgot to load font.ttf into my font folder within my assets folder.
Cannot create font in andEngine
Pergunta
I am getting an error when trying to run this code:
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();
I am just creating a basic font for my application but for some reason I am running into an error message of the following:
05-12 15:34:04.048: E/AndroidRuntime(4540): java.lang.RuntimeException: native typeface cannot be made
05-12 15:34:04.048: E/AndroidRuntime(4540): at android.graphics.Typeface.<init>(Typeface.java:322)
05-12 15:34:04.048: E/AndroidRuntime(4540): at android.graphics.Typeface.createFromAsset(Typeface.java:296)
05-12 15:34:04.048: E/AndroidRuntime(4540): at org.andengine.opengl.font.FontFactory.createStrokeFromAsset(FontFactory.java:172)
Any help would be greatly appreciated.
Solução
Outras dicas
For future readers: another cause of this problem is what I had. The font file was called "font.TTF" not "font.ttf". Changing this fixed the error for me.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow