Adds handling for the HeadlessException encountered when running FontLoader tests on Travis CI.
@@ -173,6 +173,7 @@ public class FontLoader {
final BufferedImage loadedImage = ImageIO.read(inputStream);
inputStream.close();
+ try {
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice gd = ge.getDefaultScreenDevice();
final GraphicsConfiguration gc = gd.getDefaultConfiguration();
@@ -183,6 +184,11 @@ public class FontLoader {
g2d.drawImage(loadedImage, 0, 0, null);
g2d.dispose();
return converedImage;
+ } catch(final HeadlessException e) {
+ // Occurs when running FontLoader unit tests on Travis CI.
+ // Probably because there's no screen/graphics device.
+ return loadedImage;
+ }
}
/**
