diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ba4e09d5..2568aa1f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,8 @@ All notable changes to this project will be documented in this file. - AS1/2 Debugger - script was cleared on stop button - AS1/2 Vanishing source code in some cases - AS1/2 Debugger tooltips exception +- [#2131] UseOutline flag for DefineEditText +- Wordrapping long words in DefineEditText ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class 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 ce138c388..2ee59d350 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 @@ -515,7 +515,7 @@ public class DefineEditTextTag extends TextTag { public void characters(char[] ch, int start, int length) throws SAXException { String txt = unescape(new String(ch, start, length)); TextStyle style = styles.peek(); - if (style.fontFace != null) { + if (style.fontFace != null && useOutlines) { style.font = swf.getFontByNameInTag(style.fontFace, style.bold, style.italic); if (style.font == null) { style.fontFace = null; @@ -1083,13 +1083,13 @@ public class DefineEditTextTag extends TextTag { DynamicTextGlyphEntry ge = new DynamicTextGlyphEntry(); ge.fontFace = lastStyle.fontFace; if (ge.fontFace == null && font != null) { - ge.fontFace = font.getFontName(); + ge.fontFace = font.getFontNameIntag(); } ge.fontStyle = (lastStyle.bold ? Font.BOLD : 0) | (lastStyle.italic ? Font.ITALIC : 0); ge.character = c; - if (font != null) { + if (useOutlines && font != null) { ge.glyphIndex = font.charToGlyph(c); } else { ge.glyphIndex = -1; @@ -1100,7 +1100,7 @@ public class DefineEditTextTag extends TextTag { 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 && font != null && font.hasLayout()) { + if (useOutlines && lastStyle.kerning && font != null && font.hasLayout()) { if (nextChar != null) { ge.glyphAdvance += font.getCharKerningAdjustment(c, nextChar) / font.getDivider(); } @@ -1116,18 +1116,63 @@ public class DefineEditTextTag extends TextTag { } textModel.calculateTextWidths(); + + Set noIndentLineIndices = new HashSet<>(); + List> lines; if (multiline && wordWrap) { lines = new ArrayList<>(); for (Paragraph paragraph : textModel.paragraphs) { List line = new ArrayList<>(); int lineLength = 0; - for (Word word : paragraph.words) { - if (lineLength + word.width <= bounds.getWidth()) { + for (Word word : paragraph.words) { + int indentVal = noIndentLineIndices.contains(lines.size()) ? 0 : indent; + int maxLineWidth = bounds.getWidth() - leftMargin - indentVal; + if (word.width > maxLineWidth) { + List recs = new ArrayList<>(); + for (int i = 0; i < word.records.size(); i++) { + SameStyleTextRecord rec = word.records.get(i); + for (int g = 0; g < rec.glyphEntries.size(); g++) { + GlyphCharacter gc = rec.glyphEntries.get(g); + int ga = gc.glyphEntry.glyphAdvance; + indentVal = noIndentLineIndices.contains(lines.size()) ? 0 : indent; + maxLineWidth = bounds.getWidth() - leftMargin - indentVal; + if (lineLength + ga > maxLineWidth) { + recs.add(rec); + line.addAll(recs); + lines.add(line); + + recs = new ArrayList<>(); + SameStyleTextRecord rec2 = new SameStyleTextRecord(); + rec2.style = rec.style.clone(); + rec2.glyphEntries = new ArrayList<>(); + int glen = rec.glyphEntries.size(); + for (int g2 = g; g2 < glen; g2++) { + rec2.glyphEntries.add(rec.glyphEntries.remove(g)); + } + rec2.calculateTextWidths(); + rec.calculateTextWidths(); + + rec = rec2; + g = 0; + + noIndentLineIndices.add(lines.size()); + line = new ArrayList<>(); + lineLength = 0; + } + lineLength += ga; + } + recs.add(rec); + } + if (!recs.isEmpty()) { + line.addAll(recs); + } + } else if (lineLength + word.width <= maxLineWidth) { line.addAll(word.records); lineLength += word.width; - } else { + } else { lines.add(line); + noIndentLineIndices.add(lines.size()); line = new ArrayList<>(); line.addAll(word.records); lineLength = 0; @@ -1172,40 +1217,6 @@ public class DefineEditTextTag extends TextTag { textModel.calculateTextWidths(); - Set noIndentLineIndices = new HashSet<>(); - - for (int k = 0; k < lines.size(); k++) { - List line = lines.get(k); - int width = leftMargin; - if (!noIndentLineIndices.contains(k)) { - width += indent; - } - for (int i = 0; i < line.size(); i++) { - SameStyleTextRecord tr = line.get(i); - for (int g = 0; g < tr.glyphEntries.size(); g++) { - GlyphCharacter gc = tr.glyphEntries.get(g); - int advance = gc.glyphEntry.glyphAdvance; - if (width + advance > bounds.getWidth()) { - SameStyleTextRecord newTr = new SameStyleTextRecord(); - newTr.glyphEntries = new ArrayList<>(); - newTr.style = tr.style.clone(); - int gsize = tr.glyphEntries.size(); - for (int g2 = g; g2 < gsize; g2++) { - newTr.glyphEntries.add(tr.glyphEntries.remove(g)); - } - List newLine = new ArrayList<>(); - newLine.add(newTr); - int lsize = line.size(); - for (int i2 = i + 1; i2 < lsize; i2++) { - newLine.add(line.remove(i)); - } - lines.add(k + 1, newLine); - noIndentLineIndices.add(k + 1); - } - width += advance; - } - } - } List allTextRecords = new ArrayList<>(); int lastHeight = 0; int yOffset = 0; @@ -1219,9 +1230,9 @@ public class DefineEditTextTag extends TextTag { } else { for (SameStyleTextRecord tr : line) { width += tr.width; - int lineHeight = (tr.style.font != null /*Font missing*/) && tr.style.font.hasLayout() ? (int) Math.round(tr.style.fontHeight * tr.style.font.getAscent() / tr.style.font.getDivider() / 1024.0) + tr.style.fontLeading + int lineHeight = (useOutlines && tr.style.font != null /*Font missing*/) && tr.style.font.hasLayout() ? (int) Math.round(tr.style.fontHeight * tr.style.font.getAscent() / tr.style.font.getDivider() / 1024.0) + tr.style.fontLeading : tr.style.fontHeight + tr.style.fontLeading; - if (tr.style.font != null && !firstLine && tr.style.font.hasLayout()) { + if (useOutlines && tr.style.font != null && !firstLine && tr.style.font.hasLayout()) { lineHeight += (int) Math.round(tr.style.fontHeight * tr.style.font.getDescent() / tr.style.font.getDivider() / 1024.0); } //TODO: maybe get ascent/descent from system font when not haslayout @@ -1268,14 +1279,14 @@ public class DefineEditTextTag extends TextTag { if (fontClass != null) { FontTag ft = swf.getFontByClass(fontClass); if (ft != null) { - fid = ft.getFontId(); + fid = ft.getFontId(); } } if (tr.style.font != null) { fid = tr.style.font.getFontId(); - } - - tr2.styleFlagsHasFont = fid != 0; + } + + tr2.styleFlagsHasFont = fid != 0; tr2.fontId = fid; tr2.textHeight = tr.style.fontHeight; if (tr.style.textColor != null) { diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics.swf b/libsrc/ffdec_lib/testdata/graphics/graphics.swf index df1e46e47..6aa77757b 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 ec5f65621..38a85a1bf 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/DOMDocument.xml @@ -1,7 +1,7 @@ - + @@ -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();]]> - + - - + + @@ -2519,7 +2519,7 @@ stop();]]> - + @@ -2545,7 +2545,7 @@ stop();]]> - + @@ -2584,7 +2584,7 @@ stop();]]> - + @@ -2597,7 +2597,7 @@ stop();]]> - + @@ -2623,7 +2623,7 @@ stop();]]> - + @@ -2634,13 +2634,13 @@ stop();]]> - + - + - ABCDEF + ABCDEFGHIJKL @@ -2649,7 +2649,7 @@ stop();]]> - + @@ -4063,6 +4063,13 @@ stop();]]> + + + + + + + @@ -4076,12 +4083,5 @@ stop();]]> - - - - - - - \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml index 894ca8500..c6115f532 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/ScaledRect.xml @@ -28,85 +28,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/Sprite1.xml index 04ecc3790..bfbd08dee 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 beeafb524..3ac90df2b 100644 --- a/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml +++ b/libsrc/ffdec_lib/testdata/graphics/graphics/LIBRARY/grid.xml @@ -28,69 +28,74 @@ + - - - - + + + - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - + - - - - - - + + + + + + - - - + + + + + + + + + + + + - - - - - - - - + + + + + - - + + + + + + + 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 3bad45fff..d8136706a 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-11-05T03:36:41-08:00 - 2023-11-05T03:36:41-08:00 + 2023-11-26T09:37:30-08:00 + 2023-11-26T09:37:30-08:00 @@ -15,7 +15,7 @@ - xmp.iid:6FD8A146CB7BEE11BC1CD4CECDBD36AD + xmp.iid:08941A39768CEE118671C1302BB7E893 xmp.did:D6D3FE199784EB1187FEAE6972EC5115 xmp.did:D6D3FE199784EB1187FEAE6972EC5115 @@ -170,6 +170,12 @@ 2021-03-14T08:29:20+01:00 Adobe Flash Professional CS6 - build 481 + + created + xmp.iid:08941A39768CEE118671C1302BB7E893 + 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 dc7f69cd7..718d5922e 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