W3C home > Mailing lists > Public > www-svg@w3.org > February 2010

Re: size of text box

From: Helder Magalh„es <helder.magalhaes@gmail.com>
Date: Wed, 24 Feb 2010 13:37:35 +0000
Message-ID: <2a1ddf8a1002240537y3a1a50e8r9e9c24f6f9d54bad@mail.gmail.com>
To: Immanuel Normann <immanuel.normann@googlemail.com>
Cc: www-svg@w3.org
Hi Immanuel,


Welcome to the community! :-)


> is there a js method to calculate the size of a text box?
> The scenario I have in mind: I want to render text in a speech bubble and of
> cause the speach bubble size should be adjusted to the text.
> (what I am looking for is something like the contentBox† in the dojo
> framework).

First of all, note that "[t]his mailing list is for technical
discussion on Scalable Vector Graphics (SVG) and its specifications"
so I'd recommend redirecting future threads to authoring/development
related channels such as SVG Developers [2]. ;-)

For calculating the size of any locatable element you may use its
"getBBox" [3] DOM method. This is generic (not specific to text) and
works quite well for most use-cases. :-)

There are also related, text-specific methods/properties for
determining string and/or character dimensions which one may be
interested in.


> regards,
> Immanuel

Hope this helps,
 Helder


[1] http://lists.w3.org/Archives/Public/www-svg/
[2] http://tech.groups.yahoo.com/group/svg-developers/
[3] http://www.w3.org/TR/SVG/ecmascript-binding.html
Received on Wednesday, 24 February 2010 13:38:29 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:44 GMT