Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8095952

[Linux] Font Awesome doesn't render properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 8u20
    • 8u20
    • javafx
    • Linux, JDK 8 update 20

      If you run the code below on JDK 8 it renders a left arrow and a right arrow as expected. If you run on JDK 8 update 20 then square boxes are rendered.

      I'm using Font Awesome but I expect it is the case with other fonts as well. When running the code you need the fontawesome-webfont.ttf in the root directory.

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.layout.FlowPane;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      public class FontAwesomeTest extends Application {
          @Override
          public void start(Stage stage) throws Exception {
              String fontLocation = getClass().getResource("/fontawesome-webfont.ttf").toExternalForm();
              Font.loadFont(fontLocation, 12);

              FlowPane pane = new FlowPane();
              Scene scene = new Scene(pane, 500, 500);
              stage.setScene(scene);

              Text leftArrow = new Text("\uf060");
              leftArrow.setStyle("-fx-font-family: FontAwesome; -fx-font-size: 40px;");
              Text rightArrow = new Text("\uf061");
              rightArrow.setStyle("-fx-font-family: FontAwesome; -fx-font-size: 40px;");

              pane.getChildren().addAll(leftArrow, rightArrow);

              stage.show();
          }

          public static void main(String[] args) {
              Application.launch(args);
          }
      }

            fheidric Felipe Heidrich (Inactive)
            ndarcy Nick D'Arcy
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: