[ https://issues.apache.org/jira/browse/FOP-3135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17741931#comment-17741931 ]
Dave Roxburgh commented on FOP-3135: ------------------------------------ My testing suggests that the presentation error is in the placement of the glyphs - the spacing between the glyphs is excessive in the x direction. The absolute glyph positioning is also excessive in the y direction. Fop calls the Batik Bridge to paint the image. The Batik Bridge calls back to FOP's NativeTextPainter.paintTextRuns() with textRuns to be painted. Those TextRuns position the glyphs incorrectly in both the x and y directions as described. Straight transformation of the SVG to various image formats via the Batik image transcoders works correctly but that's taking a very different path through the Batik code. As a manual intervention, cutting the adjustGlyphTJ value down by one third and reducing the glyph Y position by a quarter produces an output which looks very close to the correct placement. I can't see that FOP is setting the Batik Bridge up incorrectly so I'm gong to suggest that this is probably a Batik issue. It could be that Batik is finding a different font or it could be a scaling issue. I'll attach my working resources in case they're of use: MI-test.fo MI-tspan.svg MI-out.pdf - output produced by main branch (by: fop MI-test.fo MI-out.pdf). MI.patch - patch to implement manual intervention. MI-out-patch.pdf - output produced with patch applied. -- I'd suggest reporting on the Batik JIRA - https://issues.apache.org/jira/projects/BATIK/issues/ Link to this report for background. [^MI-test.fo] [^MI-tspan.svg] [^MI-out.pdf] [^MI.patch] ^[^MI-out-patch.pdf]^ > SVG <tspan> content is displayed on a single line without spaces > ---------------------------------------------------------------- > > Key: FOP-3135 > URL: https://issues.apache.org/jira/browse/FOP-3135 > Project: FOP > Issue Type: Bug > Components: image/svg > Reporter: Julien Lacour > Priority: Minor > Attachments: MI-out-1.pdf, MI-out-patch-1.pdf, MI-out-patch.pdf, > MI-out.pdf, MI-test-1.fo, MI-test.fo, MI-tspan-1.svg, MI-tspan.svg, MI.patch, > tspan.svg > > > We have found an issue in FOP when transforming PDFs with SVGs containing > <tspan> with multiple @x and/or @y attributes values. > The problem is located in > org.apache.fop.svg.PDFTextPainter.writeGlyphs(FOPGVTGlyphVector, > GeneralPath), the positions given by x and y are never used when set. > A possible fix for this issue is the following: > {code:java} > for (int i = 0, n = gv.getNumGlyphs(); i < n; i++) { > int gc = gv.getGlyphCode(i); > int[] pa = ((i > dp.length) || (dp[i] == null)) ? > paZero : dp[i]; > if (gv.getGlyphPosition(i) != null) { > Point2D gp = gv.getGlyphPosition(i); > double x = gp.getX() - initialPos.getX(); > double y = -(gp.getY() - initialPos.getY()); > double xd = x - xoLast; > double yd = y - yoLast; > textUtil.writeTd(xd, yd); > textUtil.writeTj((char) gc, true, false); > xc = x + pa[2]; > yc = y + pa[3]; > xoLast = x; > yoLast = y; > } else { > double xo = xc + pa[0]; > double yo = yc + pa[1]; > double xa = f.getWidth(gc); > double ya = 0; > double xd = (xo - xoLast) / 1000f; > double yd = (yo - yoLast) / 1000f; > > textUtil.writeTd(xd, yd); > textUtil.writeTj((char) gc, true, false); > xc += xa + pa[2]; > yc += ya + pa[3]; > xoLast = xo; > yoLast = yo; > } > } > {code} > I also attached an example for testing, it can be opened in Batik for > comparison. -- This message was sent by Atlassian Jira (v8.20.10#820010)