Bounding Box accuracy for text containing ISO (Æ) characters
Charles Seelig <[email protected]>
| Newsgroups | gmane.text.xml.batik.user |
|---|---|
| Message-ID | <CAGhGAhqDO_NwU_FHH6XRJOpv3CuBPpgQQS07M4dkt_4u7PxfoQ@mail.gmail.com> |
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("ΑΩ");
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