W3C home > Mailing lists > Public > www-svg@w3.org > March 2004

Re: Text measurement

From: Antoine Quint <ml@graougraou.com>
Date: Tue, 23 Mar 2004 16:10:01 +0100
Message-Id: <280E76A4-7CDC-11D8-9000-000393D124C4@graougraou.com>
Cc: <www-svg@w3.org>
To: ndumas@insa-rouen.fr

Bonjour Nathalie,

On 23 mars 04, at 16:16, ndumas@insa-rouen.fr wrote:

> i'm actually having a hard time finding information about how to 
> measure a
> string (or a sentence) once a font has been applied.
>
> that is, what is the length of a sentence (in px or so) once it is 
> written
> in a certain font of a certain weigth ?

This is quite simple. There are two mehtods you can call on your <text> 
element:

- getComputedTextLength(): takes into account internationalization 
issues (vertical text for instance)
- getBBox(): just gives you the raw bbox

Antoine
-- 
Antoine Quint <aq@fuchsia-design.com>
W3C SVG Working Group Invited Expert
SVG Consulting, Teaching and Outsourcing
Received on Tuesday, 23 March 2004 10:11:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 5 November 2012 23:52:55 GMT