From 8c18a4408f06b7ab2b5ad9df549d72b7de2841bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 23 Jun 2025 12:01:53 +0200 Subject: [PATCH] Fixed: #2471 SVG Export - exporting with font-face - incorrect text size --- CHANGELOG.md | 4 ++-- .../jpexs/decompiler/flash/tags/base/TextTag.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b88ec832e..3975c0d1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,8 +78,8 @@ All notable changes to this project will be documented in this file. - [#2470] Transform - paste matrix, edit current matrix not working - Do not allow to switch PlaceObjects in transform mode - [#2471] Clipping - multiple clips handling, in display and also SVG export -- [#2471] SVG Export - exporting with font-face - text tags with multiple texts -- [#2471] SVG Export - exporting with font-face - fix invalid family names +- [#2471] SVG Export - exporting with font-face - text tags with multiple texts, + fix invalid family names, incorrect text size ## [23.0.1] - 2025-05-16 ### Fixed 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 f08d3fb82..a3dfc3109 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 @@ -854,7 +854,7 @@ public abstract class TextTag extends DrawableTag { public static void staticTextToSVG(SWF swf, List textRecords, int numText, SVGExporter exporter, RECT bounds, MATRIX textMatrix, ColorTransform colorTransform, double zoom, Matrix transformation) { int textColor = 0; FontTag font = null; - int textHeight = 12; + double textHeight = 12; int x = 0; int y = 0; List glyphs = new ArrayList<>(); @@ -892,11 +892,16 @@ public abstract class TextTag extends DrawableTag { if (exporter.useTextTag) { StringBuilder text = new StringBuilder(); int totalAdvance = 0; - for (GLYPHENTRY entry : rec.glyphEntries) { + for (int i = 0; i < rec.glyphEntries.size(); i++) { + GLYPHENTRY entry = rec.glyphEntries.get(i); if (entry.glyphIndex != -1) { char ch = font.glyphToChar(entry.glyphIndex); text.append(ch); - totalAdvance += entry.glyphAdvance; + if (i == rec.glyphEntries.size() - 1 && entry.glyphAdvance == 0) { + totalAdvance += font.getGlyphAdvance(entry.glyphIndex) * rat; + } else { + totalAdvance += entry.glyphAdvance; + } } } @@ -908,7 +913,7 @@ public abstract class TextTag extends DrawableTag { String fontFamily = makeValidStyleFontFamily(font.getFontNameIntag()); Element textElement = exporter.createElement("text"); - textElement.setAttribute("font-size", Double.toString(rat * 1024)); + textElement.setAttribute("font-size", Double.toString(textHeight / SWF.unitDivisor)); textElement.setAttribute("font-family", fontFamily); textElement.setAttribute("textLength", Double.toString(totalAdvance / SWF.unitDivisor)); textElement.setAttribute("lengthAdjust", "spacing");