diff --git a/CHANGELOG.md b/CHANGELOG.md index ef0523fcd..dc7a80bdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. - [#2573] AS3 - Incorrect uint/int/Number coercion - AS3 local registers type propagation - [#2566] Export bounds of sprites and buttons not containg filter offsets +- [#2582] Font normalizer setting small texts when no assigned glyph found ### Changed - [#2575] dumpSWF CLI command only allows single SWF dump (no imports, etc.) @@ -4065,6 +4066,7 @@ Major version of SWF to XML export changed to 2. [#2575]: https://www.free-decompiler.com/flash/issues/2575 [#2573]: https://www.free-decompiler.com/flash/issues/2573 [#2566]: https://www.free-decompiler.com/flash/issues/2566 +[#2582]: https://www.free-decompiler.com/flash/issues/2582 [#2556]: https://www.free-decompiler.com/flash/issues/2556 [#2536]: https://www.free-decompiler.com/flash/issues/2536 [#2537]: https://www.free-decompiler.com/flash/issues/2537 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FontNormalizer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FontNormalizer.java index 43e44912b..2dd8e1f5f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FontNormalizer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/FontNormalizer.java @@ -156,12 +156,14 @@ public class FontNormalizer { List shapes1 = font.getGlyphShapeTable(); Double h = null; Double systemH = null; + double sumH = 0; for (int i = 0; i < shapes1.size(); i++) { RECT b = shapes1.get(i).getBounds(1); h = b.getHeight() / font.getDivider(); if (h <= 0) { continue; } + sumH += h; char c = font.glyphToChar(i); Font f = new Font(systemFont, (font.isBold() ? Font.BOLD : 0) | (font.isItalic() ? Font.ITALIC : 0), 1000); if (!f.canDisplay(c)) { @@ -173,10 +175,16 @@ public class FontNormalizer { break; } - if (h != null && systemH != null) { - newScale = systemH / h; - willModify = true; + if (systemH == null) { + h = sumH / shapes1.size(); + Font f = new Font(Font.SERIF, (font.isBold() ? Font.BOLD : 0) | (font.isItalic() ? Font.ITALIC : 0), 1000); + FontRenderContext frc = new FontRenderContext(null, true, true); + GlyphVector gv = f.createGlyphVector(frc, new char[]{'H'}); + systemH = gv.getGlyphOutline(0).getBounds2D().getHeight(); } + + newScale = systemH / h; + willModify = true; final double scale = newScale; @@ -342,7 +350,8 @@ public class FontNormalizer { } private static int round20(double val) { - return (int) Math.floor(val / 20.0) * 20; + //return (int) Math.round(val / 20.0) * 20; + return (int) Math.round(val); } private Set getDefineEditTextFonts(DefineEditTextTag text) {