Hello,

I am having a problem with the SVGOMTextElement.getSubStringLength method. In the following code, this.selectMask is a SVGOMRectElement and this.text a SVGOMTextElement. It tries to set the width of the <rect> element to the length of the text showed in the <text> element.

1: try {
2: this.selectMask.setAttribute("width", Float.toString(this.text.getSubStringLength(start, length)));
3: } catch (NullPointerException npe) {
4: System.out.println("selection: '" + this.text.getTextContent().substring(start, start + length) + "'");
5:     npe.printStackTrace();
6: }

The output is following:

selection: 'Hello, '
java.lang.NullPointerException
at org .apache .batik .bridge .SVGTextElementBridge.getSubStringLength(SVGTextElementBridge.java:2723) at org .apache .batik .bridge .SVGTextElementBridge.getSubStringLength(SVGTextElementBridge.java:2385) at org .apache .batik .dom .svg .SVGTextContentSupport.getSubStringLength(SVGTextContentSupport.java: 260) at org .apache .batik .dom .svg .SVGOMTextContentElement .getSubStringLength(SVGOMTextContentElement.java:195)
        at (attached source code, line 2)
        ...

The exception is raised only when the substring is at the end of the text content, and when this content is ended by a space character (' ').

Is this a bug ? If it is not, do I have to trim the substring, and get the length of this new string from the <text> element ?
Is not there a way to have this space included in the calculation ?

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to