diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 12208bb81..182cae3a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; +import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler; import com.jpexs.decompiler.flash.tags.base.RenderContext; @@ -500,6 +501,15 @@ public class DefineEditTextTag extends TextTag { case "font": try { fontId = Integer.parseInt(paramValue); + + CharacterTag characterTag = swf.getCharacter(fontId); + if (characterTag == null) { + throw new TextParseException("Font not found.", lexer.yyline()); + } + + if (!(characterTag instanceof FontTag)) { + throw new TextParseException("Character tag is not a Font tag. CharacterID: " + fontId, lexer.yyline()); + } } catch (NumberFormatException ne) { throw new TextParseException("Invalid font value. Number expected. Found: " + paramValue, lexer.yyline()); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 2ce71b04b..961f4c326 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; +import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler; import com.jpexs.decompiler.flash.tags.base.RenderContext; @@ -218,18 +219,17 @@ public class DefineText2Tag extends TextTag { try { fontId = Integer.parseInt(paramValue); - for (Tag t : swf.tags) { - if (t instanceof FontTag) { - if (((FontTag) t).getFontId() == fontId) { - font = (FontTag) t; - fontName = font.getSystemFontName(); - break; - } - } + CharacterTag characterTag = swf.getCharacter(fontId); + if (characterTag == null) { + throw new TextParseException("Font not found.", lexer.yyline()); } - if (font == null) { - throw new TextParseException("Font not found", lexer.yyline()); + + if (!(characterTag instanceof FontTag)) { + throw new TextParseException("Character tag is not a Font tag. CharacterID: " + fontId, lexer.yyline()); } + + font = (FontTag) characterTag; + fontName = font.getSystemFontName(); } catch (NumberFormatException nfe) { throw new TextParseException("Invalid font id - number expected. Found: " + paramValue, lexer.yyline()); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 1ae34e528..3efb9b68b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; +import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler; import com.jpexs.decompiler.flash.tags.base.RenderContext; @@ -224,18 +225,17 @@ public class DefineTextTag extends TextTag { try { fontId = Integer.parseInt(paramValue); - for (Tag t : swf.tags) { - if (t instanceof FontTag) { - if (((FontTag) t).getFontId() == fontId) { - font = (FontTag) t; - fontName = font.getSystemFontName(); - break; - } - } + CharacterTag characterTag = swf.getCharacter(fontId); + if (characterTag == null) { + throw new TextParseException("Font not found.", lexer.yyline()); } - if (font == null) { - throw new TextParseException("Font not found", lexer.yyline()); + + if (!(characterTag instanceof FontTag)) { + throw new TextParseException("Character tag is not a Font tag. CharacterID: " + fontId, lexer.yyline()); } + + font = (FontTag) characterTag; + fontName = font.getSystemFontName(); } catch (NumberFormatException nfe) { throw new TextParseException("Invalid font id - number expected. Found: " + paramValue, lexer.yyline()); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 7a69d077d..da87972a2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -296,7 +296,10 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { } } if (rec.styleFlagsHasFont) { - font = (FontTag) swf.getCharacter(rec.fontId); + CharacterTag character = swf.getCharacter(rec.fontId); + if (character instanceof FontTag) { + font = (FontTag) character; + } glyphs = font == null ? null : font.getGlyphShapeTable(); textHeight = rec.textHeight; }