From b8cf60c4428c807a5cdf3dc9492e73c0cec1cf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 28 Oct 2022 23:49:03 +0200 Subject: [PATCH] Fixed #1711 DefineFont2-3 advance values need to be handled as unsigned (UI16) --- CHANGELOG.md | 2 ++ .../com/jpexs/decompiler/flash/tags/DefineFont2Tag.java | 7 ++++--- .../com/jpexs/decompiler/flash/tags/DefineFont3Tag.java | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32a5fc2d5..c4c1af0e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file. - Freetransform tool dragging not always started on mousedown - [#1695] Freetransform tool vs zooming - [#1752] Freetransform tool on sprites with offset +- [#1711] DefineFont2-3 advance values need to be handled as unsigned (UI16) ### Changed - AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long. @@ -2404,6 +2405,7 @@ All notable changes to this project will be documented in this file. [#1771]: https://www.free-decompiler.com/flash/issues/1771 [#1695]: https://www.free-decompiler.com/flash/issues/1695 [#1752]: https://www.free-decompiler.com/flash/issues/1752 +[#1711]: https://www.free-decompiler.com/flash/issues/1711 [#270]: https://www.free-decompiler.com/flash/issues/270 [#1718]: https://www.free-decompiler.com/flash/issues/1718 [#1801]: https://www.free-decompiler.com/flash/issues/1801 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index ed1ce4cf8..887f5a216 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -89,7 +89,8 @@ public class DefineFont2Tag extends FontTag { @Conditional("fontFlagsHasLayout") public int fontLeading; - @SWFType(BasicType.SI16) + //Docs Says SI16, but Flash handles this as unsigned. There's probably not such thing as negative advance + @SWFType(BasicType.UI16) @Conditional("fontFlagsHasLayout") public List fontAdvanceTable; @@ -182,7 +183,7 @@ public class DefineFont2Tag extends FontTag { fontLeading = sis.readSI16("fontLeading"); fontAdvanceTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - fontAdvanceTable.add(sis.readSI16("fontAdvance")); + fontAdvanceTable.add(sis.readUI16("fontAdvance")); } fontBoundsTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { @@ -306,7 +307,7 @@ public class DefineFont2Tag extends FontTag { sos.writeUI16(fontDescent); sos.writeSI16(fontLeading); for (int i = 0; i < numGlyphs; i++) { - sos.writeSI16(fontAdvanceTable.get(i)); + sos.writeUI16(fontAdvanceTable.get(i)); } for (int i = 0; i < numGlyphs; i++) { sos.writeRECT(fontBoundsTable.get(i)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index d51b26d04..b0d4cbe8a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.Helper; import com.jpexs.helpers.utf8.Utf8Helper; import java.awt.Font; import java.io.ByteArrayOutputStream; @@ -89,7 +90,8 @@ public class DefineFont3Tag extends FontTag { @Conditional("fontFlagsHasLayout") public int fontLeading; - @SWFType(BasicType.SI16) + //Docs Says SI16, but Flash handles this as unsigned. There's probably not such thing as negative advance + @SWFType(BasicType.UI16) @Conditional("fontFlagsHasLayout") public List fontAdvanceTable; @@ -171,7 +173,7 @@ public class DefineFont3Tag extends FontTag { fontLeading = sis.readSI16("fontLeading"); fontAdvanceTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - fontAdvanceTable.add(sis.readSI16("fontAdvance")); + fontAdvanceTable.add(sis.readUI16("fontAdvance")); } fontBoundsTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { @@ -296,7 +298,7 @@ public class DefineFont3Tag extends FontTag { sos.writeUI16(fontDescent); sos.writeSI16(fontLeading); for (int i = 0; i < numGlyphs; i++) { - sos.writeSI16(fontAdvanceTable.get(i)); + sos.writeUI16(fontAdvanceTable.get(i)); } for (int i = 0; i < numGlyphs; i++) { sos.writeRECT(fontBoundsTable.get(i));