Hi Dylan,
"Dylan Browne" <[EMAIL PROTECTED]> wrote on 04/03/2007 10:19:30
AM:
> If I am rendering a specified font in SVG, say Verdana, is there anyway
to
> ascertain information about the font rendering. What I need to get hold
of
> is the ascent and descent so I am able to layout text correctly.
>
> I am guessing to be able to do this I need to get hold of the Font
Metrics
> object, and to do that would require access to the Graphics object?
The Graphics object won't help that much actually. If you are using
a "Platform Font" then you can just use the Standard Java API's to get
the font metrics. If you are using an SVG Font, this is quite a bit
more complex as the construction of an SVG Font Instance requires a
text element hooked into the CSS cascade. In fact the easiest way
to get this would be to build an SVG text element and then get the
Font associated with the GVT Graphics node.
The method:
BridgeContext.getGraphicsNode(Element)
Can be used to get the batik.gvt.TextNode that is associated
with an SVG Text Element. From that you can get the
AttributedCharacterIterator, from which you can get the Font by
looking get the value for the TextAttribute:
batik.gvt.text.GVTAttributedCharacterIterator.GVT_FONT.
> I am creating my SVG using Batik DOM, so am also guessing this is not
> possible? In which case I should define my own font, or use a true
> type font and convert it to SVG font using ttf2SVG?
It is possible although as you can see from the sketch above
it's not real easy (unless you are only concerned with Platform
fonts).
> Hope my questions make sense, and thanks in advance for any help.
Good luck!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]