Have you a example with the SVGTextContentElement interface.

-----Ursprüngliche Nachricht-----
Von: Andreas Neumann [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 17. September 2008 09:43
An: [EMAIL PROTECTED]
Cc: Batik User
Betreff: Re: text width and height


Hi Tilo,

On every SVG element you can query the bounding box to get the width and
height: .getBBox() - this retunrns an SVGRect element with
x,y,width,height

You can use the SVGTextContentElement interface to query text related
stuff. The following methods may be of interest:

.getComputedTextLength()
.getExtentOfChar() (for individual glyphs)
.getStartPositionOfChar() (for individual glyphs)
.getEndePositionOfChar() (for individual glyphs)

and a couple more ...

See http://phrogz.net/ObjJob/object.asp?id=145 and
http://www.w3.org/TR/SVG11/text.html#DOMInterfaces

Andreas

> Hi @ all,
>
> on Java swing i can use the folowing code to get a text width and height:
>
> Font f = new Font("Arial", Font.BOLD, 1 );
> FontMetrics fm = getFontMetrics(f);
> int textWidth = fm.stringWidth("example text");
> int textHeight = fm.getHeight();
>
> proviede batike a equivalent how can i get the same information for a text
> in the SVG File.
>
> Many thanks for your help
>
> Tilo Behrmann
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Andreas Neumann
Böschacherstrasse 6, CH-8624 Grüt/Gossau, Switzerland
Email: [EMAIL PROTECTED], Web:
* http://www.carto.net/ (Carto and SVG resources)
* http://www.carto.net/neumann/ (personal page)
* http://www.svgopen.org/ (SVG Open Conference)
* http://www.geofoto.ch/ (Georeferenced Photos of Switzerland)


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


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

Reply via email to