show error dialog when the specified fontid is characterId of a non-FontTag

This commit is contained in:
honfika@gmail.com
2015-02-03 20:56:47 +01:00
parent 1178faf400
commit cafacd030e
4 changed files with 34 additions and 21 deletions

View File

@@ -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());
}

View File

@@ -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());
}

View File

@@ -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());
}

View File

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