Fixed #2239 Default font name detection

Fixed #2239 Exporting TTF font on Linux
This commit is contained in:
Jindra Petřík
2024-07-21 19:43:35 +02:00
parent 2158be80fe
commit d46d32be30
6 changed files with 26 additions and 10 deletions

View File

@@ -46,6 +46,8 @@ All notable changes to this project will be documented in this file.
- [#2231] AS3 coercion to String as convert
- [#2257] Shape SVG Importer - Linear gradient matrix
- [#2253] Drawing 0,0 grid in transform tool on Linux causing sun internal errors
- [#2239] Default font name detection
- [#2239] Exporting TTF font on Linux
### Changed
- [#2185] MochiCrypt no longer offered for auto decrypt, user needs to choose variant from "Use unpacker" menu
@@ -3418,6 +3420,7 @@ Major version of SWF to XML export changed to 2.
[#2231]: https://www.free-decompiler.com/flash/issues/2231
[#2257]: https://www.free-decompiler.com/flash/issues/2257
[#2253]: https://www.free-decompiler.com/flash/issues/2253
[#2239]: https://www.free-decompiler.com/flash/issues/2239
[#2206]: https://www.free-decompiler.com/flash/issues/2206
[#2100]: https://www.free-decompiler.com/flash/issues/2100
[#2123]: https://www.free-decompiler.com/flash/issues/2123

Binary file not shown.

Binary file not shown.

View File

@@ -128,7 +128,7 @@ public class FontExporter {
currentIndex++;
}
}
return ret;
}
@@ -158,7 +158,7 @@ public class FontExporter {
final double divider = t.getDivider();
File ttfFile = file;
if (mode == FontExportMode.WOFF) {
ttfFile = File.createTempFile("ffdec_export", ".ttf");
}
@@ -167,7 +167,7 @@ public class FontExporter {
if (fontName.length() == 0) {
fontName = "noname";
}
Fontastic f = new Fontastic(fontName, ttfFile);
String cop = t.getCopyright();

View File

@@ -376,11 +376,11 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
}
if (installedFontsByFamily.containsKey("Times New Roman")) {
defaultFontName = "Times New Roman";
defaultFontName = installedFontsByFamily.get("Times New Roman").keySet().iterator().next();
} else if (installedFontsByFamily.containsKey("Arial")) {
defaultFontName = "Arial";
defaultFontName = installedFontsByFamily.get("Arial").keySet().iterator().next();
} else {
defaultFontName = installedFontsByFamily.keySet().iterator().next();
defaultFontName = installedFontsByFamily.get(installedFontsByFamily.keySet().iterator().next()).keySet().iterator().next();
}
}

View File

@@ -28,9 +28,15 @@ package fontastic;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.doubletype.ossa.Engine;
import org.doubletype.ossa.OutOfRangeException;
import org.doubletype.ossa.adapter.EContour;
@@ -169,11 +175,18 @@ public class Fontastic {
m_engine.getTypeface().addRequiredGlyphs();
m_engine.buildTrueType();
// End TTF creation
if (outFile.exists()) {
outFile.delete();
// End TTF creation
Path copied = outFile.toPath();
Path originalPath = ttfFile.toPath();
try {
Files.copy(originalPath, copied, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ex) {
//ignore
}
ttfFile.renameTo(outFile);
ttfFile.delete();
cleanup();
}