-
Bug
-
Resolution: Duplicate
-
P3
-
8u20
-
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);
}
}
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);
}
}
- duplicates
-
JDK-8097072 [Font] New native font rasterizer in Linux fails to load non system true type fonts
- Resolved