Fixed: #2471 SVG Export - exporting with font-face - incorrect text size

This commit is contained in:
Jindra Petřík
2025-06-23 12:01:53 +02:00
parent bfe685054b
commit 8c18a4408f
2 changed files with 11 additions and 6 deletions

View File

@@ -854,7 +854,7 @@ public abstract class TextTag extends DrawableTag {
public static void staticTextToSVG(SWF swf, List<TEXTRECORD> 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<SHAPE> 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");