There appears to be a rather unusual bug in font handling under newer JDKs
with squiggle, and I am somewhat at a loss to guess what's actually
happening. Below is a pseudo-minimal test case. Effectively, the problem
appears to be that under some circumstances, text-anchor: middle does not
work, and instead aligns the text somewhat in the text-advance direction
of where it ought to be; specifically, in the figure below, the line
should bisect all three tspans, but fails to do so for the second of them.
I'm presently seeing this error on Sun, er, Oracle Java 1.6.0_25-b06 on
opensuse 11.3 (Linux). The error does not occur with an antiquated
1.5.0_22-b03 JDK I've lying around. Nor does it occur with firefox,
opera, or inkscape (though the latter doesn't seem to support @dy). I've
not yet been able to test on windows. Both Batik 1.6 and 1.7 behave
identically.
Significantly, the error in alignment only occurs if some text in the same
font has previously (document order, I assume) been used: deleting the
first text element, or changing its font (or the font of the second
element) causes the problem to vanish. So long as the fonts are kept the
same however, the problem seems to occur with all fonts that I've tested
with.
If there are additional text elements, they will all exhibit this problem.
If a text element contains additional tspans, all but the last will be
shifted.
I don't know how text-anchor: middle is implemented in Batik, and it seems
it isn't easy to find out, but perhaps Batik (or the newer versions of the
JDK) is caching some incorrect information-AWT font metrics perhaps?
Really, I'm just guessing-I hope that someone with greater expertise might
be able to produce a better guess.
I've not had a chance to look at it systematically, but it seems as though
the misaligned tspans are approximately (but not quite) aligned on the
middle of the text excluding the last word; effectively left-aligned when
there is only a single word. Perhaps the behavior of a collection changed
between JDKs 1.5 and 1.6 (or became buggy), and a fencepost error has
developed as a result? Again, this is only a guess.
---cut
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
version="1.1">
<text
style="font-family: Arial; font-size: 14; text-anchor: middle;"
x="50"
y="20">
<tspan x="50">Sample Text</tspan>
</text>
<text
style="font-family: Arial; font-size: 14; text-anchor: middle;"
x="50"
y="50">
<tspan x="50">More Sample</tspan>
<tspan dy="1em" x="50">Text</tspan>
</text>
<line x1="50" y1="0" x2="50" y2="70" stroke="black" stroke-width=".5"/>
</svg>
---cut
--
HH
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org