Hi Russell.

Cameron McCormack:
> OK, I’ll mail you and the list when I take a look at it next week.

OK I have created a branch and checked in the very basic XHTML support
using Flying Saucer:

  http://svn.apache.org/repos/asf/xmlgraphics/batik/branches/foreignObject/

The Flying Saucer library itself is not checked in there, since it is
LGPL, and the ASF says that LGPL artifacts cannot be distributed from
ASF servers.  So after checking the above directory out from Subversion,
you’ll have to grab the latest FS from here:

  
http://pigeonholdings.com/projects/flyingsaucer/downloads/r8/flyingsaucer-R8pre2.zip

and then take the core-renderer.jar from that ZIP file and place it in
the lib/ directory in the Batik SVN checkout.  Then make and run
Squiggle as usual.

Attached is a small test SVG file that has XHTML content in a
<foreignObject>, and a screenshot of what it looks like running in
Squiggle.  (Note how the text sizing isn’t quite right; I think that’s
because FS is treating fonts differently from Batik, and the metrics
come out differently.)

The architecture for a <foreignObject> handler is overly simple at the
moment.  The org.apache.batik.bridge.ForeignObjectHandler interface has
only a single method:

  GraphicsNode createGraphicsNode
    (BridgeContext ctx, Element e, float w, float h);

‘e’ is the first element child of the <foreignObject>, and ‘w’ and ‘h’
are the width and height values from the <foreignObject> in user units.
The method just needs to return a GraphicsNode that is the graphical
representation of the foreign content.

The XHTML handling is done in
org.apache.batik.bridge.XHTMLForeignObjectHandlerFactory’s static inner
class Handler.  Basically it just creates an
org.xhtmlrenderer.simple.Graphics2DRenderer object and tells it to
render on to an org.apache.batik.svggen.SVGGraphics2D.  That results in
an SVG document that is the rendering of the XHTML, which is then built
and returned from createGraphicsNode().

Hopefully that is a good starting point for you to work from.

Cameron

-- 
Cameron McCormack ≝ http://mcc.id.au/

<<attachment: test.svg>>

<<attachment: shot.png>>

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

Reply via email to