diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad4b0527..31d79c81a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ All notable changes to this project will be documented in this file. - #1309 recent files not getting updates - #1311 actionScript source font size - #1312 faster colliding usages finder +- #1303 garbled text when exporting frame with text ## [9.0.0] - 2016-08-12 ### Added 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 1b6eb9b12..3cf0a48d4 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 @@ -381,7 +381,6 @@ public class DefineEditTextTag extends TextTag { try { saxParser = factory.newSAXParser(); DefaultHandler handler = new DefaultHandler() { - @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { TextStyle style = styles.peek(); @@ -999,26 +998,23 @@ public class DefineEditTextTag extends TextTag { if (i + 1 < txt.size()) { nextChar = txt.get(i + 1).character; } - int advance; + FontTag font = lastStyle.font; DynamicTextGlyphEntry ge = new DynamicTextGlyphEntry(); ge.fontFace = lastStyle.fontFace; + if (ge.fontFace == null && font != null) { + ge.fontFace = font.getFontName(); + } + ge.fontStyle = (lastStyle.bold ? Font.BOLD : 0) | (lastStyle.italic ? Font.ITALIC : 0); ge.character = c; - ge.glyphIndex = font == null ? -1 : font.charToGlyph(c); - if (font != null && font.hasLayout()) { - int kerningAdjustment = 0; - if (nextChar != null) { - kerningAdjustment = font.getCharKerningAdjustment(c, nextChar); - kerningAdjustment /= font.getDivider(); - } - advance = (int) Math.round(Math.round((double) lastStyle.fontHeight * (font.getGlyphAdvance(ge.glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0))); - } else { - String fontName = lastStyle.fontFace != null ? lastStyle.fontFace : FontTag.defaultFontName; - int fontStyle = font == null ? ge.fontStyle : font.getFontStyle(); - advance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar)); - } - ge.glyphAdvance = advance; + + ge.glyphIndex = -1; // always use system character glyphs in edit text + + String fontName = ge.fontFace != null ? ge.fontFace : FontTag.defaultFontName; + int fontStyle = font == null ? ge.fontStyle : font.getFontStyle(); + ge.glyphAdvance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar)); + textModel.addGlyph(c, ge); if (Character.isWhitespace(c)) { lastWasWhiteSpace = true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 434e25c03..4dccc9851 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -497,7 +497,7 @@ public abstract class TextTag extends DrawableTag { DynamicTextGlyphEntry dynamicEntry = (DynamicTextGlyphEntry) entry; if (dynamicEntry.fontFace != null) { FontTag fnt = swf.getFontByName(dynamicEntry.fontFace); - if (fnt != null) { + if (fnt != null && entry.glyphIndex != -1) { shape = fnt.getGlyphShapeTable().get(entry.glyphIndex); } else { shape = SHAPERECORD.fontCharacterToSHAPE(new Font(dynamicEntry.fontFace, dynamicEntry.fontStyle, 12), (int) Math.round(divider * 1024), dynamicEntry.character); diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index b75b8fcb4..221060330 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -97,7 +97,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private boolean stillFrame = false; - private Timer timer; + private volatile Timer timer; private int frame = -1;