1
votes

Sorry for that stupid question but I'm a quiet noob. I can't figure out how to draw Bitmap Font in Libgdx. Well, I've used HIERO v2.0 tool to make BitmapFont file. Then I initialize it in code:

BitmapFont font = new BitmapFont(Gdx.files.internal("data/fonts/Georgia.fnt"), Gdx.files.internal("data/fonts/Georgia.png"), false);

But when I try to draw it on screen:

game.batch.begin();    
font.draw(game.batch, "Text string", game.screenWidth * 0.5f, game.screenHeight * 0.5f);
game.batch.end();

I get this result: http://imageshack.us/photo/my-images/696/bitmapfont.png/ Does anybody know, what I'm doing wrong?

1
No, I'm not. Just a web tutorials - Thash
It's possible, I'm reading this: rengelbert.com/tutorial.php?id=175&show_all=true and the Libgdx wiki where is a similar example (for screens). I also try to get font through TrueTypeFontFactory but it is not stable and I get exception: Couldn't load shared library: 'gdx-stb-truetype' for target Windows 7, 64-bit - Thash

1 Answers

4
votes

This tends to happen when the Georgia.fnt and Georgia.png are out of sync. That is, they are from different exports.

Double check that you saved both in HIERO