From a99fc25d88a0b0d1d1cc9badb2c32eefea8f986a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 25 Aug 2013 15:26:03 +0200 Subject: [PATCH] Issue #307 Export FLA: Empty DefineEditText fix Non existing font names fix (Dialog.plain etc.) --- .../decompiler/flash/xfl/XFLConverter.java | 206 ++++++++++-------- 1 file changed, 112 insertions(+), 94 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 20bca7531..aea93e03c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -2288,14 +2288,15 @@ public class XFLConverter { if ((fontName == null) && (font != null)) { fontName = font.getFontName(tags); } - psFontName = fontName; - if (fontName != null) { - for (String avFont : availableFonts) { - if (avFont.equals(fontName)) { - Font f = new Font(fontName, 0, 10); - psFontName = f.getPSName(); - } - } + int fontStyle = 0; + if (font != null) { + fontStyle = font.getFontStyle(); + } + String installedFont; + if((installedFont = FontTag.isFontInstalled(fontName))!=null){ + psFontName = new Font(installedFont, fontStyle, 10).getPSName(); + }else{ + psFontName = fontName; } } newline = false; @@ -2400,93 +2401,102 @@ public class XFLConverter { ret += ">"; ret += matStr; ret += ""; + String txt = ""; if (det.hasText) { - if (det.html) { - ret += convertHTMLText(tags, det, det.initialText); - } else { - ret += ""; - ret += "" + xmlString(det.initialText) + ""; - int leftMargin = -1; - int rightMargin = -1; - int indent = -1; - int lineSpacing = -1; - String alignment = null; - boolean italic = false; - boolean bold = false; - String fontFace = null; - int size = -1; - RGBA textColor = null; - if (det.hasTextColor) { - textColor = det.textColor; - } - if (det.hasFont) { - String fontName = null; - FontTag ft = null; - for (Tag u : tags) { - if (u instanceof DefineFontNameTag) { - if (((DefineFontNameTag) u).fontId == det.fontId) { - fontName = ((DefineFontNameTag) u).fontName; - } - } - if (u instanceof FontTag) { - if (((FontTag) u).getFontId() == det.fontId) { - ft = (FontTag) u; - } - } - if (fontName != null && ft != null) { - break; - } - } - if (ft != null) { - if (fontName == null) { - fontName = ft.getFontName(tags); - } - italic = ft.isItalic(); - bold = ft.isBold(); - size = det.fontHeight; - fontFace = new Font(fontName, (italic ? Font.ITALIC : 0) | (bold ? Font.BOLD : 0) | (!italic && !bold ? Font.PLAIN : 0), size < 0 ? 10 : size).getPSName(); - } - } - if (det.hasLayout) { - leftMargin = det.leftMargin; - rightMargin = det.rightMargin; - indent = det.indent; - lineSpacing = det.leading; - String alignNames[] = {"left", "right", "center", "justify"}; - alignment = alignNames[det.align]; - } - ret += ""; - ret += " -1) { - ret += " indent=\"" + twipToPixel(indent) + "\""; - } - if (leftMargin > -1) { - ret += " leftMargin=\"" + twipToPixel(leftMargin) + "\""; - } - if (lineSpacing > -1) { - ret += " lineSpacing=\"" + twipToPixel(lineSpacing) + "\""; - } - if (rightMargin > -1) { - ret += " rightMargin=\"" + twipToPixel(rightMargin) + "\""; - } - if (size > -1) { - ret += " size=\"" + twipToPixel(size) + "\""; - ret += " bitmapSize=\"" + size + "\""; - } - if (fontFace != null) { - ret += " face=\"" + fontFace + "\""; - } - if (textColor != null) { - ret += " fillColor=\"" + textColor.toHexRGB() + "\" alpha=\"" + textColor.getAlphaFloat() + "\""; - } - ret += "/>"; - ret += ""; - ret += ""; + txt = det.initialText; + } + + if (det.html) { + ret += convertHTMLText(tags, det, txt); + } else { + ret += ""; + ret += "" + xmlString(txt) + ""; + int leftMargin = -1; + int rightMargin = -1; + int indent = -1; + int lineSpacing = -1; + String alignment = null; + boolean italic = false; + boolean bold = false; + String fontFace = null; + int size = -1; + RGBA textColor = null; + if (det.hasTextColor) { + textColor = det.textColor; } + if (det.hasFont) { + String fontName = null; + FontTag ft = null; + for (Tag u : tags) { + if (u instanceof DefineFontNameTag) { + if (((DefineFontNameTag) u).fontId == det.fontId) { + fontName = ((DefineFontNameTag) u).fontName; + } + } + if (u instanceof FontTag) { + if (((FontTag) u).getFontId() == det.fontId) { + ft = (FontTag) u; + } + } + if (fontName != null && ft != null) { + break; + } + } + if (ft != null) { + if (fontName == null) { + fontName = ft.getFontName(tags); + } + italic = ft.isItalic(); + bold = ft.isBold(); + size = det.fontHeight; + fontFace = fontName; + String installedFont=null; + if((installedFont=FontTag.isFontInstalled(fontName))!=null){ + fontName = installedFont; + fontFace = new Font(installedFont, (italic ? Font.ITALIC : 0) | (bold ? Font.BOLD : 0) | (!italic && !bold ? Font.PLAIN : 0), size < 0 ? 10 : size).getPSName(); + } + + } + } + if (det.hasLayout) { + leftMargin = det.leftMargin; + rightMargin = det.rightMargin; + indent = det.indent; + lineSpacing = det.leading; + String alignNames[] = {"left", "right", "center", "justify"}; + alignment = alignNames[det.align]; + } + ret += ""; + ret += " -1) { + ret += " indent=\"" + twipToPixel(indent) + "\""; + } + if (leftMargin > -1) { + ret += " leftMargin=\"" + twipToPixel(leftMargin) + "\""; + } + if (lineSpacing > -1) { + ret += " lineSpacing=\"" + twipToPixel(lineSpacing) + "\""; + } + if (rightMargin > -1) { + ret += " rightMargin=\"" + twipToPixel(rightMargin) + "\""; + } + if (size > -1) { + ret += " size=\"" + twipToPixel(size) + "\""; + ret += " bitmapSize=\"" + size + "\""; + } + if (fontFace != null) { + ret += " face=\"" + fontFace + "\""; + } + if (textColor != null) { + ret += " fillColor=\"" + textColor.toHexRGB() + "\" alpha=\"" + textColor.getAlphaFloat() + "\""; + } + ret += "/>"; + ret += ""; + ret += ""; } ret += ""; ret += filterStr; @@ -3167,7 +3177,12 @@ public class XFLConverter { if (fontName == null) { fontName = ft.getFontName(tags); } - fontFace = new Font(fontName, (italic ? Font.ITALIC : 0) | (bold ? Font.BOLD : 0) | (!italic && !bold ? Font.PLAIN : 0), size < 0 ? 10 : size).getPSName(); + String installedFont; + if((installedFont = FontTag.isFontInstalled(fontName))!=null){ + fontFace = new Font(installedFont, (italic ? Font.ITALIC : 0) | (bold ? Font.BOLD : 0) | (!italic && !bold ? Font.PLAIN : 0), size < 0 ? 10 : size).getPSName(); + }else{ + fontFace = fontName; + } break; } } @@ -3253,6 +3268,9 @@ public class XFLConverter { @Override public void endDocument() { + if (this.result.equals("")) { + putText(""); + } } } }