22

I'm trying to change the color of the font I use in my application. But whatever I try the font remains black. I made this font using Hiero font tool.

My code is something like this:

SpriteBatch batch = new SpriteBatch();
BitmapFont font = new BtimapFont( Gdx.files.internal(MainAssets.pathToAssets + "font/comic.fnt"), Gdx.files.internal(MainAssets.pathToAssets +  "font/comic.png"), false );

In render where I draw the font:

batch.begin();
font.setColor(1, 0, 0, 1);
font.draw(batch, "Hello World!", 0, 0);
batch.end();

I found a similar issue to mine but there was still no solution.

http://code.google.com/p/libgdx/issues/detail?id=370

Morgoth
  • 4,935
  • 8
  • 40
  • 66
ruff1991
  • 803
  • 3
  • 9
  • 16

4 Answers4

22

You need to set output format with 32-bit depth and white colour with alpha (in case you are using BMFont tool, dont know about the Hiero ).

far
  • 2,697
  • 1
  • 17
  • 9
18

If your font is black then it won't be colour tinted (which is what you're doing when calling setColor). Try generating the font in Hiero again in white.

nmw
  • 6,664
  • 3
  • 31
  • 32
14

you can use this

font.setColor(Color.BLUE);

simplest way

bensiu
  • 24,660
  • 56
  • 77
  • 117
sandeep kundliya
  • 963
  • 8
  • 13
0

Had the same problem with latest libGDX and in my case it was about font image format. For details check this message:

font.setColor method not working after libGDX update to latest version

Community
  • 1
  • 1
MilanG
  • 6,994
  • 2
  • 35
  • 64