Fixed #2104 Empty texts import

This commit is contained in:
Jindra Petřík
2023-10-21 19:11:18 +02:00
parent 0c2a522c5d
commit f3341c5490
2 changed files with 10 additions and 3 deletions

View File

@@ -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

View File

@@ -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<GLYPHENTRY> glyphEntries = textRecord.glyphEntries;
if (glyphEntries.isEmpty()) {
return 0;
}
for (int i = 0; i < glyphEntries.size(); i++) {
GLYPHENTRY glyph = glyphEntries.get(i);
GLYPHENTRY nextGlyph = null;