[xep-support] SVG Text baseline alignment issue

From: Darren Munt <darrenm@ardex.com.au>
Date: Thu Feb 21 2013 - 20:44:11 PST

I'm using SVG to embed some charts in a PDF document. Because I need to support both PDF and the web from the same SVG, I'm outputting almost identical SVG to both the HTML page and to the FO which is fed into RenderX.

Because there's no consistency amongst browsers as to how text is aligned vertically in relation to the specified y coordinate, I use a tspan with a dy value to adjust this for each target in order to have consistent results. So the text element specifies the y coordinate for the text container, and the dy attribute of the tspan element specifies an offset within that to adjust for individual alignment handling in the browser/RenderX.

However when I specify a dy value in the SVG that I pass to RenderX I am getting weird vertical alignment issues which disappear when I remove the dy attribute from the tspan.

My SVG in part looks like this:

                <text x="103" y="52" text-anchor="start" font="12 'Arial'" stroke="none" stroke-width="0" fill="#5c477a" font-size="12" font-weight="bold">
                  <tspan dy="4">Competing</tspan>
                </text>
                <text x="377" y="52" text-anchor="end" font="12 'Arial'" stroke="none" stroke-width="0" fill="#5c477a" font-size="12" font-weight="bold">
                  <tspan dy="4">Collaborating</tspan>
                </text>
                <text x="103" y="310" text-anchor="start" font="12 'Arial'" stroke="none" stroke-width="0" fill="#5c477a" font-size="12" font-weight="bold">
                  <tspan dy="4">Avoiding</tspan>
                </text>
                <text x="377" y="310" text-anchor="end" font="12 'Arial'" stroke="none" stroke-width="0" fill="#5c477a" font-size="12" font-weight="bold">
                  <tspan dy="4">Accommodating</tspan>
                </text>
                <text x="240" y="181" text-anchor="middle" font="12 'Arial'" stroke="none" stroke-width="0" fill="#5c477a" font-size="12" font-weight="bold">
                  <tspan dy="4">Compromising</tspan>
                </text>
When this is rendered by RenderX I see this:

[cid:image001.png@01CE1111.D09D77A0]

As you can see 'Competing' is not aligned with 'Collaborating' and 'Avoiding' is not aligned with 'Accommodating', despite each pair having y and dy coordinates in common. The placement of Competing and Avoiding are correct in terms of how I'm aiming to have it look, but the other two are defaulting to the baseline alignment, or are ignoring the dy attribute when text-anchor is not 'start'. Note I am getting similar alignment problems when text-anchor="middle": the text in the middle of the square 'Compromising' is intended to be aligned centrally with the horizontal white line.

Can you let me know if there's a work around for this, or if there's an issue with my SVG?

!DSPAM:87,5126f9439853737320948!

_______________________________________________
(*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service http://w
ww.renderx.com/terms-of-service.html

image001.png
Received on Thu Feb 21 20:51:18 2013

This archive was generated by hypermail 2.1.8 : Thu Feb 21 2013 - 20:51:25 PST