package de.gurkenlabs.litiengine.gui;

import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

import de.gurkenlabs.litiengine.util.io.FileUtilities;

/**
 * The Class FontLoader loads custom fonts to the java environment.
 */
public class FontLoader {
  /** The Constant fonts. */
  private static final HashMap<String, Font> fonts = new HashMap<>();
  private static final Logger log = Logger.getLogger(FontLoader.class.getName());

  private FontLoader() {
  }

  /**
   * Gets the font.
   *
   * @param fontName
   *          the font name
   * @return the font
   */
  public static Font load(final String fontName) {
    if (fonts.containsKey(fontName)) {
      return fonts.get(fontName);
    }

    final String[] f = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    for (final String font : f) {
      final String name = FileUtilities.getFileName(fontName);
      if (font.equals(name)) {
        return new Font(name, Font.PLAIN, 8);
      }
    }
    try {
      final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

      final InputStream fontStream = FileUtilities.getGameResource(fontName);
      if (fontStream == null) {
        log.log(Level.SEVERE, "font {0} could not be loaded", fontName);
      }

      final Font font = Font.createFont(Font.TRUETYPE_FONT, fontStream);
      ge.registerFont(font);
      fonts.put(fontName, font);
      return font;
    } catch (final FontFormatException | IOException e) {
      log.log(Level.SEVERE, e.getMessage(), e);
    }
    return null;
  }
}

@@ -686,21 +686,73 @@
   * 
-Gets the font
+Loads a custom font with the specified name from game's resources
 .%0D%0A 
@@ -792,24 +792,36 @@
         
+The name of 
 the font
  name%0D%0A 
@@ -812,21 +812,16 @@
 the font
- name
 %0D%0A   * @
@@ -827,24 +827,32 @@
 @return 
-t
+T
 he 
+loaded 
 font
+.
 %0D%0A   */%0D
@@ -992,307 +992,8 @@
 %0D%0A%0D%0A
-    final String%5B%5D f = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();%0D%0A    for (final String font : f) %7B%0D%0A      final String name = FileUtilities.getFileName(fontName);%0D%0A      if (font.equals(name)) %7B%0D%0A        return new Font(name, Font.PLAIN, 8);%0D%0A      %7D%0D%0A    %7D%0D%0A
     
@@ -1272,24 +1272,46 @@
 fontName);%0D%0A
+        return null;%0D%0A
       %7D%0D%0A%0D%0A 
@@ -1582,16 +1582,18 @@
 %0A    %7D%0D%0A
+%0D%0A
     retu

Remove the loading of system fonts by the FontLoader