allow adding new tags (todo: add constructor for all supported tagtypes)

This commit is contained in:
honfika@gmail.com
2014-11-05 00:12:57 +01:00
parent 49765d71b7
commit e7b2fbdfa2
9 changed files with 196 additions and 102 deletions

View File

@@ -191,7 +191,7 @@ public class DefineFont2Tag extends FontTag {
return baos.toByteArray();
}
public DefineFont2Tag(SWF swf) throws IOException {
public DefineFont2Tag(SWF swf) {
super(swf, ID, "DefineFont2", null);
}

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.FontTag;
@@ -135,6 +136,14 @@ public class DefineFontTag extends FontTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineFontTag(SWF swf) {
super(swf, ID, "DefineFont", null);
}
/**
* Constructor
*

View File

@@ -355,49 +355,44 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
@Override
public FontTag toClassicFont() {
try {
DefineFont2Tag ret = new DefineFont2Tag(swf);
ret.fontId = getFontId();
ret.fontFlagsBold = isBold();
ret.fontFlagsItalic = isItalic();
ret.fontFlagsWideOffsets = true;
ret.fontFlagsWideCodes = true;
ret.fontFlagsHasLayout = true;
ret.fontAscent = (getAscent());
ret.fontDescent = (getDescent());
ret.fontLeading = (getLeading());
ret.fontAdvanceTable = new ArrayList<>();
ret.fontBoundsTable = new ArrayList<>();
ret.codeTable = new ArrayList<>();
ret.glyphShapeTable = new ArrayList<>();
List<SHAPE> shp = getGlyphShapeTable();
ret.numGlyphs = shp.size();
for (int g = 0; g < shp.size(); g++) {
ret.fontAdvanceTable.add(resize(getGlyphAdvance(g)));
ret.codeTable.add((int) glyphToChar(g));
DefineFont2Tag ret = new DefineFont2Tag(swf);
ret.fontId = getFontId();
ret.fontFlagsBold = isBold();
ret.fontFlagsItalic = isItalic();
ret.fontFlagsWideOffsets = true;
ret.fontFlagsWideCodes = true;
ret.fontFlagsHasLayout = true;
ret.fontAscent = (getAscent());
ret.fontDescent = (getDescent());
ret.fontLeading = (getLeading());
ret.fontAdvanceTable = new ArrayList<>();
ret.fontBoundsTable = new ArrayList<>();
ret.codeTable = new ArrayList<>();
ret.glyphShapeTable = new ArrayList<>();
List<SHAPE> shp = getGlyphShapeTable();
ret.numGlyphs = shp.size();
for (int g = 0; g < shp.size(); g++) {
ret.fontAdvanceTable.add(resize(getGlyphAdvance(g)));
ret.codeTable.add((int) glyphToChar(g));
SHAPE shpX = resizeShape(shp.get(g));
ret.glyphShapeTable.add(shpX);
ret.fontBoundsTable.add(getGlyphBounds(g));
}
ret.fontName = getFontNameIntag();
ret.languageCode = new LANGCODE(1);
ret.fontKerningTable = new ArrayList<>();
FontType ft = fonts.get(0);
for (int i = 0; i < ft.kerning.size(); i++) {
KERNINGRECORD kr = new KERNINGRECORD();
kr.fontKerningAdjustment = resize(ft.kerning.get(i).advance);
kr.fontKerningCode1 = ft.kerning.get(i).char1;
kr.fontKerningCode2 = ft.kerning.get(i).char2;
ret.fontKerningTable.add(kr);
}
return ret;
} catch (IOException ex) {
Logger.getLogger(DefineCompactedFont.class.getName()).log(Level.SEVERE, null, ex);
SHAPE shpX = resizeShape(shp.get(g));
ret.glyphShapeTable.add(shpX);
ret.fontBoundsTable.add(getGlyphBounds(g));
}
return null;
ret.fontName = getFontNameIntag();
ret.languageCode = new LANGCODE(1);
ret.fontKerningTable = new ArrayList<>();
FontType ft = fonts.get(0);
for (int i = 0; i < ft.kerning.size(); i++) {
KERNINGRECORD kr = new KERNINGRECORD();
kr.fontKerningAdjustment = resize(ft.kerning.get(i).advance);
kr.fontKerningCode1 = ft.kerning.get(i).char1;
kr.fontKerningCode2 = ft.kerning.get(i).char2;
ret.fontKerningTable.add(kr);
}
return ret;
}
@Override

View File

@@ -33,6 +33,7 @@ public class SWFList implements List<SWF>, SWFContainerItem {
public String name;
public boolean isBundle;
public Class bundleClass;
public SWFSourceInfo sourceInfo;
public List<SWF> swfs = new ArrayList<>();