diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7e1fae4..810d6fdb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. - Status bar with info about edges on walking shaperecords - [#1799] Text tags editor has new parameter `[space xxx]` specifying exact letter advance value (add to the font advance + calculated letterspacing) +- DefineEditText display - letterspacing, kerning, relative font size ### Fixed - [#1306], [#1768] Maximizing window on other than main monitor 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 e139c2d0d..61d86d0e7 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 @@ -438,11 +438,16 @@ public class DefineEditTextTag extends TextTag { char firstChar = size.charAt(0); if (firstChar != '+' && firstChar != '-') { int fontSize = Integer.parseInt(size); - style.fontHeight = (int) Math.round(fontSize * SWF.unitDivisor); - style.fontLeading = leading; + style.fontHeight = (int) Math.round(fontSize * SWF.unitDivisor); } else { - // todo: parse relative sizes + int fontSizeDelta = (int) Math.round(Integer.parseInt(size.substring(1)) * SWF.unitDivisor); + if (firstChar == '+') { + style.fontHeight = style.fontHeight + fontSizeDelta; + } else { + style.fontHeight = style.fontHeight - fontSizeDelta; + } } + style.fontLeading = leading; } String face = unescape(attributes.getValue("face")); @@ -455,7 +460,16 @@ public class DefineEditTextTag extends TextTag { } } - // todo: parse the following attributes: letterSpacing, kerning + String letterspacing = unescape(attributes.getValue("letterSpacing")); + if (letterspacing != null && letterspacing.length() > 0) { + style.letterSpacing = Double.parseDouble(letterspacing); + } + + String kerning = unescape(attributes.getValue("kerning")); + if (kerning != null && kerning.length() > 0) { + style.kerning = kerning.equals("1"); + } + styles.add(style); break; case "br": @@ -1077,9 +1091,14 @@ public class DefineEditTextTag extends TextTag { String fontName = ge.fontFace != null ? ge.fontFace : FontTag.getDefaultFontName(); int fontStyle = font == null ? ge.fontStyle : font.getFontStyle(); - ge.glyphAdvance = ge.glyphIndex == -1 ? (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar)) + ge.glyphAdvance = ge.glyphIndex == -1 ? (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, lastStyle.kerning ? nextChar : null)) : (int) Math.round(font.getGlyphAdvance(ge.glyphIndex) / font.getDivider() * lastStyle.fontHeight / 1024); - + ge.glyphAdvance += lastStyle.letterSpacing * SWF.unitDivisor; + if (lastStyle.kerning) { + if (nextChar != null) { + ge.glyphAdvance += font.getCharKerningAdjustment(c, nextChar) / font.getDivider(); + } + } textModel.addGlyph(c, ge); if (Character.isWhitespace(c)) { lastWasWhiteSpace = true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java index 68350e3f0..4bb00cbdb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java @@ -40,6 +40,10 @@ public final class TextStyle implements Cloneable { public boolean underlined; public RGBA textColor; + + public double letterSpacing; + + public boolean kerning; @Override public TextStyle clone() { diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics.swf b/libsrc/ffdec_lib/testdata/graphics/graphics.swf index b42093163..25dae7a9d 100644 Binary files a/libsrc/ffdec_lib/testdata/graphics/graphics.swf and b/libsrc/ffdec_lib/testdata/graphics/graphics.swf differ diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml index 36cc4ece1..eea57010c 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml @@ -1,13 +1,13 @@ + - - + @@ -36,9 +36,9 @@ - + - + @@ -64,7 +64,7 @@ stop();]]> - + @@ -253,7 +253,7 @@ stop();]]> - + @@ -333,10 +333,10 @@ stop();]]> - + @@ -865,10 +865,10 @@ stop();]]> !3980 1990|2980 1990!2980 1990|2980 990!2980 990|3980 990!3980 990|3980 1990"/> - + @@ -1467,18 +1467,18 @@ stop();]]> - + - - + + @@ -2502,6 +2502,114 @@ stop();]]> + + + + + + + + + AV + + + + + + + + + + + + + AV + + + + + + + + + + + + + kerning on + + + + + + + + + + + + + kerning off + + + + + + + + + + + + + ABCD + + + + + + + + + + + + + letterspacing positive + + + + + + + + + + + + + ABCD + + + + + + + + + + + + + letterspacing negative + + + + + + + + @@ -3129,7 +3237,7 @@ stop();]]> - + @@ -3796,7 +3904,7 @@ stop();]]> - + @@ -3879,6 +3987,23 @@ stop();]]> + + + + + + + + + 066 EditTexts + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml index 9735e47db..894ca8500 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml @@ -28,89 +28,85 @@ - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml index bfbd08dee..04ecc3790 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml @@ -25,9 +25,9 @@ - - + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml index 3cb8b9d3a..beeafb524 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml @@ -28,73 +28,69 @@ - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + - - - - - - - - - - + + + + + + - - + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml index 32ee2ccdb..ca1dc5168 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/META-INF/metadata.xml @@ -5,8 +5,8 @@ xmlns:xmp="http://ns.adobe.com/xap/1.0/"> Adobe Flash Professional CS6 - build 481 2021-03-14T08:29:20+01:00 - 2023-10-14T07:01:59-07:00 - 2023-10-14T07:01:59-07:00 + 2023-11-04T15:04:36-07:00 + 2023-11-04T15:04:36-07:00 @@ -15,7 +15,7 @@ - xmp.iid:15855FDA1B6AEE11BC63CA8993825CE8 + xmp.iid:87EBDCC1FF7AEE11A761AC8796625B0A xmp.did:D6D3FE199784EB1187FEAE6972EC5115 xmp.did:D6D3FE199784EB1187FEAE6972EC5115 @@ -158,6 +158,12 @@ 2021-03-14T08:29:20+01:00 Adobe Flash Professional CS6 - build 481 + + created + xmp.iid:87EBDCC1FF7AEE11A761AC8796625B0A + 2021-03-14T08:29:20+01:00 + Adobe Flash Professional CS6 - build 481 + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache b/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache index a092db321..3e47fddd6 100644 Binary files a/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache and b/libsrc/ffdec_lib/testdata/graphics/graphics/bin/SymDepend.cache differ