/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.text.Text; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.FontPosture; import java.util.List; import javafx.scene.control.ScrollPane; public class FontTest extends Application { public static void main(String[] args) { Application.launch(FontTest.class, args); } static final String multilingual = "English русский 简体中文 繁體中文 日本語 한국인 français Deutsch Português italiano svenska español"; @Override public void start(Stage stage) { Text[] texts = null; Text[] labels = null; int x = 20, y = 20; Group pane = new Group(); ScrollPane sp = new ScrollPane(); sp.setNode(pane); Scene scene = new Scene(sp, 1200, 600); stage.setScene(scene); List fontFamilies = Font.getFamilies(); int fontFamiliesSize = fontFamilies.size(); System.out.println("size = " + fontFamiliesSize); texts = new Text[fontFamiliesSize + 1]; labels = new Text[fontFamiliesSize + 1]; // Default font: Amble texts[0] = new Text(multilingual); texts[0].setFont(Font.font(Font.getDefault().getFamily(), FontPosture.ITALIC, 15 )); texts[0].setY(y); texts[0].setX(160 + x); labels[0] = new Text(Font.getDefault().getName() + "(Default)"); labels[0].setFont(new Font(15)); labels[0].setY(y); labels[0].setX(10 + x); // All available fonts for (int i = 1; i < fontFamiliesSize + 1; i++) { Font font = Font.font(fontFamilies.get(i - 1), FontPosture.ITALIC, 15); y += 20; texts[i] = new Text(multilingual); texts[i].setFont(font); texts[i].setY(y); texts[i].setX(160 + x); labels[i] = new Text(font.getFamily()); labels[i].setFont(new Font(15)); labels[i].setY(y); labels[i].setX(10 + x); } pane.getChildren().addAll(texts); pane.getChildren().addAll(labels); pane.getChildren().add(new Text(" ")); stage.setVisible(true); } }