public static TreeMap<String, String> enumerateFonts() { String[] fontdirs = {fontsFolder}; TreeMap<String, String> fonts = new TreeMap<>(); TTFAnalyzer analyzer = new TTFAnalyzer(); for (String fontdir : fontdirs) { File dir = new File(fontdir); if (!dir.exists()) continue; File[] files = dir.listFiles(); if (files == null) continue; for (File fileAndPath : files) { String fontname = analyzer.getTtfFontName(fileAndPath.getAbsolutePath()); if (fontname != null && !fontname.isEmpty()) fonts.put(fileAndPath.getAbsolutePath(), fontname); } } return fonts.isEmpty() ? null : fonts; }