diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index a8b24068b..38f6e8bc0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -447,36 +447,8 @@ public class DefineText2Tag extends TextTag { @Override public boolean alignText(TextAlign textAlign) { - int maxWidth = 0; - for (TEXTRECORD tr : textRecords) { - int width = tr.getTotalAdvance(); - - if (width > maxWidth) { - maxWidth = width; - } - } - - for (TEXTRECORD tr : textRecords) { - int width = tr.getTotalAdvance(); - switch (textAlign) { - case LEFT: - tr.xOffset = 0; - tr.styleFlagsHasXOffset = true; - break; - case CENTER: - tr.xOffset = (maxWidth - width) / 2; - tr.styleFlagsHasXOffset = true; - break; - case RIGHT: - tr.xOffset = maxWidth - width; - tr.styleFlagsHasXOffset = true; - break; - case JUSTIFY: - tr.xOffset = 0; - tr.styleFlagsHasXOffset = true; - break; - } - } + alignText(textRecords, textAlign); + setModified(true); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 83462acc2..923216df5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -455,36 +455,8 @@ public class DefineTextTag extends TextTag { @Override public boolean alignText(TextAlign textAlign) { - int maxWidth = 0; - for (TEXTRECORD tr : textRecords) { - int width = tr.getTotalAdvance(); - - if (width > maxWidth) { - maxWidth = width; - } - } - - for (TEXTRECORD tr : textRecords) { - int width = tr.getTotalAdvance(); - switch (textAlign) { - case LEFT: - tr.xOffset = 0; - tr.styleFlagsHasXOffset = true; - break; - case CENTER: - tr.xOffset = (maxWidth - width) / 2; - tr.styleFlagsHasXOffset = true; - break; - case RIGHT: - tr.xOffset = maxWidth - width; - tr.styleFlagsHasXOffset = true; - break; - case JUSTIFY: - tr.xOffset = 0; - tr.styleFlagsHasXOffset = true; - break; - } - } + alignText(textRecords, textAlign); + setModified(true); return 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 81af44a33..d866e2c7b 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 @@ -117,6 +117,39 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { } } + public static void alignText(List textRecords, TextAlign textAlign) { + int maxWidth = 0; + for (TEXTRECORD tr : textRecords) { + int width = tr.getTotalAdvance(); + + if (width > maxWidth) { + maxWidth = width; + } + } + + for (TEXTRECORD tr : textRecords) { + int width = tr.getTotalAdvance(); + switch (textAlign) { + case LEFT: + tr.xOffset = 0; + tr.styleFlagsHasXOffset = true; + break; + case CENTER: + tr.xOffset = (maxWidth - width) / 2; + tr.styleFlagsHasXOffset = true; + break; + case RIGHT: + tr.xOffset = maxWidth - width; + tr.styleFlagsHasXOffset = true; + break; + case JUSTIFY: + tr.xOffset = 0; + tr.styleFlagsHasXOffset = true; + break; + } + } + } + public static Map getTextRecordsAttributes(List list, List tags) { Map att = new HashMap<>(); RECT textBounds = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE);