I'm having problems with fonts using libgdx on android. They work fine when i first open the application. But when I pause the app then resume it, the fonts are rendered incorrectly.
Here's how I create the font.
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/MainFont.ttf"));
LabelStyle ls = new LabelStyle();
ls.font = generator.generateFont(30);
ls.fontColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
mPlay = new Label("Play", ls);
mInstructions = new Label("How To Play", ls);
generator.dispose();
I don't have anything in my Pause/Resume methods, not sure if there should be something there.
Here's what it looks before/after like.
This looks like a known issue of the LibGDX framework. If it's your case, this bug is solved in newer versions of the framework.
More info on the official issues tracker: https://github.com/libgdx/libgdx/issues/870
Hope it helps.
generator.dispose();
remove this line and put it in dispose method your font is getting dispossed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With