mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-31 19:54:37 +00:00
show error dialog when the specified fontid is characterId of a non-FontTag
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user