package javatest; import java.util.List; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.text.*; import javafx.stage.Stage; public class getFamilies extends Application { public static void main(String[] args) { getFamilies.launch(args); } @Override public void start(Stage stage) throws Exception { Scene scn = new Scene(new Group(), 300, 300); stage.setScene(scn); String error = ""; boolean result = true; Font myFont = Font.getDefault(); List fontFamilies = Font.getFamilies();//Fixed this List fontNames = Font.getFontNames();//Fixed this int fontFamiliesSize = fontFamilies.size(); if (fontFamiliesSize == 0 || fontFamilies == null) { error = error + "Quantity of font\'s families: " + fontFamiliesSize + ".\n"; result = false; } else { System.out.println("Num of families: " + fontFamiliesSize); for (String family : fontFamilies) { System.out.println("*** checking family: " + family + " ***"); List fontFamilyNames = Font.getFontNames(family); int fontFamilyNamesSize = fontFamilyNames.size(); if (fontFamilyNamesSize == 0 || fontFamilyNames == null) { error = error + "Quantity of fonts in " + family + ": " + fontFamiliesSize + ".\n"; } else //result = false; { for (String fontFamily : fontFamilyNames) { System.out.print("-- checking font: " + fontFamily); boolean flag = false; for (String fontName : fontNames) { if (fontFamily.equals(fontName)) { flag = true; } } System.out.println(": " + flag); if (!flag) { error = error + "Cannot find " + fontFamily + " in the list of fonts given by getFontNames function.\n"; result = false; } } } System.out.println("*** finished checking of the family " + family + "***"); } } for (String name : fontNames) { System.out.println(name); } if (result) { System.out.println("Passed"); } else { System.out.println("Error " + error); } } }