[ https://issues.apache.org/jira/browse/FOP-3135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17737556#comment-17737556 ]
Julien Lacour commented on FOP-3135: ------------------------------------ I've tested with FOP 2.8 with {{fop -fo ..\test\tspan.fo ..\test\tspan.pdf}} ant the following FO: {code:xml} <?xml version="1.0" encoding="UTF-8"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="sample"> <fo:region-body/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="sample"> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:external-graphic src="tspan.svg"/> </fo:block> </fo:flow> </fo:page-sequence> </fo:root> {code} But the output seems quite correct, just a little truncated in the bottom part. I will analyze on my side again to see if I find the problem, maybe I use a different batik. > 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: 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)