diff --git a/lib/JavactiveX.jar b/lib/JavactiveX.jar index d3143e889..e80251090 100644 Binary files a/lib/JavactiveX.jar and b/lib/JavactiveX.jar differ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index 49675c624..e5a52fa81 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -55,7 +55,7 @@ import java.util.Set; */ public abstract class FontTag extends CharacterTag implements AloneTag, DrawableTag { - protected final int previewSize = 500; + public static final int PREVIEWSIZE = 500; public FontTag(SWF swf, int id, String name, ByteArrayRange data) { super(swf, id, name, data); @@ -316,7 +316,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable @Override public RECT getRect(Set added) { - return new RECT(0, (int) (previewSize * SWF.unitDivisor), 0, (int) (previewSize * SWF.unitDivisor)); + return new RECT(0, (int) (PREVIEWSIZE * SWF.unitDivisor), 0, (int) (PREVIEWSIZE * SWF.unitDivisor)); } @Override diff --git a/nbproject/project.xml b/nbproject/project.xml index 4ab983a72..73200092d 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -203,7 +203,7 @@ src - lib/LZMA.jar;lib/jna-3.5.1.jar;lib/jpproxy.jar;lib/trident-6.2.jar;lib/substance-flamingo-6.2.jar;lib/flamingo-6.2.jar;lib/substance-6.2.jar;lib/jl1.0.1.jar;lib/nellymoser.jar;lib/gif.jar;lib/avi.jar;lib/ttf.jar;lib/jpacker.jar;lib/sfntly.jar;lib/gnujpdf.jar;libsrc/ffdec_lib/src;lib/JavactiveX.jar;lib/tablelayout.jar;lib/jsyntaxpane-0.9.5.jar + lib/LZMA.jar;lib/jna-3.5.1.jar;lib/jpproxy.jar;lib/trident-6.2.jar;lib/substance-flamingo-6.2.jar;lib/flamingo-6.2.jar;lib/substance-6.2.jar;lib/jl1.0.1.jar;lib/nellymoser.jar;lib/gif.jar;lib/avi.jar;lib/ttf.jar;lib/jpacker.jar;lib/sfntly.jar;lib/gnujpdf.jar;libsrc/ffdec_lib/src;lib/tablelayout.jar;lib/jsyntaxpane-0.9.5.jar;lib/JavactiveX.jar build javadoc reports diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index b5797114c..30d23cc6b 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -61,6 +61,7 @@ import com.jpexs.decompiler.flash.types.GLYPHENTRY; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGB; +import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.decompiler.flash.types.TEXTRECORD; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.helpers.Helper; @@ -521,6 +522,12 @@ public class PreviewPanel extends JSplitPane implements ActionListener { SWFOutputStream sos2 = new SWFOutputStream(baos, SWF.DEFAULT_VERSION); int width = swf.displayRect.Xmax - swf.displayRect.Xmin; int height = swf.displayRect.Ymax - swf.displayRect.Ymin; + + if (tagObj instanceof FontTag) { + width = FontTag.PREVIEWSIZE*20; + height = FontTag.PREVIEWSIZE*20; + } + sos2.writeRECT(swf.displayRect); sos2.writeUI8(0); sos2.writeUI8(frameRate); @@ -648,9 +655,26 @@ public class PreviewPanel extends JSplitPane implements ActionListener { int cols = (int) Math.ceil(Math.sqrt(countGlyphs)); int rows = (int) Math.ceil(((float) countGlyphs) / ((float) cols)); int x = 0; - int y = 1; + int y = 0; int firstGlyphIndex = fontPageNum * SHAPERECORD.MAX_CHARACTERS_IN_FONT_PREVIEW; countGlyphs = Math.min(SHAPERECORD.MAX_CHARACTERS_IN_FONT_PREVIEW, countGlyphsTotal - firstGlyphIndex); + List shapes=((FontTag) tagObj).getGlyphShapeTable(); + int maxw = 0; + for (int f = firstGlyphIndex; f < firstGlyphIndex + countGlyphs; f++) { + RECT b = shapes.get(f).getBounds(); + int w=(int)(b.getWidth()/((FontTag) tagObj).getDivider()); + if(w>maxw){ + maxw = w; + } + } + + int BORDER = 5*20; + + int textHeight = height / rows; + while(maxw*textHeight/1024 > width/cols-2*BORDER){ + textHeight--; + } + for (int f = firstGlyphIndex; f < firstGlyphIndex + countGlyphs; f++) { if (x >= cols) { x = 0; @@ -658,20 +682,41 @@ public class PreviewPanel extends JSplitPane implements ActionListener { } List rec = new ArrayList<>(); TEXTRECORD tr = new TEXTRECORD(); - int textHeight = height / rows; + + RECT b = shapes.get(f).getBounds(); + int xmin = b.Xmin == Integer.MAX_VALUE?0:(int)(b.Xmin/((FontTag) tagObj).getDivider()); + xmin *= textHeight/1024.0; + int ymin = b.Ymin == Integer.MAX_VALUE?0:(int)(b.Ymin/((FontTag) tagObj).getDivider()); + ymin *= textHeight/1024.0; + int w=(int)(b.getWidth()/((FontTag) tagObj).getDivider()); + w *= textHeight/1024.0; + int h=(int)(b.getHeight()/((FontTag) tagObj).getDivider()); + h *= textHeight/1024.0; + tr.fontId = fontId; tr.styleFlagsHasFont = true; tr.textHeight = textHeight; + tr.xOffset=-xmin; + tr.yOffset=0; + tr.styleFlagsHasXOffset=true; + tr.styleFlagsHasYOffset=true; tr.glyphEntries = new GLYPHENTRY[1]; tr.styleFlagsHasColor = true; tr.textColor = new RGB(0, 0, 0); tr.glyphEntries[0] = new GLYPHENTRY(); - tr.glyphEntries[0].glyphAdvance = 0; + + + + double ga=((FontTag) tagObj).getGlyphAdvance(f); + int cw=ga==-1?w:(int)(ga/((FontTag) tagObj).getDivider()*textHeight/1024); + + tr.glyphEntries[0].glyphAdvance = cw; tr.glyphEntries[0].glyphIndex = f; - rec.add(tr); - mat.translateX = swf.displayRect.Xmin + x * width / cols; - mat.translateY = swf.displayRect.Ymin + y * height / rows; - new DefineTextTag(swf, 999 + f, new RECT(0, width, 0, height), new MATRIX(), rec).writeTag(sos2); + rec.add(tr); + + mat.translateX = x * width/ cols + width/cols/2 - w/2; + mat.translateY = y * height / rows; + new DefineTextTag(swf, 999 + f, new RECT(0, cw, ymin, ymin+h), new MATRIX(), rec).writeTag(sos2); new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1 + f, 999 + f, mat, null, 0, null, 0, null).writeTag(sos2); x++; } @@ -861,7 +906,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener { fos.flush(); } if (flashPanel != null) { - flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, frameRate); + flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, frameRate); } showFlashViewerPanel(); } catch (IOException | ActionParseException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index bcf3fc84e..3e554651d 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -173,7 +173,7 @@ public class FlashPlayerPanel extends Panel implements Closeable, MediaDisplay { if (bgColor != null) { setBackground(bgColor); } - flash.setMovie(flashName); + flash.setMovie(flashName); //play stopped = false; @@ -181,7 +181,7 @@ public class FlashPlayerPanel extends Panel implements Closeable, MediaDisplay { @Override public void close() throws IOException { - + } @Override