// Use a region with the same name as the font, else use a PNG file in the same directory as the FNT file.
String regionName = fontFile.nameWithoutExtension();
try {
if (skin.hasResource(regionName, TextureRegion.class))
return new BitmapFont(fontFile, skin.getResource(regionName, TextureRegion.class), false);
else {
FileHandle imageFile = fontFile.parent().child(regionName + ".png");
if (imageFile.exists())
return new BitmapFont(fontFile, imageFile, false);
else
return new BitmapFont(fontFile, false);
}
} catch (RuntimeException ex) {
throw new SerializationException("Error loading bitmap font: " + fontFile, ex);
}
}