I'm using FreeTypeFontGenerator to load my fonts. Currently I have 6 different BitmapFonts and I load them in the constructor of my Screen class and draw them in the render function. Here's a code snippet, myFont is a class I've written which internally uses FreeTypeFontGenerator and the loadFont function returns a BitmapFont object.
public Screen1 () {
.....
.....
myFont = new MyFont();
circleFonts = new BitmapFont[4];
for (int i=0; i<4; i++) {
circleFonts[i] = myFont.loadFont("fonts/roboto/Roboto-Light.ttf", 20);
}
textOrColorFont = myFont.loadFont("fonts/roboto/Roboto-Light.ttf",15);
currentColorFont = myFont.loadFont("fonts/roboto/Roboto-Light.ttf", 15);
}
The problem is since I have to load these fonts every time I move to Screen1, the game gets stuck for a good 2-3 seconds because it has to load the fonts from the file. Is there a better way to do this?
Thanks.