import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.control.Label; import javafx.scene.text.Font; import javafx.scene.layout.VBox; public class JavaFXFontTest extends Application { private void init(Stage primaryStage) { String fontName1 = "SimHei"; String fontName2 = "黑体"; int size = 22; String labelString = "\u7b80\u4f53\u4e2d\u6587"; Group root = new Group(); primaryStage.setScene(new Scene(root)); VBox vbox = new VBox(2); Label label1 = new Label(); Font font1 = new Font(fontName1, size); label1.setFont(font1); label1.setText(fontName1 + "--" + font1.getName() + "--" + labelString); Label label2 = new Label(); Font font2 = Font.font(fontName2, size); label2.setFont(font2); label2.setText(fontName2 + "--" + font2.getName() + "--" + labelString); vbox.getChildren().addAll(label1, label2); root.getChildren().add(vbox); } @Override public void start(Stage primaryStage) throws Exception { init(primaryStage); primaryStage.setTitle("JavaFXFontTest - " + System.getProperty("javafx.runtime.version")); primaryStage.show(); } public static void main(String[] args) { System.out.println("Default font=" + com.sun.javafx.font.PrismFontFactory.getSystemFont(com.sun.javafx.font.LogicalFont.SYSTEM)); launch(args); } }