> If you want to know actual text content positions I would suggest
> that the text content SVG DOM Api's would be a better choice than
> getBBox:
>
> http://www.w3.org/TR/SVG/text.html#DOMInterfaces
>
> Take a look at 'samples/tests/spec/scripting/text_content.svg'
> in the distribution for an example of using these API's.
> In particular you can call 'getEndPositionOfChar(index)' for the
> trailing space to get the location of the end of the space.
Hi,
I tried this solution and it's more accurate, but it's not the "ultimate"
solution for my space problem.
In fact, i compute height and width of each character in a String with the
following code :
SVGTextElement retourLigne = (SVGTextElement)
docCalcul.createElementNS(svgNS, "text");
retourLigne.setAttributeNS(null, "x", "0");
retourLigne.setAttributeNS(null, "y", "0");
retourLigne.setAttributeNS(null, "font-family", fontFamily);
retourLigne.setAttributeNS(null, "font-size",
String.valueOf(fontSize));
retourLigne.setAttributeNS(xmlNS, "xml:space", "preserve");
int retour = 0;
Text tmpText = docCalcul.createTextNode(string);
retourLigne.appendChild(tmpText);
docCalcul.getDocumentElement().appendChild(retourLigne);
retour += retourLigne.getEndPositionOfChar(0).getX();
docCalcul.getDocumentElement().removeChild(retourLigne);
It's worked well for all character but the space width isn't exact.
Can you tell me why ?
I need an exact size for my compute.
Here is a snapshot of the result :
Each red rectangle is the bounding rectangle of a character.
http://www.hiboox.fr/go/images/informatique/spaceproblem,8595d6a7be900c2c0c63600b7dc0678e.png.html
You can easily see the problem on the first space.
The more space i have in a string, the biggest the error is !
Cheers,
--
View this message in context:
http://www.nabble.com/Define-String-Width-with-bounding-box-tp20228931p23728414.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]