mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-11 19:51:55 +00:00
Fixed #1750 Application won't start when cannot access font file
This commit is contained in:
@@ -51,7 +51,6 @@ public class FontHelper {
|
||||
Class<?> clFmFactory = Class.forName("sun.font.FontManagerFactory");
|
||||
return clFmFactory.getDeclaredMethod("getInstance").invoke(null);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Gets all available fonts in the system
|
||||
*
|
||||
@@ -89,7 +88,7 @@ public class FontHelper {
|
||||
} catch (Throwable ex) {
|
||||
// ignore
|
||||
}
|
||||
*/
|
||||
*/
|
||||
if (fonts == null) {
|
||||
fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
|
||||
}
|
||||
@@ -312,23 +311,28 @@ public class FontHelper {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static List<File> getTtfFilesRecursively(File dir) {
|
||||
List<File> ret = new ArrayList<>();
|
||||
try {
|
||||
File files[] = dir.listFiles();
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
ret.addAll(getTtfFilesRecursively(f));
|
||||
} else if (f.getAbsolutePath().endsWith(".ttf") || f.getAbsolutePath().endsWith(".TTF")) {
|
||||
ret.add(f);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
//ignore any access errors
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static List<File> getSystemFontFiles() {
|
||||
List<File> dirs = getSystemFontDirectories();
|
||||
List<File> ret = new ArrayList<>();
|
||||
for (File d : dirs) {
|
||||
try {
|
||||
Object[] paths = Files.find(d.toPath(), Integer.MAX_VALUE, new BiPredicate<Path, BasicFileAttributes>() {
|
||||
@Override
|
||||
public boolean test(Path t, BasicFileAttributes u) {
|
||||
return u.isRegularFile() && (t.toString().endsWith(".ttf") || t.toString().endsWith(".TTF"));
|
||||
}
|
||||
}).toArray();
|
||||
for (Object o : paths) {
|
||||
ret.add(((Path) o).toFile());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
//ignore
|
||||
}
|
||||
ret.addAll(getTtfFilesRecursively(d));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user