diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb9f0d56..3dfa6d2fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. - [#2013] AS3 Multiname renaming - closing the script when renaming the class, nullpointer exception - GFX - FontTextureInfo tag reading - GFX - Fonts with stripped shapes +- [#2104] Empty texts import ### Changed - Basic tag info panel always visible even when nothing to display (to avoid flickering) @@ -3209,6 +3210,7 @@ Major version of SWF to XML export changed to 2. [#1306]: https://www.free-decompiler.com/flash/issues/1306 [#1768]: https://www.free-decompiler.com/flash/issues/1768 [#2013]: https://www.free-decompiler.com/flash/issues/2013 +[#2104]: https://www.free-decompiler.com/flash/issues/2104 [#2099]: https://www.free-decompiler.com/flash/issues/2099 [#2090]: https://www.free-decompiler.com/flash/issues/2090 [#2079]: https://www.free-decompiler.com/flash/issues/2079 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/StaticTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/StaticTextTag.java index 36b5788fb..e3f8a97c7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/StaticTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/StaticTextTag.java @@ -472,11 +472,11 @@ public abstract class StaticTextTag extends TextTag { throw new TextParseException("Font not defined", lexer.yyline()); } - while (txt.charAt(0) == '\r' || txt.charAt(0) == '\n') { + while (!txt.isEmpty() && (txt.charAt(0) == '\r' || txt.charAt(0) == '\n')) { txt = txt.substring(1); } - while (txt.charAt(txt.length() - 1) == '\r' || txt.charAt(txt.length() - 1) == '\n') { + while (!txt.isEmpty() && (txt.charAt(txt.length() - 1) == '\r' || txt.charAt(txt.length() - 1) == '\n')) { txt = txt.substring(0, txt.length() - 1); } @@ -586,9 +586,14 @@ public abstract class StaticTextTag extends TextTag { return advance; } - public static int detectLetterSpacing(TEXTRECORD textRecord, FontTag font, int textHeight) { + public static int detectLetterSpacing(TEXTRECORD textRecord, FontTag font, int textHeight) { int totalLetterSpacing = 0; List glyphEntries = textRecord.glyphEntries; + + if (glyphEntries.isEmpty()) { + return 0; + } + for (int i = 0; i < glyphEntries.size(); i++) { GLYPHENTRY glyph = glyphEntries.get(i); GLYPHENTRY nextGlyph = null;