Charles,

bbox() is indeed tricky! Try doing it on rotated text, or worse, text
on a path! However, your problem may only be a timing issue -- Batik
only knows the bbox once the text has been rendered, and in your
example there's probably not time for the renderer to have done its
work when you interrogate the properties.

HTH
Martin

On 20 February 2012 22:16, Charles Seelig <charles.see...@gmail.com> wrote:
> Hello, all.
>
> I'm wondering if anyone could point me in the right direction re: coaxing
> an SVGTextElement to return a correct bounding box when the text contains
> ISO encoded characters.
>
> SVGDocument doc = makeSvgDocument(svgString);
>
> SVGTextElement svgTextElement = (SVGTextElement)
> doc.getElementById("textID");
>
> svgTextElement.getFirstChild().setNodeValue("&#913;&#937;");
>
> float width = svgTextElement.getBBox().getWidth();
>
>
> My document is created as follows -
>
> protected SVGDocument makeSvgDocument(String svgString) {
>
> SVGDocument svgDoc = null;
>
> @SuppressWarnings("unused")
>
> GraphicsNode rootGN;
>
> UserAgent userAgent    = new UserAgentAdapter();
>
> DocumentLoader loader  = new DocumentLoader(userAgent);
>
> BridgeContext ctx      = new BridgeContext(userAgent, loader);
>
> GVTBuilder builder     = new GVTBuilder();
>
> SAXSVGDocumentFactory factory = new
> SAXSVGDocumentFactory(SAXParser.class.getCanonicalName(), true);
>
> try {
>
> svgDoc = (SVGDocument)
> factory.createDocument("file:///dummy/dummy/file.svg", new
> StringReader(svgString));
>
> ctx.setDynamicState(BridgeContext.DYNAMIC);
>
> rootGN = builder.build(ctx, svgDoc);
>
> } catch (IOException e) {
>
> e.printStackTrace();
>
> }
>
> return svgDoc;
>
> }
>
>
> It appears to me that the result (especially evident for width) is
> calculated as if the 1 character is actually 6 characters.
>
> Thank you.
>
> Best regards,
>
> Charles Seelig
>



-- 
>From my MacBook Pro

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org

Reply via email to