Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create a custom font in AndEngine?

How in the world do you create a custom front? Almost straight from the example:

BitmapTextureAtlas font_texture = new BitmapTextureAtlas(this.getTextureManager(), 256, 256, TextureOptions.BILINEAR); 
    mFont = FontFactory.createFromAsset(font_texture, this, "comic.ttf", 18f, true, Color.WHITE);

Yet I get this error:

The method createFromAsset(FontManager, ITexture, AssetManager, String, float, boolean, int) in the type FontFactory is not applicable for the arguments (BitmapTextureAtlas, TestGFX5Activity, String, float, boolean, Color)

I've tried many different combinations and can't get anything to work. I want the font "comic.ttf", size 18, and white. How do I do this and not get that error?

like image 554
rphello101 Avatar asked Jan 16 '23 05:01

rphello101


1 Answers

Finally found the answer:

final ITexture fontTexture = new BitmapTextureAtlas(this.getTextureManager(),256,256);

mFont = FontFactory.createFromAsset(this.getFontManager(),fontTexture,this.getAssets(),"COMIC.TTF",18f,true,Color.WHITE);

But you must import android.graphics.Color not org.andengine.util.color.Color!!!

like image 134
rphello101 Avatar answered Jan 28 '23 15:01

rphello101