title: Display FontAwesome icons with JavaFX
body: <p>I'm trying to create a class that could load <code>FontAwesome</code> icons but it doesn't achieve to read the <code>fontawesome-webfont.ttf</code> file.</p>
  
  <p><strong>Class to create an icon:</strong></p>
  
  <pre><code>import javafx.scene.control.Label;
  import javafx.scene.text.Font;
  
  public class AppFont {
      static {
          Font.loadFont(AppFont.class.getResource("/res/fontawesome-webfont.ttf").toExternalForm(), 10);
      }
  
      public static Label createIcon(Icon icon, int iconSize) {
          Label label = new Label(icon.toString());
          label.setStyle("-fx-font-family: FontAwesome; -fx-font-size: " + iconSize + ";");
          return label;
      }
  }
  </code></pre>
  
  <p><strong>Icon enum:</strong></p>
  
  <pre><code>public enum Icon {
  
      TEST('\uf099');
  
      private Character c;
  
      private Icon(Character c) {
          this.c = c;
      }
  
      public Character getCharacter() {
          return c;
      }
  
      @Override
      public String toString() {
          return c.toString();
      }
  }
  </code></pre>
  
  <p><strong>Usage:</strong></p>
  
  <pre><code>Label l = AppFont.createIcon(Icon.TEST, 40);
  this.getChildren().add(l);
  </code></pre>
  
  <p>What I get</p>
  
  <p><a href="https://i.stack.imgur.com/c2sCU.png" rel="nofollow noreferrer">Only the black rectangle</a></p>
  
  <p>and of course <code>.ttf</code> file is in the right location. It doesn't throw any error.</p>
  
  <p>Thanks for your help!</p>