NPE on runtime when installedFontsByFamily is null (#73)

* NPE on runtime when installedFontsByFamily is `null`

When running the command `java -jar dist/ffdec.jar -export fla <out> <file.swf>`, it crashes with stacktrace:
```
java.lang.NullPointerException                                                                                                                                                                                                                                           
        at com.jpexs.decompiler.flash.tags.base.FontTag.isFontFamilyInstalled(FontTag.java:310)                                                                                                                                                                          
        at com.jpexs.decompiler.flash.xfl.XFLConverter.convertFonts(XFLConverter.java:2366)                                                                                                                                                                              
        at com.jpexs.decompiler.flash.xfl.XFLConverter.convertSWF(XFLConverter.java:3363)
        at com.jpexs.decompiler.flash.SWF.exportXfl(SWF.java:2506)
        at com.jpexs.decompiler.flash.console.CommandLineArgumentParser.exportFla(CommandLineArgumentParser.java:2410)
        at com.jpexs.decompiler.flash.console.CommandLineArgumentParser.parseExport(CommandLineArgumentParser.java:2349)
        at com.jpexs.decompiler.flash.console.CommandLineArgumentParser.parseArguments(CommandLineArgumentParser.java:891)
        at com.jpexs.decompiler.flash.gui.Main.main(Main.java:1976)

```

Null checking `installedFontsByFamily` fixes the issue and the SWF to FLA is successful.

* Add ensureLoaded()  for isFontFamilyInstalled

With ensureLoaded() instead of null check
This commit is contained in:
florent.fauchille
2019-03-07 10:39:27 +01:00
committed by Jindra Petřík
parent 5733cd9051
commit 419fd9590e

View File

@@ -306,6 +306,7 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
}
public static String isFontFamilyInstalled(String fontFamily) {
ensureLoaded();
if (installedFontsByFamily.containsKey(fontFamily)) {
return fontFamily;
}