diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index ba3616327..d8de95bcc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -1047,8 +1047,8 @@ public final class SWF implements TreeItem, Timelined { for (int r = ret.size() - 1; r >= 0; r--) { TreeNode node = ret.get(r); - TreeItem item = node.getItem(); - if (!(item instanceof DefineSpriteTag + TreeItem item = node.getItem(); + if (!(item instanceof DefineSpriteTag || item instanceof DefineButtonTag || item instanceof DefineButton2Tag || item instanceof DoInitActionTag @@ -1080,7 +1080,7 @@ public final class SWF implements TreeItem, Timelined { if (path == null) { path = ""; } - String[] pathParts = path.contains(".") ? path.split("\\.") : new String[]{ path }; + String[] pathParts = path.contains(".") ? path.split("\\.") : new String[]{path}; List items = ret; for (int pos = 0; pos < pathParts.length - 1; pos++) { String pathPart = pathParts[pos]; @@ -1139,7 +1139,7 @@ public final class SWF implements TreeItem, Timelined { ret.addAll(frames); for (int i = ret.size() - 1; i >= 0; i--) { TreeNode node = ret.get(i); - TreeItem item = node.getItem(); + TreeItem item = node.getItem(); if (item instanceof ASMSource) { ASMSource ass = (ASMSource) item; if (ass.containsSource()) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java index ab0b0b173..8c080301b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -400,11 +400,11 @@ public class SWFOutputStream extends OutputStream { nBits = enlargeBitCountS(nBits, xMax); nBits = enlargeBitCountS(nBits, yMin); nBits = enlargeBitCountS(nBits, yMax); - + if (Configuration.debugCopy.get()) { nBits = Math.max(nBits, value.nbits); } - + writeUB(5, nBits); writeSB(nBits, xMin); writeSB(nBits, xMax); @@ -569,7 +569,7 @@ public class SWFOutputStream extends OutputStream { if (Configuration.debugCopy.get()) { nBits = Math.max(nBits, value.nScaleBits); } - + writeUB(5, nBits); writeSB(nBits, value.scaleX); writeSB(nBits, value.scaleY); @@ -583,7 +583,7 @@ public class SWFOutputStream extends OutputStream { if (Configuration.debugCopy.get()) { nBits = Math.max(nBits, value.nRotateBits); } - + writeUB(5, nBits); writeSB(nBits, value.rotateSkew0); writeSB(nBits, value.rotateSkew1); @@ -624,11 +624,11 @@ public class SWFOutputStream extends OutputStream { Nbits = enlargeBitCountS(Nbits, value.greenAddTerm); Nbits = enlargeBitCountS(Nbits, value.blueAddTerm); } - + if (Configuration.debugCopy.get()) { Nbits = Math.max(Nbits, value.nbits); } - + writeUB(4, Nbits); if (value.hasMultTerms) { writeSB(Nbits, value.redMultTerm); @@ -669,7 +669,7 @@ public class SWFOutputStream extends OutputStream { if (Configuration.debugCopy.get()) { Nbits = Math.max(Nbits, value.nbits); } - + writeUB(4, Nbits); if (value.hasMultTerms) { writeSB(Nbits, value.redMultTerm); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 33258aaad..d5d02f8f3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -467,7 +467,7 @@ public class Configuration { } return result; } - + public static Map getFontIdToFaceMap() { String fonts = fontPairing.get(); if (fonts == null) { @@ -478,7 +478,7 @@ public class Configuration { for (String pair : fonts.split("::")) { if (!pair.isEmpty()) { String[] splittedPair = pair.split("="); - result.put(splittedPair[0], splittedPair.length<3?"":splittedPair[2]); + result.put(splittedPair[0], splittedPair.length < 3 ? "" : splittedPair[2]); } } return result; @@ -489,8 +489,8 @@ public class Configuration { Map fontPairs = getFontIdToFamilyMap(); fontPairs.put(key, installedFontFamily); fontPairs.put(fontName, installedFontFamily); - - Map facePairs = getFontIdToFaceMap(); + + Map facePairs = getFontIdToFaceMap(); facePairs.put(key, installedFontFace); facePairs.put(fontName, installedFontFace); StringBuilder sb = new StringBuilder(); @@ -499,7 +499,7 @@ public class Configuration { if (i != 0) { sb.append("::"); } - sb.append(pair.getKey()).append("=").append(pair.getValue()).append("=").append(facePairs.containsKey(pair.getKey())?facePairs.get(pair.getKey()):""); + sb.append(pair.getKey()).append("=").append(pair.getValue()).append("=").append(facePairs.containsKey(pair.getKey()) ? facePairs.get(pair.getKey()) : ""); i++; } fontPairing.set(sb.toString()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java index 5c904214a..8b3c6ffe4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java @@ -24,7 +24,6 @@ import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.RetryTask; import com.jpexs.decompiler.flash.RunnableIOEx; -import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings; import com.jpexs.decompiler.flash.exporters.shape.PathExporter; @@ -114,7 +113,7 @@ public class FontExporter { List shapes = t.getGlyphShapeTable(); final double divider = t.getDivider(); - + File ttfFile = file; if (mode == FontExportMode.WOFF) { @@ -126,8 +125,8 @@ public class FontExporter { f.getEngine().setCopyrightYear(cop == null ? "" : cop); f.setAuthor(ApplicationInfo.shortApplicationVerName); - f.setVersion("1.0"); - + f.setVersion("1.0"); + f.setAscender(Math.round(t.getAscent() / divider)); f.setDescender(Math.round(t.getDescent() / divider)); @@ -179,13 +178,13 @@ public class FontExporter { char c = t.glyphToChar(i); if (contours.isEmpty()) { continue; - } + } final FGlyph g = f.addGlyph(c); double adv = t.getGlyphAdvance(i); if (adv != -1) { g.setAdvanceWidth((int) Math.round(adv / divider)); } else { - g.setAdvanceWidth((int)Math.round(t.getGlyphWidth(i) / divider + 100)); + g.setAdvanceWidth((int) Math.round(t.getGlyphWidth(i) / divider + 100)); } for (FPoint[] cnt : contours) { if (cnt.length == 0) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java index 1340df6c7..fdd8717e5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.helpers; -import com.jpexs.decompiler.flash.AppResources; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.lang.reflect.Field; @@ -30,17 +29,18 @@ import java.util.Map; * @author JPEXS */ public class FontHelper { - + /** * Gets all available fonts in the system + * * @return Map> */ - public static Map> getInstalledFonts(){ - Map> ret = new HashMap<>(); + public static Map> getInstalledFonts() { + Map> ret = new HashMap<>(); Font fonts[] = null; - + try { - Class clFmFactory = Class.forName("sun.font.FontManagerFactory"); + Class clFmFactory = Class.forName("sun.font.FontManagerFactory"); Object fm = clFmFactory.getDeclaredMethod("getInstance").invoke(null); Class clFm = Class.forName("sun.font.SunFontManager"); @@ -52,7 +52,7 @@ public class FontHelper { //Delete cached family names Field allFamField = clFm.getDeclaredField("allFamilies"); allFamField.setAccessible(true); - allFamField.set(fm,null); + allFamField.set(fm, null); //Delete cached fonts Field allFonField = clFm.getDeclaredField("allFonts"); @@ -60,34 +60,34 @@ public class FontHelper { allFonField.set(fm, null); fonts = (Font[]) clFm.getDeclaredMethod("getAllInstalledFonts").invoke(fm); - } catch (Throwable ex) { + } catch (Throwable ex) { //ignore } - if(fonts == null){ + if (fonts == null) { fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); - } - for(Font f:fonts){ + } + for (Font f : fonts) { String fam = f.getFamily(Locale.getDefault()); //Do not want Java logical fonts - if(Arrays.asList("Dialog","DialogInput","Monospaced","Serif","SansSerif").contains(fam)){ + if (Arrays.asList("Dialog", "DialogInput", "Monospaced", "Serif", "SansSerif").contains(fam)) { continue; } - if(!ret.containsKey(fam)){ + if (!ret.containsKey(fam)) { ret.put(fam, new HashMap()); } - String face = getFontFace(f); + String face = getFontFace(f); ret.get(f.getFamily()).put(face, f); } return ret; } - - public static String getFontFace(Font f){ + + public static String getFontFace(Font f) { String fam = f.getFamily(Locale.getDefault()); String face = f.getFontName(Locale.getDefault()); - if(face.startsWith(fam)){ + if (face.startsWith(fam)) { face = face.substring(fam.length()).trim(); - } - if(face.startsWith(".")){ + } + if (face.startsWith(".")) { face = face.substring(1); } return face; 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 8670d97d2..241232a99 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 @@ -260,7 +260,7 @@ public class DefineEditTextTag extends TextTag { char firstChar = size.charAt(0); if (firstChar != '+' && firstChar != '-') { int fontSize = Integer.parseInt(size); - style.fontHeight = (int)Math.round(fontSize * (style.font == null ? 1 : style.font.getDivider())); + style.fontHeight = (int) Math.round(fontSize * (style.font == null ? 1 : style.font.getDivider())); style.fontLeading = leading; } else { // todo: parse relative sizes diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index 96f4f89fa..7be666191 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -102,9 +102,6 @@ public class DefineFont2Tag extends FontTag { return fontBoundsTable.get(glyphIndex); } - - - @Override public double getGlyphAdvance(int glyphIndex) { if (fontFlagsHasLayout) { @@ -380,7 +377,7 @@ public class DefineFont2Tag extends FontTag { public void addCharacter(char character, Font font) { int fontStyle = getFontStyle(); - SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, fontStyle, (int)Math.round(getDivider() * 1024), character); + SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, fontStyle, (int) Math.round(getDivider() * 1024), character); int code = (int) character; int pos = -1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index cfef8825e..ee6b8c1c9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -16,7 +16,6 @@ */ 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.abc.CopyOutputStream; @@ -377,7 +376,7 @@ public class DefineFont3Tag extends FontTag { } } int fontStyle = getFontStyle(); - SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, fontStyle, (int)Math.round(getDivider() * 1024), character); + SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, fontStyle, (int) Math.round(getDivider() * 1024), character); int code = (int) character; int pos = -1; boolean exists = false; @@ -438,8 +437,6 @@ public class DefineFont3Tag extends FontTag { return fontBoundsTable.get(glyphIndex); } - - @Override public int getGlyphKerningAdjustment(int glyphIndex, int nextGlyphIndex) { if (glyphIndex == -1 || nextGlyphIndex == -1) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java index 91d5d0497..ac2deff67 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java @@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.types.BasicType; -import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; @@ -268,7 +267,7 @@ public class DefineFontTag extends FontTag { @Override public void addCharacter(char character, Font font) { - SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, getFontStyle(), (int)Math.round(getDivider() * 1024), character); + SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, getFontStyle(), (int) Math.round(getDivider() * 1024), character); List codeTable = new ArrayList<>(); ensureFontInfo(); if (fontInfoTag != null) { @@ -324,5 +323,5 @@ public class DefineFontTag extends FontTag { public int getGlyphKerningAdjustment(int glyphIndex, int nextGlyphIndex) { return 0; } - + } 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 1ca1777f3..724a24cae 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 @@ -460,7 +460,7 @@ public class DefineText2Tag extends TextTag { glyphBits = Math.max(glyphBits, this.glyphBits); advanceBits = Math.max(advanceBits, this.advanceBits); } - + sos.writeUI8(glyphBits); sos.writeUI8(advanceBits); for (TEXTRECORD tr : textRecords) { 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 78a092336..8c4b4cc26 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 @@ -472,7 +472,7 @@ public class DefineTextTag extends TextTag { glyphBits = Math.max(glyphBits, this.glyphBits); advanceBits = Math.max(advanceBits, this.advanceBits); } - + sos.writeUI8(glyphBits); sos.writeUI8(advanceBits); for (TEXTRECORD tr : textRecords) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 2d7ed7de5..5cc176d4d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -205,7 +205,6 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { return pathParts[pathParts.length - 1]; } - @Override public GraphTextWriter getActionSourcePrefix(GraphTextWriter writer) { return writer; 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 1875fa534..a21ef7230 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 @@ -22,29 +22,18 @@ import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; import com.jpexs.decompiler.flash.helpers.FontHelper; -import com.jpexs.decompiler.flash.tags.DefineFont2Tag; import com.jpexs.decompiler.flash.tags.DefineFontNameTag; import com.jpexs.decompiler.flash.tags.DefineText2Tag; import com.jpexs.decompiler.flash.tags.DefineTextTag; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.GLYPHENTRY; -import com.jpexs.decompiler.flash.types.KERNINGRECORD; -import com.jpexs.decompiler.flash.types.LANGCODE; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.decompiler.flash.types.TEXTRECORD; -import com.jpexs.decompiler.flash.types.gfx.FontType; -import com.jpexs.decompiler.flash.types.gfx.GlyphInfoType; -import com.jpexs.decompiler.flash.types.gfx.GlyphType; -import com.jpexs.decompiler.flash.types.shaperecords.CurvedEdgeRecord; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; -import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord; -import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord; import com.jpexs.helpers.ByteArrayRange; -import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.awt.Font; @@ -54,15 +43,10 @@ import java.awt.font.FontRenderContext; import java.awt.font.GlyphMetrics; import java.awt.font.GlyphVector; import java.awt.geom.Area; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -120,7 +104,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable public abstract int getLeading(); - public static Map> installedFonts; + public static Map> installedFonts; public static String defaultFontName; @@ -352,15 +336,11 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable sb.append("\t}\r\n"); return sb.toString(); } - - - - public RECT getGlyphBounds(int glyphIndex) { return getGlyphShapeTable().get(glyphIndex).getBounds(); - } - + } + public FontTag toClassicFont() { return this; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java index 3fcaf4104..0d1c6da1d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/ContourType.java @@ -70,7 +70,7 @@ public class ContourType implements Serializable { edges = edgesList.toArray(new EdgeType[edgesList.size()]); } - public ContourType(GFxInputStream sis,long fontOffset) throws IOException { + public ContourType(GFxInputStream sis, long fontOffset) throws IOException { moveToX = sis.readSI15("moveToX"); moveToY = sis.readSI15("moveToY"); long numEdgesRef = sis.readUI30("numEdgesRef"); @@ -80,10 +80,10 @@ public class ContourType implements Serializable { int numEdges; if (isReference) { long referencePos = numEdgesRef; - sis.setPos(fontOffset+referencePos); - numEdges = (int)(sis.readUI30("numEdges") >> 1); - }else{ - numEdges = (int)numEdgesRef; + sis.setPos(fontOffset + referencePos); + numEdges = (int) (sis.readUI30("numEdges") >> 1); + } else { + numEdges = (int) numEdgesRef; } edges = new EdgeType[(int) numEdges]; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java index 563efc0ca..79a871082 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/FontType.java @@ -74,10 +74,10 @@ public class FontType implements Serializable { for (int i = 0; i < glyphInfo.size(); i++) { sis.setPos(glyphInfo.get(i).globalOffset + offset); sis.newDumpLevel("glyphType", "GlyphType"); - glyphs.add(new GlyphType(sis,offset)); + glyphs.add(new GlyphType(sis, offset)); sis.endDumpLevel(); } - + sis.setPos(pos); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index 79d28dc97..a2cd0494c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -234,9 +234,9 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali } public static SHAPE systemFontCharacterToSHAPE(final String fontName, final int fontStyle, int fontSize, char character) { - return fontCharacterToSHAPE(new Font(FontTag.getFontNameWithFallback(fontName),Font.PLAIN,10), fontStyle, fontSize, character); + return fontCharacterToSHAPE(new Font(FontTag.getFontNameWithFallback(fontName), Font.PLAIN, 10), fontStyle, fontSize, character); } - + public static SHAPE fontCharacterToSHAPE(final Font font, final int fontStyle, int fontSize, char character) { int multiplier = 1; if (fontSize > 1024) { @@ -244,7 +244,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali fontSize = 1024; } List retList = new ArrayList<>(); - Font f = font.deriveFont(fontStyle, fontSize); + Font f = font.deriveFont(fontStyle, fontSize); GlyphVector v = f.createGlyphVector((new JPanel()).getFontMetrics(f).getFontRenderContext(), "" + character); Shape shp = v.getOutline(); double[] points = new double[6]; diff --git a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java index 63ce4171a..efc7d5717 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java @@ -74,7 +74,7 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { private final JLabel[] rangeSamples; private final JTextField individualCharsField; private boolean result = false; - private JLabel individialSample; + private JLabel individialSample; private Font customFont; private final JCheckBox allCheckbox; private final JCheckBox updateTextsCheckbox; @@ -83,17 +83,17 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { if (ttfFileRadio.isSelected() && customFont != null) { return customFont; } - return FontTag.installedFonts.get(familyNamesSelection.getSelectedItem().toString()).get(faceSelection.getSelectedItem().toString()); + return FontTag.installedFonts.get(familyNamesSelection.getSelectedItem().toString()).get(faceSelection.getSelectedItem().toString()); } - public boolean hasUpdateTexts(){ + public boolean hasUpdateTexts() { return updateTextsCheckbox.isSelected(); } - + public Set getSelectedChars() { Set chars = new TreeSet<>(); Font f = getSelectedFont(); - if(allCheckbox.isSelected()){ + if (allCheckbox.isSelected()) { for (int i = 0; i < rangeCheckboxes.length; i++) { int codes[] = CharacterRanges.rangeCodes(i); for (int c : codes) { @@ -102,7 +102,7 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { } } } - }else{ + } else { for (int i = 0; i < rangeCheckboxes.length; i++) { if (rangeCheckboxes[i].isSelected()) { int codes[] = CharacterRanges.rangeCodes(i); @@ -126,10 +126,10 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { private JRadioButton ttfFileRadio; private JRadioButton installedRadio; - private void updateFaceSelection(){ - faceSelection.setModel( new DefaultComboBoxModel<>(new Vector(FontTag.installedFonts.get(familyNamesSelection.getSelectedItem().toString()).keySet()))); + private void updateFaceSelection() { + faceSelection.setModel(new DefaultComboBoxModel<>(new Vector(FontTag.installedFonts.get(familyNamesSelection.getSelectedItem().toString()).keySet()))); } - + public FontEmbedDialog(String selectedFamily, String selectedFace, String selectedChars) { setSize(900, 600); setDefaultCloseOperation(HIDE_ON_CLOSE); @@ -150,8 +150,8 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { installedRadio.setSelected(true); individialSample = new JLabel(); - familyNamesSelection = new JComboBox<>(new Vector(new TreeSet(FontTag.installedFonts.keySet()))); - familyNamesSelection.setSelectedItem(selectedFamily); + familyNamesSelection = new JComboBox<>(new Vector(new TreeSet(FontTag.installedFonts.keySet()))); + familyNamesSelection.setSelectedItem(selectedFamily); faceSelection = new JComboBox<>(); updateFaceSelection(); faceSelection.setSelectedItem(selectedFace); @@ -207,14 +207,14 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { @Override public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED){ - for (int i = 0; i < rc; i++) { - rangeCheckboxes[i].setEnabled(false); - } - individualCharsField.setEnabled(false); - }else if(e.getStateChange() == ItemEvent.DESELECTED){ + if (e.getStateChange() == ItemEvent.SELECTED) { for (int i = 0; i < rc; i++) { - rangeCheckboxes[i].setEnabled(true); + rangeCheckboxes[i].setEnabled(false); + } + individualCharsField.setEnabled(false); + } else if (e.getStateChange() == ItemEvent.DESELECTED) { + for (int i = 0; i < rc; i++) { + rangeCheckboxes[i].setEnabled(true); } individualCharsField.setEnabled(true); } @@ -222,10 +222,10 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { }); JPanel rangeRowPanel = new JPanel(); rangeRowPanel.setLayout(new BorderLayout()); - rangeRowPanel.add(allCheckbox,BorderLayout.WEST); + rangeRowPanel.add(allCheckbox, BorderLayout.WEST); rangeRowPanel.setAlignmentX(0); rangesPanel.add(rangeRowPanel); - + for (int i = 0; i < rc; i++) { rangeNames[i] = CharacterRanges.rangeName(i); rangeSamples[i] = new JLabel(""); @@ -247,18 +247,14 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { individualCharsField.setPreferredSize(new Dimension(100, individualCharsField.getPreferredSize().height)); individialSample = new JLabel(); specialPanel.add(individualCharsField); - + updateTextsCheckbox = new JCheckBox(AppStrings.translate("font.updateTexts")); - + JPanel utPanel = new JPanel(new FlowLayout()); utPanel.add(updateTextsCheckbox); cnt.add(specialPanel); cnt.add(individialSample); cnt.add(utPanel); - - - - JPanel buttonsPanel = new JPanel(new FlowLayout()); JButton okButton = new JButton(AppStrings.translate("button.ok")); @@ -279,7 +275,7 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { @Override public void itemStateChanged(ItemEvent e) { updateFaceSelection(); - updateCheckboxes(); + updateCheckboxes(); } }); faceSelection.addItemListener(new ItemListener() { @@ -313,8 +309,8 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { private void updateCheckboxes() { Font f = getSelectedFont().deriveFont(12f); int rc = CharacterRanges.rangeCount(); - - Set allChars=new HashSet<>(); + + Set allChars = new HashSet<>(); for (int i = 0; i < rc; i++) { rangeNames[i] = CharacterRanges.rangeName(i); int codes[] = CharacterRanges.rangeCodes(i); @@ -333,7 +329,7 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { rangeSamples[i].setFont(f); rangeCheckboxes[i].setText(translate("range.description").replace("%available%", "" + avail).replace("%name%", rangeNames[i]).replace("%total%", "" + codes.length)); } - allCheckbox.setText(translate("allcharacters").replace("%available%", ""+allChars.size())); + allCheckbox.setText(translate("allcharacters").replace("%available%", "" + allChars.size())); individialSample.setFont(f); updateIndividual(); }