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

Font metrics support in SVG 1.2

From: Cameron McCormack <cam-www-svg@aka.mcc.id.au>
Date: Wed, 11 Feb 2004 11:42:40 +1100
To: www-svg@w3.org
Message-ID: <20040211004240.GB16940@mcc.id.au>

Hi.

Can I suggest that for SVG 1.2 there should be the ability to get some
information about the font metrics used for a particular text element?
In particular I think it would be handy to be able to get the ascent of
the text, as it can make vertically centering text a lot easier.
Bounding box is not sufficient if you want to center to pieces of text
vertically and have them running along the same baseline, if one text
has descenders and the other doesn't.

For example, if you wanted to vertically center the string "Hello" at
(100, 100) and the string "Goodbye" at (200, 100), then the baseline of
the "Goodbye" string is going to be a bit lower than the "Hello" string,
since its bounding box has greater height.  What you really need to do
is get the ascent of these strings and use that value instead of the
height of the bounding box.  This centering will look more natural.

Perhaps a getAscentOfChar method can be added to SVGTextContentElement.

Alternatively, a vertical-text-align property that can be used to do
this type of centering could be added (and would have the benefit of not
requiring script to vertically center text).

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922
Received on Tuesday, 10 February 2004 19:42:59 GMT

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