From bfe685054b7ff45394c8238f80bf27bb7bc9b6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 23 Jun 2025 11:00:21 +0200 Subject: [PATCH] Fixed: #2471 SVG Export - exporting with font-face - fix invalid family names --- CHANGELOG.md | 1 + .../jpexs/decompiler/flash/tags/base/TextTag.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cb1f2cd0..b88ec832e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ All notable changes to this project will be documented in this file. - 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 ## [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 08f6450ba..f08d3fb82 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 @@ -832,6 +832,13 @@ public abstract class TextTag extends DrawableTag { } } + private static String makeValidStyleFontFamily(String family) { + family = family.replace("+", "_"); + family = family.replace("\uFFFD", "_"); + //this may be incomplete list of incompatibilities + return family; + } + /** * Converts static text to SVG. * @param swf SWF @@ -897,10 +904,12 @@ public abstract class TextTag extends DrawableTag { if (hasOffset) { exporter.createSubGroup(Matrix.getTranslateInstance(x, y), null); } + + String fontFamily = makeValidStyleFontFamily(font.getFontNameIntag()); Element textElement = exporter.createElement("text"); textElement.setAttribute("font-size", Double.toString(rat * 1024)); - textElement.setAttribute("font-family", font.getFontNameIntag()); + textElement.setAttribute("font-family", fontFamily); textElement.setAttribute("textLength", Double.toString(totalAdvance / SWF.unitDivisor)); textElement.setAttribute("lengthAdjust", "spacing"); textElement.setTextContent(text.toString()); @@ -913,7 +922,7 @@ public abstract class TextTag extends DrawableTag { exporter.addToGroup(textElement); FontExportMode fontExportMode = FontExportMode.WOFF; - exporter.addStyle(font.getFontNameIntag(), new FontExporter().exportFont(font, fontExportMode), fontExportMode); + exporter.addStyle(fontFamily, new FontExporter().exportFont(font, fontExportMode), fontExportMode); if (hasOffset) { exporter.endGroup();