diff --git a/CHANGELOG.md b/CHANGELOG.md index 490c277f1..b913ac430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ All notable changes to this project will be documented in this file. - Correct line matching in debugger of AS3 after using deobfuscation - Concurrent access while in debugger - Correct body index for script initializer in P-code debugging +- #1548 TTF export - correctly handle duplicate unicode codes +- #1548 correctly handle empty generated file names ## [11.3.0] - 2020-04-25 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java index 95da8dcf9..e2639a812 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.exporters; import com.google.typography.font.sfntly.Font; @@ -46,7 +47,9 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.Date; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -175,15 +178,20 @@ public class FontExporter { f.setDescender(value); } - int glyphCount = 0; - for (int i = 0; i < shapes.size(); i++) { - - //if there are more glyphs for one char (in some weird fonts), use the last glyph + List reallyExportedGlyphs = new ArrayList<>(); + Set processedCharacters = new HashSet<>(); + //if there are more glyphs for one char (in some weird fonts), use the last glyph + for (int i = shapes.size() - 1; i >= 0; i--) { char c = t.glyphToChar(i); - while (i + 1 < shapes.size() && t.glyphToChar(i + 1) == c) { - i++; + if (!processedCharacters.contains((Character) c)) { + reallyExportedGlyphs.add(0, (Integer) i); + processedCharacters.add((Character) c); } - + } + int glyphCount = 0; + for (Integer ii : reallyExportedGlyphs) { + int i = (int) ii; + char c = t.glyphToChar(i); SHAPE s = shapes.get(i); final List contours = new ArrayList<>(); PathExporter seb = new PathExporter(swf, s, null) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index f914ceab3..103dbf720 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -843,13 +843,15 @@ public class Helper { } } - char lastChar = sb.charAt(sb.length() - 1); - if (lastChar == ' ') { - sb.setLength(sb.length() - 1); - sb.append("%20"); - } else if (lastChar == '.') { - sb.setLength(sb.length() - 1); - sb.append("%2E"); + if (!sb.isEmpty()) { + char lastChar = sb.charAt(sb.length() - 1); + if (lastChar == ' ') { + sb.setLength(sb.length() - 1); + sb.append("%20"); + } else if (lastChar == '.') { + sb.setLength(sb.length() - 1); + sb.append("%2E"); + } } str = sb.toString();