In case anyone is still having this problem. Using LibGDX 1.9.2, I had this problem as well:
Run the game, navigate 'back' to Android home screen, go back to the game and fonts would be black rectangles.
Turned out I was loading all textures in a static way, which only loads them once at game start and never again:
//THIS IS WRONG
public class Styles {
public static final BitmapFont HEADER_FONT;
public static final FreeTypeFontGenerator _freeTypeFontGenerator = ...
static {
FreeTypeFontGenerator.FreeTypeFontParameter params = ...
HEADER_FONT = freeTypeFontGenerator.generateFont(params);
}
}
This causes trouble when the game is reloaded in memory. As far as I understand, the final fields now refer to non-existent texture data. To fix that, I got rid of the final properties and load them in the create() function, recreating all assets each time the game is reloaded in memory:
public void onCreate() {
Styles.loadAssets();
}
And in Styles:
//STATIC RESOURCES CAN CAUSE TROUBLE, KEEP IT IN MIND
public class Styles {
public static BitmapFont HEADER_FONT;
public static FreeTypeFontGenerator FONT_GENERATOR = ...
public static void loadAssets() {
FreeTypeFontGenerator.FreeTypeFontParameter params = ...
HEADER_FONT = FONT_GENERATOR.generateFont(params);
}
}
I prefer my read-only assets to be static to be memory friendly. However, the use of static resources may still create problems I'm not aware of, as per the manual.