Tjorven Lauchardt wrote:
I was wondering, if I could use a simpler workaround, but ended up at another problem. First the workaround:
I create a java.awt.Font with the same (as far as I know) parameters, I give to the SVG DOM. After that, the variable "bounds" should contain the boundingbox of the Text, but in fact it is smaller. Here the code:
String title="something";
Font f = new Font("SansSerif",Font.PLAIN,12);
Rectangle2D bounds = f.getStringBounds(title,new FontRenderContext(null,true,true));
// the text-element Element text = doc.createElementNS(svgNS,"text"); ... text.setAttributeNS(null,"font-family","sans-serif"); text.setAttributeNS(null,"font-size","12pt"); Text textNode = doc.createTextNode(title); text.appendChild(textNode);
Ouch. My fault: The workaround works fine, but the units of the boundings box (in variable bounds) are points, so my background-rect has to have the following attributes:
rect.setAttributeNS(null,"width",String.valueOf(bounds.getWidth())+"pt"); rect.setAttributeNS(null,"height",String.valueOf(bounds.getHeight())+"pt");
I didn't add the "pt" in the first place, now the problem is solved!
Great, thank you for your help!
Regards, Tjorven
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]