diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a14332ff..559c6a00c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. ### Fixed - [#1687] Slow speed of cyclic tags detection - CopyStream bug for copies smaller than the buffer size +- [#1748] Wrong matching of DefineEditText fonts for rendering ## [14.4.0] - 2021-04-05 ### Added @@ -2200,6 +2201,7 @@ All notable changes to this project will be documented in this file. [#1485]: https://www.free-decompiler.com/flash/issues/1485 [#1681]: https://www.free-decompiler.com/flash/issues/1681 [#1687]: https://www.free-decompiler.com/flash/issues/1687 +[#1748]: https://www.free-decompiler.com/flash/issues/1748 [#1015]: https://www.free-decompiler.com/flash/issues/1015 [#1466]: https://www.free-decompiler.com/flash/issues/1466 [#1513]: https://www.free-decompiler.com/flash/issues/1513 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 54fa04d04..1517016e9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -584,6 +584,20 @@ public final class SWF implements SWFContainerItem, Timelined { return null; } + public FontTag getFontByNameInTag(String fontName) { + if (fontName == null) { + return null; + } + for (Tag t : getTags()) { + if (t instanceof FontTag) { + if (fontName.equals(((FontTag) t).getFontNameIntag())) { + return (FontTag) t; + } + } + } + return null; + } + public FontTag getFont(int fontId) { CharacterTag characterTag = getCharacters().get(fontId); if (characterTag instanceof FontTag) { 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 d3344b943..cf9a7cc43 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 @@ -440,7 +440,7 @@ public class DefineEditTextTag extends TextTag { { if (face != null && face.length() > 0) { style.fontFace = face; - FontTag insideFont = swf.getFontByName(face); + FontTag insideFont = swf.getFontByNameInTag(face); style.font = insideFont; if (insideFont != null) { style.fontFace = null; @@ -1043,11 +1043,16 @@ public class DefineEditTextTag extends TextTag { ge.fontStyle = (lastStyle.bold ? Font.BOLD : 0) | (lastStyle.italic ? Font.ITALIC : 0); ge.character = c; - ge.glyphIndex = -1; // always use system character glyphs in edit text + if (font != null) { + ge.glyphIndex = font.charToGlyph(c); + } else { + ge.glyphIndex = -1; + } String fontName = ge.fontFace != null ? ge.fontFace : FontTag.getDefaultFontName(); 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)); + ge.glyphAdvance = font == null ? (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar)) + : (int) (font.getGlyphAdvance(ge.glyphIndex) / font.getDivider()); textModel.addGlyph(c, ge); if (Character.isWhitespace(c)) {